dialog.c 16 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3 4
/*
 * Program Manager
 *
 * Copyright 1996 Ulrich Schmid
5
 * Copyright 2002 Sylvain Petreolle
6
 * Copyright 2002 Andriy Palamarchuk
7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliard's avatar
Alexandre Julliard committed
21 22
 */

23 24
#define WIN32_LEAN_AND_MEAN

Alexandre Julliard's avatar
Alexandre Julliard committed
25 26
#include "windows.h"
#include "commdlg.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
27
#include "progman.h"
28

Alexandre Julliard's avatar
Alexandre Julliard committed
29 30 31

/***********************************************************************
 *
32
 *           DIALOG_Browse
Alexandre Julliard's avatar
Alexandre Julliard committed
33 34
 */

35 36 37
static BOOL DIALOG_Browse(HWND hDlg, LPCSTR lpszzFilter,
			  LPSTR lpstrFile, INT nMaxFile)

Alexandre Julliard's avatar
Alexandre Julliard committed
38
{
39
    OPENFILENAMEA openfilename;
Alexandre Julliard's avatar
Alexandre Julliard committed
40

41 42 43 44 45
    CHAR szDir[MAX_PATH];
    CHAR szDefaultExt[] = "exe";

    ZeroMemory(&openfilename, sizeof(openfilename));

46
    GetCurrentDirectoryA(sizeof(szDir), szDir);
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

    openfilename.lStructSize       = sizeof(openfilename);
    openfilename.hwndOwner         = Globals.hMainWnd;
    openfilename.hInstance         = Globals.hInstance;
    openfilename.lpstrFilter       = lpszzFilter;
    openfilename.lpstrFile         = lpstrFile;
    openfilename.nMaxFile          = nMaxFile;
    openfilename.lpstrInitialDir   = szDir;
    openfilename.Flags             = 0;
    openfilename.lpstrDefExt       = szDefaultExt;
    openfilename.lpstrCustomFilter = 0;
    openfilename.nMaxCustFilter    = 0;
    openfilename.nFilterIndex      = 0;
    openfilename.lpstrFileTitle    = 0;
    openfilename.nMaxFileTitle     = 0;
    openfilename.lpstrInitialDir   = 0;
    openfilename.lpstrTitle        = 0;
    openfilename.nFileOffset       = 0;
    openfilename.nFileExtension    = 0;
    openfilename.lCustData         = 0;
    openfilename.lpfnHook          = 0;
    openfilename.lpTemplateName    = 0;

70
    return GetOpenFileNameA(&openfilename);
71 72 73 74 75 76 77 78
}

/***********************************************************************
 *
 *           DIALOG_AddFilterItem
 */

static VOID DIALOG_AddFilterItem(LPSTR *p, UINT ids, LPCSTR filter)
Alexandre Julliard's avatar
Alexandre Julliard committed
79
{
80
  LoadStringA(Globals.hInstance, ids, *p, MAX_STRING_LEN);
81
  *p += strlen(*p) + 1;
82
  lstrcpyA(*p, filter);
83 84 85
  *p += strlen(*p) + 1;
  **p = '\0';
}
Alexandre Julliard's avatar
Alexandre Julliard committed
86

87 88 89 90
/***********************************************************************
 *
 *           DIALOG_BrowsePrograms
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
91

92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
static BOOL DIALOG_BrowsePrograms(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
{
  CHAR  szzFilter[2 * MAX_STRING_LEN + 100];
  LPSTR p = szzFilter;

  DIALOG_AddFilterItem(&p, IDS_PROGRAMS,  "*.exe;*.pif;*.com;*.bat");
  DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");

  return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
}

/***********************************************************************
 *
 *           DIALOG_BrowseSymbols
 */

static BOOL DIALOG_BrowseSymbols(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
{
  CHAR  szzFilter[5 * MAX_STRING_LEN + 100];
  LPSTR p = szzFilter;

  DIALOG_AddFilterItem(&p, IDS_SYMBOL_FILES,  "*.ico;*.exe;*.dll");
  DIALOG_AddFilterItem(&p, IDS_PROGRAMS,      "*.exe");
  DIALOG_AddFilterItem(&p, IDS_LIBRARIES_DLL, "*.dll");
  DIALOG_AddFilterItem(&p, IDS_SYMBOLS_ICO,   "*.ico");
  DIALOG_AddFilterItem(&p, IDS_ALL_FILES,     "*.*");

  return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
Alexandre Julliard's avatar
Alexandre Julliard committed
120 121
}

122 123 124 125 126
static struct
{
  INT nDefault;
} New;

Alexandre Julliard's avatar
Alexandre Julliard committed
127 128 129 130
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *           DIALOG_NEW_DlgProc
 */
Mike McCormack's avatar
Mike McCormack committed
131
static INT_PTR CALLBACK DIALOG_NEW_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Alexandre Julliard's avatar
Alexandre Julliard committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
{
  switch (msg)
    {
    case WM_INITDIALOG:
      CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, New.nDefault);
      break;

    case WM_COMMAND:
      switch (wParam)
	{
	case PM_NEW_GROUP:
	case PM_NEW_PROGRAM:
	  CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, wParam);
	  return TRUE;

	case IDOK:
	  EndDialog(hDlg, IsDlgButtonChecked(hDlg, PM_NEW_GROUP) ?
		    PM_NEW_GROUP : PM_NEW_PROGRAM);
	  return TRUE;

	case IDCANCEL:
	  EndDialog(hDlg, IDCANCEL);
	  return TRUE;
	}
    }
  return FALSE;
}

/***********************************************************************
 *
162
 *           DIALOG_New
Alexandre Julliard's avatar
Alexandre Julliard committed
163
 */
164
INT DIALOG_New(INT nDefault)
Alexandre Julliard's avatar
Alexandre Julliard committed
165
{
166
  New.nDefault = nDefault;
167
  return DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_NEW), Globals.hMainWnd, DIALOG_NEW_DlgProc);
Alexandre Julliard's avatar
Alexandre Julliard committed
168 169
}

170 171 172 173 174 175 176

static struct
{
  LPCSTR lpszProgramName, lpszFromGroupName;
  HLOCAL hToGroup;
} CopyMove;

Alexandre Julliard's avatar
Alexandre Julliard committed
177 178 179 180
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *           DIALOG_COPY_MOVE_DlgProc
 */
Mike McCormack's avatar
Mike McCormack committed
181
static INT_PTR CALLBACK DIALOG_COPY_MOVE_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Alexandre Julliard's avatar
Alexandre Julliard committed
182 183 184 185 186 187 188 189
{
  HLOCAL hGroup;

  switch (msg)
    {
    case WM_INITDIALOG:
      /* List all group names */
      for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
190
	SendDlgItemMessageA(hDlg, PM_TO_GROUP, CB_ADDSTRING, 0, (LPARAM)GROUP_GroupName(hGroup));
Alexandre Julliard's avatar
Alexandre Julliard committed
191

192 193
      SetDlgItemTextA(hDlg, PM_PROGRAM,    CopyMove.lpszProgramName);
      SetDlgItemTextA(hDlg, PM_FROM_GROUP, CopyMove.lpszFromGroupName);
Alexandre Julliard's avatar
Alexandre Julliard committed
194 195 196 197 198 199 200 201
      break;

    case WM_COMMAND:
      switch (wParam)
	{
	case IDOK:
	{
	  /* Get selected group */
202 203
	  INT nCurSel    = SendDlgItemMessageW(hDlg, PM_TO_GROUP, CB_GETCURSEL, 0, 0);
	  INT nLen       = SendDlgItemMessageW(hDlg, PM_TO_GROUP, CB_GETLBTEXTLEN, nCurSel, 0);
Alexandre Julliard's avatar
Alexandre Julliard committed
204 205 206
	  HLOCAL hBuffer = LocalAlloc(LMEM_FIXED, nLen + 1);
	  LPSTR   buffer = LocalLock(hBuffer);

207
	  SendDlgItemMessageA(hDlg, PM_TO_GROUP, CB_GETLBTEXT, nCurSel, (LPARAM)buffer);
Alexandre Julliard's avatar
Alexandre Julliard committed
208
	  for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
209
	    if (!lstrcmpA(buffer, GROUP_GroupName(hGroup))) break;
Alexandre Julliard's avatar
Alexandre Julliard committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
	  LocalFree(hBuffer);

	  CopyMove.hToGroup = hGroup;
	  EndDialog(hDlg, IDOK);
	  return TRUE;
	}

	case IDCANCEL:
	  EndDialog(hDlg, IDCANCEL);
	  return TRUE;
	}
    }
  return FALSE;
}

225 226 227 228 229 230 231 232 233 234 235 236 237
/***********************************************************************
 *
 *           DIALOG_CopyMove
 */
HLOCAL DIALOG_CopyMove(LPCSTR lpszProgramName, LPCSTR lpszFromGroupName,
		     BOOL bMove)
{
  INT ret;

  CopyMove.lpszProgramName   = lpszProgramName;
  CopyMove.lpszFromGroupName = lpszFromGroupName;
  CopyMove.hToGroup          = 0;

238 239 240
  ret = DialogBoxW(Globals.hInstance,
                   bMove ? MAKEINTRESOURCEW(IDD_MOVE) : MAKEINTRESOURCEW(IDD_COPY),
                   Globals.hMainWnd, DIALOG_COPY_MOVE_DlgProc);
241 242 243
  return((ret == IDOK) ? CopyMove.hToGroup : 0);
}

Alexandre Julliard's avatar
Alexandre Julliard committed
244 245 246 247 248
/***********************************************************************
 *
 *           DIALOG_Delete
 */

Alexandre Julliard's avatar
Alexandre Julliard committed
249
BOOL DIALOG_Delete(UINT ids_text_s, LPCSTR lpszName)
Alexandre Julliard's avatar
Alexandre Julliard committed
250
{
Alexandre Julliard's avatar
Alexandre Julliard committed
251 252
  return (IDYES == MAIN_MessageBoxIDS_s(ids_text_s, lpszName, IDS_DELETE,
					MB_YESNO | MB_DEFBUTTON2));
Alexandre Julliard's avatar
Alexandre Julliard committed
253 254 255 256 257 258 259 260 261 262 263 264 265
}


static struct
{
  LPSTR lpszTitle, lpszGrpFile;
  INT   nSize;
} GroupAttributes;

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *           DIALOG_GROUP_DlgProc
 */
Mike McCormack's avatar
Mike McCormack committed
266
static INT_PTR CALLBACK DIALOG_GROUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Alexandre Julliard's avatar
Alexandre Julliard committed
267 268 269 270
{
  switch (msg)
    {
    case WM_INITDIALOG:
271 272
      SetDlgItemTextA(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle);
      SetDlgItemTextA(hDlg, PM_FILE, GroupAttributes.lpszGrpFile);
Alexandre Julliard's avatar
Alexandre Julliard committed
273 274 275 276 277 278
      break;

    case WM_COMMAND:
      switch (wParam)
	{
	case IDOK:
279 280
	  GetDlgItemTextA(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle, GroupAttributes.nSize);
	  GetDlgItemTextA(hDlg, PM_FILE, GroupAttributes.lpszGrpFile, GroupAttributes.nSize);
Alexandre Julliard's avatar
Alexandre Julliard committed
281 282 283 284 285 286 287 288 289 290 291 292 293
	  EndDialog(hDlg, IDOK);
	  return TRUE;

	case IDCANCEL:
	  EndDialog(hDlg, IDCANCEL);
	  return TRUE;
	}
    }
  return FALSE;
}

/***********************************************************************
 *
294
 *           DIALOG_GroupAttributes
Alexandre Julliard's avatar
Alexandre Julliard committed
295
 */
296
BOOL DIALOG_GroupAttributes(LPSTR lpszTitle, LPSTR lpszGrpFile, INT nSize)
Alexandre Julliard's avatar
Alexandre Julliard committed
297 298 299
{
  INT ret;

300 301 302
  GroupAttributes.nSize       = nSize;
  GroupAttributes.lpszTitle   = lpszTitle;
  GroupAttributes.lpszGrpFile = lpszGrpFile;
Alexandre Julliard's avatar
Alexandre Julliard committed
303

304
  ret = DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_GROUP), Globals.hMainWnd, DIALOG_GROUP_DlgProc);
Alexandre Julliard's avatar
Alexandre Julliard committed
305 306 307
  return(ret == IDOK);
}

308 309 310 311 312 313 314 315 316

static struct
{
  LPSTR  lpszIconFile;
  INT    nSize;
  HICON  *lphIcon;
  INT    *lpnIconIndex;
} Symbol;

Alexandre Julliard's avatar
Alexandre Julliard committed
317 318
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
319
 *           DIALOG_SYMBOL_DlgProc
Alexandre Julliard's avatar
Alexandre Julliard committed
320
 */
321
static INT_PTR CALLBACK DIALOG_SYMBOL_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Alexandre Julliard's avatar
Alexandre Julliard committed
322 323 324 325
{
  switch (msg)
    {
    case WM_INITDIALOG:
326 327 328 329 330
      SetDlgItemTextA(hDlg, PM_ICON_FILE, Symbol.lpszIconFile);
      SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST, CB_SETITEMHEIGHT, 0, (LPARAM) 32);
      SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)*Symbol.lphIcon);
      SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)Globals.hDefaultIcon);
      SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST, CB_SETCURSEL, 0, 0);
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
      return TRUE;

    case WM_MEASUREITEM:
      {
	PMEASUREITEMSTRUCT measure = (PMEASUREITEMSTRUCT) lParam;
	measure->itemWidth = 32;
	measure->itemHeight = 32;
	return TRUE;
      }

    case WM_DRAWITEM:
      {
	PDRAWITEMSTRUCT dis = (PDRAWITEMSTRUCT) lParam;
	DrawIcon(dis->hDC, dis->rcItem.left, dis->rcItem.top, (HICON)dis->itemData);
	return TRUE;
      }
Alexandre Julliard's avatar
Alexandre Julliard committed
347 348 349 350 351 352 353

    case WM_COMMAND:
      switch (wParam)
	{
	case PM_BROWSE:
	  {
	    CHAR filename[MAX_PATHNAME_LEN];
354
	    filename[0] = 0;
355
	    if (DIALOG_BrowseSymbols(hDlg, filename, sizeof(filename)))
356
	      SetDlgItemTextA(hDlg, PM_ICON_FILE, filename);
Alexandre Julliard's avatar
Alexandre Julliard committed
357 358 359
	    return TRUE;
	  }

360 361 362
	case PM_HELP:
	  MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
	  return TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
363 364

	case IDOK:
365
	  {
366
	    INT nCurSel = SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST, CB_GETCURSEL, 0, 0);
Alexandre Julliard's avatar
Alexandre Julliard committed
367

368
	    GetDlgItemTextA(hDlg, PM_ICON_FILE, Symbol.lpszIconFile, Symbol.nSize);
369

370
	    *Symbol.lphIcon = (HICON)SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST,
371 372
							CB_GETITEMDATA,
							(WPARAM) nCurSel, 0);
Alexandre Julliard's avatar
Alexandre Julliard committed
373
#if 0
374
	    *Symbol.lphIcon = CopyIcon(*Symbol.lphIcon);
Alexandre Julliard's avatar
Alexandre Julliard committed
375 376
#endif

377 378 379
	    EndDialog(hDlg, IDOK);
	    return TRUE;
	  }
Alexandre Julliard's avatar
Alexandre Julliard committed
380 381 382 383 384 385 386 387 388 389 390 391 392

	case IDCANCEL:
	  EndDialog(hDlg, IDCANCEL);
	  return TRUE;
	}
    }
  return FALSE;
}

/***********************************************************************
 *
 *           DIALOG_Symbol
 */
393
static VOID DIALOG_Symbol(HICON *lphIcon, LPSTR lpszIconFile,
Alexandre Julliard's avatar
Alexandre Julliard committed
394 395 396 397 398 399 400
		   INT *lpnIconIndex, INT nSize)
{
  Symbol.nSize = nSize;
  Symbol.lpszIconFile = lpszIconFile;
  Symbol.lphIcon = lphIcon;
  Symbol.lpnIconIndex = lpnIconIndex;

401
  DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_SYMBOL), Globals.hMainWnd, DIALOG_SYMBOL_DlgProc);
Alexandre Julliard's avatar
Alexandre Julliard committed
402 403
}

404 405 406 407 408 409 410 411 412 413 414 415

static struct
{
  LPSTR lpszTitle, lpszCmdLine, lpszWorkDir, lpszIconFile, lpszTmpIconFile;
  INT   nSize;
  INT   *lpnCmdShow;
  INT   *lpnHotKey;
  HWND  hSelGroupWnd;
  HICON *lphIcon, hTmpIcon;
  INT   *lpnIconIndex, nTmpIconIndex;
} ProgramAttributes;

Alexandre Julliard's avatar
Alexandre Julliard committed
416 417
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
418
 *           DIALOG_PROGRAM_DlgProc
Alexandre Julliard's avatar
Alexandre Julliard committed
419
 */
420
static INT_PTR CALLBACK DIALOG_PROGRAM_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Alexandre Julliard's avatar
Alexandre Julliard committed
421
{
422
  CHAR buffer[MAX_STRING_LEN];
Alexandre Julliard's avatar
Alexandre Julliard committed
423 424 425
  switch (msg)
    {
    case WM_INITDIALOG:
426 427 428
      SetDlgItemTextA(hDlg, PM_DESCRIPTION, ProgramAttributes.lpszTitle);
      SetDlgItemTextA(hDlg, PM_COMMAND_LINE, ProgramAttributes.lpszCmdLine);
      SetDlgItemTextA(hDlg, PM_DIRECTORY, ProgramAttributes.lpszWorkDir);
429 430
      if (!*ProgramAttributes.lpnHotKey)
	{
431 432
	  LoadStringA(Globals.hInstance, IDS_NO_HOT_KEY, buffer, sizeof(buffer));
	  SetDlgItemTextA(hDlg, PM_HOT_KEY, buffer);
433
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
434

435 436
      CheckDlgButton(hDlg, PM_SYMBOL,
		     (*ProgramAttributes.lpnCmdShow == SW_SHOWMINIMIZED));
437
      SendDlgItemMessageA(hDlg, PM_ICON, STM_SETICON, (WPARAM)ProgramAttributes.hTmpIcon, 0);
438
      break;
Alexandre Julliard's avatar
Alexandre Julliard committed
439 440 441 442

    case WM_COMMAND:
      switch (wParam)
	{
443 444 445 446
	case PM_SYMBOL:
	  CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
	  return TRUE;

Alexandre Julliard's avatar
Alexandre Julliard committed
447 448 449
	case PM_BROWSE:
	  {
	    CHAR filename[MAX_PATHNAME_LEN];
450
	    filename[0] = 0;
451
	    if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
452
	      SetDlgItemTextA(hDlg, PM_COMMAND_LINE, filename);
Alexandre Julliard's avatar
Alexandre Julliard committed
453 454 455
	    return TRUE;
	  }

456
	case PM_OTHER_SYMBOL:
Alexandre Julliard's avatar
Alexandre Julliard committed
457
	  {
458 459 460 461
	    DIALOG_Symbol(&ProgramAttributes.hTmpIcon,
			  ProgramAttributes.lpszTmpIconFile,
			  &ProgramAttributes.nTmpIconIndex,
			  MAX_PATHNAME_LEN);
Alexandre Julliard's avatar
Alexandre Julliard committed
462

463
	    SendDlgItemMessageA(hDlg, PM_ICON, STM_SETICON, (WPARAM)ProgramAttributes.hTmpIcon, 0);
464 465
	    return TRUE;
	  }
Alexandre Julliard's avatar
Alexandre Julliard committed
466

467
	case IDOK:
468
	  GetDlgItemTextA(hDlg, PM_DESCRIPTION,
469 470
			 ProgramAttributes.lpszTitle,
			 ProgramAttributes.nSize);
471
	  GetDlgItemTextA(hDlg, PM_COMMAND_LINE,
472 473
			 ProgramAttributes.lpszCmdLine,
			 ProgramAttributes.nSize);
474
	  GetDlgItemTextA(hDlg, PM_DIRECTORY,
475 476 477 478 479
			 ProgramAttributes.lpszWorkDir,
			 ProgramAttributes.nSize);

	  if (ProgramAttributes.hTmpIcon)
	    {
Alexandre Julliard's avatar
Alexandre Julliard committed
480
#if 0
481 482
	      if (*ProgramAttributes.lphIcon)
		DestroyIcon(*ProgramAttributes.lphIcon);
Alexandre Julliard's avatar
Alexandre Julliard committed
483
#endif
484 485
	      *ProgramAttributes.lphIcon = ProgramAttributes.hTmpIcon;
	      *ProgramAttributes.lpnIconIndex = ProgramAttributes.nTmpIconIndex;
486 487 488
	      lstrcpynA(ProgramAttributes.lpszIconFile,
                        ProgramAttributes.lpszTmpIconFile,
                        ProgramAttributes.nSize);
489
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
490

491 492 493 494 495
	  *ProgramAttributes.lpnCmdShow =
	    IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
	    SW_SHOWMINIMIZED : SW_SHOWNORMAL;
	  EndDialog(hDlg, IDOK);
	  return TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
496 497 498 499 500

	case IDCANCEL:
	  EndDialog(hDlg, IDCANCEL);
	  return TRUE;
	}
501
      return FALSE;
Alexandre Julliard's avatar
Alexandre Julliard committed
502 503 504 505 506 507
    }
  return FALSE;
}

/***********************************************************************
 *
508
 *           DIALOG_ProgramAttributes
Alexandre Julliard's avatar
Alexandre Julliard committed
509
 */
510 511 512 513
BOOL DIALOG_ProgramAttributes(LPSTR lpszTitle, LPSTR lpszCmdLine,
			      LPSTR lpszWorkDir, LPSTR lpszIconFile,
			      HICON *lphIcon, INT *lpnIconIndex,
			      INT *lpnHotKey, INT *lpnCmdShow, INT nSize)
Alexandre Julliard's avatar
Alexandre Julliard committed
514
{
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
  CHAR szTmpIconFile[MAX_PATHNAME_LEN];
  INT ret;

  ProgramAttributes.nSize = nSize;
  ProgramAttributes.lpszTitle = lpszTitle;
  ProgramAttributes.lpszCmdLine = lpszCmdLine;
  ProgramAttributes.lpszWorkDir = lpszWorkDir;
  ProgramAttributes.lpszIconFile = lpszIconFile;
  ProgramAttributes.lpnCmdShow = lpnCmdShow;
  ProgramAttributes.lpnHotKey = lpnHotKey;
  ProgramAttributes.lphIcon = lphIcon;
  ProgramAttributes.lpnIconIndex = lpnIconIndex;

#if 0
  ProgramAttributes.hTmpIcon = 0;
#else
  ProgramAttributes.hTmpIcon = *lphIcon;
#endif
  ProgramAttributes.nTmpIconIndex = *lpnIconIndex;
  ProgramAttributes.lpszTmpIconFile = szTmpIconFile;
535
  lstrcpynA(ProgramAttributes.lpszTmpIconFile, lpszIconFile, MAX_PATHNAME_LEN);
536

537
  ret = DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_PROGRAM), Globals.hMainWnd, DIALOG_PROGRAM_DlgProc);
538
  return(ret == IDOK);
Alexandre Julliard's avatar
Alexandre Julliard committed
539 540
}

541

Alexandre Julliard's avatar
Alexandre Julliard committed
542 543 544 545
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *           DIALOG_EXECUTE_DlgProc
 */
Mike McCormack's avatar
Mike McCormack committed
546
static INT_PTR CALLBACK DIALOG_EXECUTE_DlgProc(HWND hDlg, UINT msg,
Alexandre Julliard's avatar
Alexandre Julliard committed
547 548 549 550 551 552 553 554 555 556 557 558 559 560
				      WPARAM wParam, LPARAM lParam)
{
  switch (msg)
    {
    case WM_COMMAND:
      switch (wParam)
	{
	case PM_SYMBOL:
	  CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
	  return TRUE;

	case PM_BROWSE:
	  {
	    CHAR filename[MAX_PATHNAME_LEN];
561
	    filename[0] = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
562
	    if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
563
	      SetDlgItemTextA(hDlg, PM_COMMAND, filename);
Alexandre Julliard's avatar
Alexandre Julliard committed
564 565 566 567
	    return TRUE;
	  }

	case PM_HELP:
Alexandre Julliard's avatar
Alexandre Julliard committed
568
	  MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
Alexandre Julliard's avatar
Alexandre Julliard committed
569 570 571 572 573
	  return TRUE;

	case IDOK:
	  {
	    CHAR cmdline[MAX_PATHNAME_LEN];
574
	    GetDlgItemTextA(hDlg, PM_COMMAND, cmdline, sizeof(cmdline));
Alexandre Julliard's avatar
Alexandre Julliard committed
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593

	    WinExec(cmdline, IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
		    SW_SHOWMINIMIZED : SW_SHOWNORMAL);
	    if (Globals.bMinOnRun) CloseWindow(Globals.hMainWnd);

	    EndDialog(hDlg, IDOK);
	    return TRUE;
	  }

	case IDCANCEL:
	  EndDialog(hDlg, IDCANCEL);
	  return TRUE;
	}
    }
  return FALSE;
}

/***********************************************************************
 *
594
 *           DIALOG_Execute
Alexandre Julliard's avatar
Alexandre Julliard committed
595 596
 */

597
VOID DIALOG_Execute(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
598
{
599
    DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_EXECUTE), Globals.hMainWnd, DIALOG_EXECUTE_DlgProc);
Alexandre Julliard's avatar
Alexandre Julliard committed
600
}