dialog.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. /*
  2. * Program Manager
  3. *
  4. * Copyright 1996 Ulrich Schmid
  5. * Copyright 2002 Sylvain Petreolle
  6. * Copyright 2002 Andriy Palamarchuk
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * 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
  21. */
  22. #define WIN32_LEAN_AND_MEAN
  23. #include "windows.h"
  24. #include "commdlg.h"
  25. #include "progman.h"
  26. /***********************************************************************
  27. *
  28. * DIALOG_Browse
  29. */
  30. static BOOL DIALOG_Browse(HWND hDlg, LPCSTR lpszzFilter,
  31. LPSTR lpstrFile, INT nMaxFile)
  32. {
  33. OPENFILENAMEA openfilename;
  34. CHAR szDir[MAX_PATH];
  35. CHAR szDefaultExt[] = "exe";
  36. ZeroMemory(&openfilename, sizeof(openfilename));
  37. GetCurrentDirectoryA(sizeof(szDir), szDir);
  38. openfilename.lStructSize = sizeof(openfilename);
  39. openfilename.hwndOwner = Globals.hMainWnd;
  40. openfilename.hInstance = Globals.hInstance;
  41. openfilename.lpstrFilter = lpszzFilter;
  42. openfilename.lpstrFile = lpstrFile;
  43. openfilename.nMaxFile = nMaxFile;
  44. openfilename.lpstrInitialDir = szDir;
  45. openfilename.Flags = 0;
  46. openfilename.lpstrDefExt = szDefaultExt;
  47. openfilename.lpstrCustomFilter = 0;
  48. openfilename.nMaxCustFilter = 0;
  49. openfilename.nFilterIndex = 0;
  50. openfilename.lpstrFileTitle = 0;
  51. openfilename.nMaxFileTitle = 0;
  52. openfilename.lpstrInitialDir = 0;
  53. openfilename.lpstrTitle = 0;
  54. openfilename.nFileOffset = 0;
  55. openfilename.nFileExtension = 0;
  56. openfilename.lCustData = 0;
  57. openfilename.lpfnHook = 0;
  58. openfilename.lpTemplateName = 0;
  59. return GetOpenFileNameA(&openfilename);
  60. }
  61. /***********************************************************************
  62. *
  63. * DIALOG_AddFilterItem
  64. */
  65. static VOID DIALOG_AddFilterItem(LPSTR *p, UINT ids, LPCSTR filter)
  66. {
  67. LoadStringA(Globals.hInstance, ids, *p, MAX_STRING_LEN);
  68. *p += strlen(*p) + 1;
  69. lstrcpyA(*p, filter);
  70. *p += strlen(*p) + 1;
  71. **p = '\0';
  72. }
  73. /***********************************************************************
  74. *
  75. * DIALOG_BrowsePrograms
  76. */
  77. static BOOL DIALOG_BrowsePrograms(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
  78. {
  79. CHAR szzFilter[2 * MAX_STRING_LEN + 100];
  80. LPSTR p = szzFilter;
  81. DIALOG_AddFilterItem(&p, IDS_PROGRAMS, "*.exe;*.pif;*.com;*.bat");
  82. DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");
  83. return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
  84. }
  85. /***********************************************************************
  86. *
  87. * DIALOG_BrowseSymbols
  88. */
  89. static BOOL DIALOG_BrowseSymbols(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
  90. {
  91. CHAR szzFilter[5 * MAX_STRING_LEN + 100];
  92. LPSTR p = szzFilter;
  93. DIALOG_AddFilterItem(&p, IDS_SYMBOL_FILES, "*.ico;*.exe;*.dll");
  94. DIALOG_AddFilterItem(&p, IDS_PROGRAMS, "*.exe");
  95. DIALOG_AddFilterItem(&p, IDS_LIBRARIES_DLL, "*.dll");
  96. DIALOG_AddFilterItem(&p, IDS_SYMBOLS_ICO, "*.ico");
  97. DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");
  98. return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
  99. }
  100. static struct
  101. {
  102. INT nDefault;
  103. } New;
  104. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  105. *
  106. * DIALOG_NEW_DlgProc
  107. */
  108. static INT_PTR CALLBACK DIALOG_NEW_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  109. {
  110. switch (msg)
  111. {
  112. case WM_INITDIALOG:
  113. CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, New.nDefault);
  114. break;
  115. case WM_COMMAND:
  116. switch (wParam)
  117. {
  118. case PM_NEW_GROUP:
  119. case PM_NEW_PROGRAM:
  120. CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, wParam);
  121. return TRUE;
  122. case IDOK:
  123. EndDialog(hDlg, IsDlgButtonChecked(hDlg, PM_NEW_GROUP) ?
  124. PM_NEW_GROUP : PM_NEW_PROGRAM);
  125. return TRUE;
  126. case IDCANCEL:
  127. EndDialog(hDlg, IDCANCEL);
  128. return TRUE;
  129. }
  130. }
  131. return FALSE;
  132. }
  133. /***********************************************************************
  134. *
  135. * DIALOG_New
  136. */
  137. INT DIALOG_New(INT nDefault)
  138. {
  139. New.nDefault = nDefault;
  140. return DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_NEW), Globals.hMainWnd, DIALOG_NEW_DlgProc);
  141. }
  142. static struct
  143. {
  144. LPCSTR lpszProgramName, lpszFromGroupName;
  145. HLOCAL hToGroup;
  146. } CopyMove;
  147. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  148. *
  149. * DIALOG_COPY_MOVE_DlgProc
  150. */
  151. static INT_PTR CALLBACK DIALOG_COPY_MOVE_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  152. {
  153. HLOCAL hGroup;
  154. switch (msg)
  155. {
  156. case WM_INITDIALOG:
  157. /* List all group names */
  158. for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
  159. SendDlgItemMessageA(hDlg, PM_TO_GROUP, CB_ADDSTRING, 0, (LPARAM)GROUP_GroupName(hGroup));
  160. SetDlgItemTextA(hDlg, PM_PROGRAM, CopyMove.lpszProgramName);
  161. SetDlgItemTextA(hDlg, PM_FROM_GROUP, CopyMove.lpszFromGroupName);
  162. break;
  163. case WM_COMMAND:
  164. switch (wParam)
  165. {
  166. case IDOK:
  167. {
  168. /* Get selected group */
  169. INT nCurSel = SendDlgItemMessageW(hDlg, PM_TO_GROUP, CB_GETCURSEL, 0, 0);
  170. INT nLen = SendDlgItemMessageW(hDlg, PM_TO_GROUP, CB_GETLBTEXTLEN, nCurSel, 0);
  171. HLOCAL hBuffer = LocalAlloc(LMEM_FIXED, nLen + 1);
  172. LPSTR buffer = LocalLock(hBuffer);
  173. SendDlgItemMessageA(hDlg, PM_TO_GROUP, CB_GETLBTEXT, nCurSel, (LPARAM)buffer);
  174. for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
  175. if (!lstrcmpA(buffer, GROUP_GroupName(hGroup))) break;
  176. LocalFree(hBuffer);
  177. CopyMove.hToGroup = hGroup;
  178. EndDialog(hDlg, IDOK);
  179. return TRUE;
  180. }
  181. case IDCANCEL:
  182. EndDialog(hDlg, IDCANCEL);
  183. return TRUE;
  184. }
  185. }
  186. return FALSE;
  187. }
  188. /***********************************************************************
  189. *
  190. * DIALOG_CopyMove
  191. */
  192. HLOCAL DIALOG_CopyMove(LPCSTR lpszProgramName, LPCSTR lpszFromGroupName,
  193. BOOL bMove)
  194. {
  195. INT ret;
  196. CopyMove.lpszProgramName = lpszProgramName;
  197. CopyMove.lpszFromGroupName = lpszFromGroupName;
  198. CopyMove.hToGroup = 0;
  199. ret = DialogBoxW(Globals.hInstance,
  200. bMove ? MAKEINTRESOURCEW(IDD_MOVE) : MAKEINTRESOURCEW(IDD_COPY),
  201. Globals.hMainWnd, DIALOG_COPY_MOVE_DlgProc);
  202. return((ret == IDOK) ? CopyMove.hToGroup : 0);
  203. }
  204. /***********************************************************************
  205. *
  206. * DIALOG_Delete
  207. */
  208. BOOL DIALOG_Delete(UINT ids_text_s, LPCSTR lpszName)
  209. {
  210. return (IDYES == MAIN_MessageBoxIDS_s(ids_text_s, lpszName, IDS_DELETE,
  211. MB_YESNO | MB_DEFBUTTON2));
  212. }
  213. static struct
  214. {
  215. LPSTR lpszTitle, lpszGrpFile;
  216. INT nSize;
  217. } GroupAttributes;
  218. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  219. *
  220. * DIALOG_GROUP_DlgProc
  221. */
  222. static INT_PTR CALLBACK DIALOG_GROUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  223. {
  224. switch (msg)
  225. {
  226. case WM_INITDIALOG:
  227. SetDlgItemTextA(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle);
  228. SetDlgItemTextA(hDlg, PM_FILE, GroupAttributes.lpszGrpFile);
  229. break;
  230. case WM_COMMAND:
  231. switch (wParam)
  232. {
  233. case IDOK:
  234. GetDlgItemTextA(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle, GroupAttributes.nSize);
  235. GetDlgItemTextA(hDlg, PM_FILE, GroupAttributes.lpszGrpFile, GroupAttributes.nSize);
  236. EndDialog(hDlg, IDOK);
  237. return TRUE;
  238. case IDCANCEL:
  239. EndDialog(hDlg, IDCANCEL);
  240. return TRUE;
  241. }
  242. }
  243. return FALSE;
  244. }
  245. /***********************************************************************
  246. *
  247. * DIALOG_GroupAttributes
  248. */
  249. BOOL DIALOG_GroupAttributes(LPSTR lpszTitle, LPSTR lpszGrpFile, INT nSize)
  250. {
  251. INT ret;
  252. GroupAttributes.nSize = nSize;
  253. GroupAttributes.lpszTitle = lpszTitle;
  254. GroupAttributes.lpszGrpFile = lpszGrpFile;
  255. ret = DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_GROUP), Globals.hMainWnd, DIALOG_GROUP_DlgProc);
  256. return(ret == IDOK);
  257. }
  258. static struct
  259. {
  260. LPSTR lpszIconFile;
  261. INT nSize;
  262. HICON *lphIcon;
  263. INT *lpnIconIndex;
  264. } Symbol;
  265. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  266. *
  267. * DIALOG_SYMBOL_DlgProc
  268. */
  269. static INT_PTR CALLBACK DIALOG_SYMBOL_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  270. {
  271. switch (msg)
  272. {
  273. case WM_INITDIALOG:
  274. SetDlgItemTextA(hDlg, PM_ICON_FILE, Symbol.lpszIconFile);
  275. SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST, CB_SETITEMHEIGHT, 0, (LPARAM) 32);
  276. SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)*Symbol.lphIcon);
  277. SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)Globals.hDefaultIcon);
  278. SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST, CB_SETCURSEL, 0, 0);
  279. return TRUE;
  280. case WM_MEASUREITEM:
  281. {
  282. PMEASUREITEMSTRUCT measure = (PMEASUREITEMSTRUCT) lParam;
  283. measure->itemWidth = 32;
  284. measure->itemHeight = 32;
  285. return TRUE;
  286. }
  287. case WM_DRAWITEM:
  288. {
  289. PDRAWITEMSTRUCT dis = (PDRAWITEMSTRUCT) lParam;
  290. DrawIcon(dis->hDC, dis->rcItem.left, dis->rcItem.top, (HICON)dis->itemData);
  291. return TRUE;
  292. }
  293. case WM_COMMAND:
  294. switch (wParam)
  295. {
  296. case PM_BROWSE:
  297. {
  298. CHAR filename[MAX_PATHNAME_LEN];
  299. filename[0] = 0;
  300. if (DIALOG_BrowseSymbols(hDlg, filename, sizeof(filename)))
  301. SetDlgItemTextA(hDlg, PM_ICON_FILE, filename);
  302. return TRUE;
  303. }
  304. case PM_HELP:
  305. MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
  306. return TRUE;
  307. case IDOK:
  308. {
  309. INT nCurSel = SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST, CB_GETCURSEL, 0, 0);
  310. GetDlgItemTextA(hDlg, PM_ICON_FILE, Symbol.lpszIconFile, Symbol.nSize);
  311. *Symbol.lphIcon = (HICON)SendDlgItemMessageA(hDlg, PM_SYMBOL_LIST,
  312. CB_GETITEMDATA,
  313. (WPARAM) nCurSel, 0);
  314. #if 0
  315. *Symbol.lphIcon = CopyIcon(*Symbol.lphIcon);
  316. #endif
  317. EndDialog(hDlg, IDOK);
  318. return TRUE;
  319. }
  320. case IDCANCEL:
  321. EndDialog(hDlg, IDCANCEL);
  322. return TRUE;
  323. }
  324. }
  325. return FALSE;
  326. }
  327. /***********************************************************************
  328. *
  329. * DIALOG_Symbol
  330. */
  331. static VOID DIALOG_Symbol(HICON *lphIcon, LPSTR lpszIconFile,
  332. INT *lpnIconIndex, INT nSize)
  333. {
  334. Symbol.nSize = nSize;
  335. Symbol.lpszIconFile = lpszIconFile;
  336. Symbol.lphIcon = lphIcon;
  337. Symbol.lpnIconIndex = lpnIconIndex;
  338. DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_SYMBOL), Globals.hMainWnd, DIALOG_SYMBOL_DlgProc);
  339. }
  340. static struct
  341. {
  342. LPSTR lpszTitle, lpszCmdLine, lpszWorkDir, lpszIconFile, lpszTmpIconFile;
  343. INT nSize;
  344. INT *lpnCmdShow;
  345. INT *lpnHotKey;
  346. HWND hSelGroupWnd;
  347. HICON *lphIcon, hTmpIcon;
  348. INT *lpnIconIndex, nTmpIconIndex;
  349. } ProgramAttributes;
  350. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  351. *
  352. * DIALOG_PROGRAM_DlgProc
  353. */
  354. static INT_PTR CALLBACK DIALOG_PROGRAM_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  355. {
  356. CHAR buffer[MAX_STRING_LEN];
  357. switch (msg)
  358. {
  359. case WM_INITDIALOG:
  360. SetDlgItemTextA(hDlg, PM_DESCRIPTION, ProgramAttributes.lpszTitle);
  361. SetDlgItemTextA(hDlg, PM_COMMAND_LINE, ProgramAttributes.lpszCmdLine);
  362. SetDlgItemTextA(hDlg, PM_DIRECTORY, ProgramAttributes.lpszWorkDir);
  363. if (!*ProgramAttributes.lpnHotKey)
  364. {
  365. LoadStringA(Globals.hInstance, IDS_NO_HOT_KEY, buffer, sizeof(buffer));
  366. SetDlgItemTextA(hDlg, PM_HOT_KEY, buffer);
  367. }
  368. CheckDlgButton(hDlg, PM_SYMBOL,
  369. (*ProgramAttributes.lpnCmdShow == SW_SHOWMINIMIZED));
  370. SendDlgItemMessageA(hDlg, PM_ICON, STM_SETICON, (WPARAM)ProgramAttributes.hTmpIcon, 0);
  371. break;
  372. case WM_COMMAND:
  373. switch (wParam)
  374. {
  375. case PM_SYMBOL:
  376. CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
  377. return TRUE;
  378. case PM_BROWSE:
  379. {
  380. CHAR filename[MAX_PATHNAME_LEN];
  381. filename[0] = 0;
  382. if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
  383. SetDlgItemTextA(hDlg, PM_COMMAND_LINE, filename);
  384. return TRUE;
  385. }
  386. case PM_OTHER_SYMBOL:
  387. {
  388. DIALOG_Symbol(&ProgramAttributes.hTmpIcon,
  389. ProgramAttributes.lpszTmpIconFile,
  390. &ProgramAttributes.nTmpIconIndex,
  391. MAX_PATHNAME_LEN);
  392. SendDlgItemMessageA(hDlg, PM_ICON, STM_SETICON, (WPARAM)ProgramAttributes.hTmpIcon, 0);
  393. return TRUE;
  394. }
  395. case IDOK:
  396. GetDlgItemTextA(hDlg, PM_DESCRIPTION,
  397. ProgramAttributes.lpszTitle,
  398. ProgramAttributes.nSize);
  399. GetDlgItemTextA(hDlg, PM_COMMAND_LINE,
  400. ProgramAttributes.lpszCmdLine,
  401. ProgramAttributes.nSize);
  402. GetDlgItemTextA(hDlg, PM_DIRECTORY,
  403. ProgramAttributes.lpszWorkDir,
  404. ProgramAttributes.nSize);
  405. if (ProgramAttributes.hTmpIcon)
  406. {
  407. #if 0
  408. if (*ProgramAttributes.lphIcon)
  409. DestroyIcon(*ProgramAttributes.lphIcon);
  410. #endif
  411. *ProgramAttributes.lphIcon = ProgramAttributes.hTmpIcon;
  412. *ProgramAttributes.lpnIconIndex = ProgramAttributes.nTmpIconIndex;
  413. lstrcpynA(ProgramAttributes.lpszIconFile,
  414. ProgramAttributes.lpszTmpIconFile,
  415. ProgramAttributes.nSize);
  416. }
  417. *ProgramAttributes.lpnCmdShow =
  418. IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
  419. SW_SHOWMINIMIZED : SW_SHOWNORMAL;
  420. EndDialog(hDlg, IDOK);
  421. return TRUE;
  422. case IDCANCEL:
  423. EndDialog(hDlg, IDCANCEL);
  424. return TRUE;
  425. }
  426. return FALSE;
  427. }
  428. return FALSE;
  429. }
  430. /***********************************************************************
  431. *
  432. * DIALOG_ProgramAttributes
  433. */
  434. BOOL DIALOG_ProgramAttributes(LPSTR lpszTitle, LPSTR lpszCmdLine,
  435. LPSTR lpszWorkDir, LPSTR lpszIconFile,
  436. HICON *lphIcon, INT *lpnIconIndex,
  437. INT *lpnHotKey, INT *lpnCmdShow, INT nSize)
  438. {
  439. CHAR szTmpIconFile[MAX_PATHNAME_LEN];
  440. INT ret;
  441. ProgramAttributes.nSize = nSize;
  442. ProgramAttributes.lpszTitle = lpszTitle;
  443. ProgramAttributes.lpszCmdLine = lpszCmdLine;
  444. ProgramAttributes.lpszWorkDir = lpszWorkDir;
  445. ProgramAttributes.lpszIconFile = lpszIconFile;
  446. ProgramAttributes.lpnCmdShow = lpnCmdShow;
  447. ProgramAttributes.lpnHotKey = lpnHotKey;
  448. ProgramAttributes.lphIcon = lphIcon;
  449. ProgramAttributes.lpnIconIndex = lpnIconIndex;
  450. #if 0
  451. ProgramAttributes.hTmpIcon = 0;
  452. #else
  453. ProgramAttributes.hTmpIcon = *lphIcon;
  454. #endif
  455. ProgramAttributes.nTmpIconIndex = *lpnIconIndex;
  456. ProgramAttributes.lpszTmpIconFile = szTmpIconFile;
  457. lstrcpynA(ProgramAttributes.lpszTmpIconFile, lpszIconFile, MAX_PATHNAME_LEN);
  458. ret = DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_PROGRAM), Globals.hMainWnd, DIALOG_PROGRAM_DlgProc);
  459. return(ret == IDOK);
  460. }
  461. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  462. *
  463. * DIALOG_EXECUTE_DlgProc
  464. */
  465. static INT_PTR CALLBACK DIALOG_EXECUTE_DlgProc(HWND hDlg, UINT msg,
  466. WPARAM wParam, LPARAM lParam)
  467. {
  468. switch (msg)
  469. {
  470. case WM_COMMAND:
  471. switch (wParam)
  472. {
  473. case PM_SYMBOL:
  474. CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
  475. return TRUE;
  476. case PM_BROWSE:
  477. {
  478. CHAR filename[MAX_PATHNAME_LEN];
  479. filename[0] = 0;
  480. if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
  481. SetDlgItemTextA(hDlg, PM_COMMAND, filename);
  482. return TRUE;
  483. }
  484. case PM_HELP:
  485. MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
  486. return TRUE;
  487. case IDOK:
  488. {
  489. CHAR cmdline[MAX_PATHNAME_LEN];
  490. GetDlgItemTextA(hDlg, PM_COMMAND, cmdline, sizeof(cmdline));
  491. WinExec(cmdline, IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
  492. SW_SHOWMINIMIZED : SW_SHOWNORMAL);
  493. if (Globals.bMinOnRun) CloseWindow(Globals.hMainWnd);
  494. EndDialog(hDlg, IDOK);
  495. return TRUE;
  496. }
  497. case IDCANCEL:
  498. EndDialog(hDlg, IDCANCEL);
  499. return TRUE;
  500. }
  501. }
  502. return FALSE;
  503. }
  504. /***********************************************************************
  505. *
  506. * DIALOG_Execute
  507. */
  508. VOID DIALOG_Execute(void)
  509. {
  510. DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_EXECUTE), Globals.hMainWnd, DIALOG_EXECUTE_DlgProc);
  511. }