4 * Copyright 1996 Ulrich Schmid
5 * Copyright 2002 Sylvain Petreolle
6 * Copyright 2002 Andriy Palamarchuk
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 static BOOL DIALOG_BrowsePrograms(HWND, LPSTR, INT);
27 static BOOL DIALOG_BrowseSymbols(HWND, LPSTR, INT);
28 static BOOL CALLBACK DIALOG_NEW_DlgProc(HWND, UINT, WPARAM, LPARAM);
29 static BOOL CALLBACK DIALOG_COPY_MOVE_DlgProc(HWND, UINT, WPARAM, LPARAM);
30 static BOOL CALLBACK DIALOG_GROUP_DlgProc(HWND, UINT, WPARAM, LPARAM);
31 static BOOL CALLBACK DIALOG_PROGRAM_DlgProc(HWND, UINT, WPARAM, LPARAM);
32 static BOOL CALLBACK DIALOG_SYMBOL_DlgProc(HWND, UINT, WPARAM, LPARAM);
33 static BOOL CALLBACK DIALOG_EXECUTE_DlgProc(HWND, UINT, WPARAM, LPARAM);
35 /***********************************************************************
45 INT DIALOG_New(INT nDefault)
47 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_NEW_DlgProc, Globals.hInstance);
50 New.nDefault = nDefault;
52 ret = DialogBox(Globals.hInstance, STRING_NEW,
53 Globals.hMainWnd, lpfnDlg);
54 FreeProcInstance(lpfnDlg);
58 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
63 static BOOL CALLBACK DIALOG_NEW_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
68 CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, New.nDefault);
76 CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, wParam);
80 EndDialog(hDlg, IsDlgButtonChecked(hDlg, PM_NEW_GROUP) ?
81 PM_NEW_GROUP : PM_NEW_PROGRAM);
85 EndDialog(hDlg, IDCANCEL);
92 /***********************************************************************
99 LPCSTR lpszProgramName, lpszFromGroupName;
103 HLOCAL DIALOG_CopyMove(LPCSTR lpszProgramName, LPCSTR lpszFromGroupName,
106 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_COPY_MOVE_DlgProc, Globals.hInstance);
109 CopyMove.lpszProgramName = lpszProgramName;
110 CopyMove.lpszFromGroupName = lpszFromGroupName;
111 CopyMove.hToGroup = 0;
113 ret = DialogBox(Globals.hInstance,
114 bMove ? STRING_MOVE : STRING_COPY,
115 Globals.hMainWnd, lpfnDlg);
116 FreeProcInstance(lpfnDlg);
118 return((ret == IDOK) ? CopyMove.hToGroup : 0);
121 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
123 * DIALOG_COPY_MOVE_DlgProc
126 static BOOL CALLBACK DIALOG_COPY_MOVE_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
133 /* List all group names */
134 for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
135 SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_ADDSTRING, 0,
136 (LPARAM) GROUP_GroupName(hGroup));
138 SetDlgItemText(hDlg, PM_PROGRAM, CopyMove.lpszProgramName);
139 SetDlgItemText(hDlg, PM_FROM_GROUP, CopyMove.lpszFromGroupName);
147 /* Get selected group */
148 INT nCurSel = SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETCURSEL, 0, 0);
149 INT nLen = SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETLBTEXTLEN, nCurSel, 0);
150 HLOCAL hBuffer = LocalAlloc(LMEM_FIXED, nLen + 1);
151 LPSTR buffer = LocalLock(hBuffer);
153 SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETLBTEXT, nCurSel, (LPARAM)buffer);
154 for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
155 if (!lstrcmp(buffer, GROUP_GroupName(hGroup))) break;
158 CopyMove.hToGroup = hGroup;
159 EndDialog(hDlg, IDOK);
164 EndDialog(hDlg, IDCANCEL);
171 /***********************************************************************
176 BOOL DIALOG_Delete(UINT ids_text_s, LPCSTR lpszName)
178 return (IDYES == MAIN_MessageBoxIDS_s(ids_text_s, lpszName, IDS_DELETE,
179 MB_YESNO | MB_DEFBUTTON2));
183 /***********************************************************************
185 * DIALOG_GroupAttributes
190 LPSTR lpszTitle, lpszGrpFile;
194 BOOL DIALOG_GroupAttributes(LPSTR lpszTitle, LPSTR lpszGrpFile, INT nSize)
196 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_GROUP_DlgProc, Globals.hInstance);
199 GroupAttributes.nSize = nSize;
200 GroupAttributes.lpszTitle = lpszTitle;
201 GroupAttributes.lpszGrpFile = lpszGrpFile;
203 ret = DialogBox(Globals.hInstance, STRING_GROUP,
204 Globals.hMainWnd, lpfnDlg);
205 FreeProcInstance(lpfnDlg);
209 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
211 * DIALOG_GROUP_DlgProc
214 static BOOL CALLBACK DIALOG_GROUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
219 SetDlgItemText(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle);
220 SetDlgItemText(hDlg, PM_FILE, GroupAttributes.lpszGrpFile);
227 GetDlgItemText(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle,
228 GroupAttributes.nSize);
229 GetDlgItemText(hDlg, PM_FILE, GroupAttributes.lpszGrpFile,
230 GroupAttributes.nSize);
231 EndDialog(hDlg, IDOK);
235 EndDialog(hDlg, IDCANCEL);
242 /***********************************************************************
244 * DIALOG_ProgramAttributes
249 LPSTR lpszTitle, lpszCmdLine, lpszWorkDir, lpszIconFile, lpszTmpIconFile;
254 HICON *lphIcon, hTmpIcon;
255 INT *lpnIconIndex, nTmpIconIndex;
258 BOOL DIALOG_ProgramAttributes(LPSTR lpszTitle, LPSTR lpszCmdLine,
259 LPSTR lpszWorkDir, LPSTR lpszIconFile,
260 HICON *lphIcon, INT *lpnIconIndex,
261 INT *lpnHotKey, INT *lpnCmdShow, INT nSize)
263 CHAR szTmpIconFile[MAX_PATHNAME_LEN];
264 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_PROGRAM_DlgProc, Globals.hInstance);
267 ProgramAttributes.nSize = nSize;
268 ProgramAttributes.lpszTitle = lpszTitle;
269 ProgramAttributes.lpszCmdLine = lpszCmdLine;
270 ProgramAttributes.lpszWorkDir = lpszWorkDir;
271 ProgramAttributes.lpszIconFile = lpszIconFile;
272 ProgramAttributes.lpnCmdShow = lpnCmdShow;
273 ProgramAttributes.lpnHotKey = lpnHotKey;
274 ProgramAttributes.lphIcon = lphIcon;
275 ProgramAttributes.lpnIconIndex = lpnIconIndex;
278 ProgramAttributes.hTmpIcon = 0;
280 ProgramAttributes.hTmpIcon = *lphIcon;
282 ProgramAttributes.nTmpIconIndex = *lpnIconIndex;
283 ProgramAttributes.lpszTmpIconFile = szTmpIconFile;
284 lstrcpyn(ProgramAttributes.lpszTmpIconFile, lpszIconFile, MAX_PATHNAME_LEN);
286 ret = DialogBox(Globals.hInstance, STRING_PROGRAM,
287 Globals.hMainWnd, lpfnDlg);
288 FreeProcInstance(lpfnDlg);
293 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
295 * DIALOG_PROGRAM_DlgProc
298 static BOOL CALLBACK DIALOG_PROGRAM_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
300 CHAR buffer[MAX_STRING_LEN];
304 SetDlgItemText(hDlg, PM_DESCRIPTION, ProgramAttributes.lpszTitle);
305 SetDlgItemText(hDlg, PM_COMMAND_LINE, ProgramAttributes.lpszCmdLine);
306 SetDlgItemText(hDlg, PM_DIRECTORY, ProgramAttributes.lpszWorkDir);
307 if (!*ProgramAttributes.lpnHotKey)
309 LoadString(Globals.hInstance, IDS_NO_HOT_KEY, buffer, sizeof(buffer));
310 SetDlgItemText(hDlg, PM_HOT_KEY, buffer);
313 CheckDlgButton(hDlg, PM_SYMBOL,
314 (*ProgramAttributes.lpnCmdShow == SW_SHOWMINIMIZED));
315 SendDlgItemMessage(hDlg, PM_ICON, STM_SETICON,
316 (WPARAM) ProgramAttributes.hTmpIcon, 0);
323 CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
328 CHAR filename[MAX_PATHNAME_LEN];
329 if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
330 SetDlgItemText(hDlg, PM_COMMAND_LINE, filename);
334 case PM_OTHER_SYMBOL:
336 DIALOG_Symbol(&ProgramAttributes.hTmpIcon,
337 ProgramAttributes.lpszTmpIconFile,
338 &ProgramAttributes.nTmpIconIndex,
341 SendDlgItemMessage(hDlg, PM_ICON, STM_SETICON,
342 (WPARAM) ProgramAttributes.hTmpIcon, 0);
347 GetDlgItemText(hDlg, PM_DESCRIPTION,
348 ProgramAttributes.lpszTitle,
349 ProgramAttributes.nSize);
350 GetDlgItemText(hDlg, PM_COMMAND_LINE,
351 ProgramAttributes.lpszCmdLine,
352 ProgramAttributes.nSize);
353 GetDlgItemText(hDlg, PM_DIRECTORY,
354 ProgramAttributes.lpszWorkDir,
355 ProgramAttributes.nSize);
357 if (ProgramAttributes.hTmpIcon)
360 if (*ProgramAttributes.lphIcon)
361 DestroyIcon(*ProgramAttributes.lphIcon);
363 *ProgramAttributes.lphIcon = ProgramAttributes.hTmpIcon;
364 *ProgramAttributes.lpnIconIndex = ProgramAttributes.nTmpIconIndex;
365 lstrcpyn(ProgramAttributes.lpszIconFile,
366 ProgramAttributes.lpszTmpIconFile,
367 ProgramAttributes.nSize);
370 *ProgramAttributes.lpnCmdShow =
371 IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
372 SW_SHOWMINIMIZED : SW_SHOWNORMAL;
373 EndDialog(hDlg, IDOK);
377 EndDialog(hDlg, IDCANCEL);
385 /***********************************************************************
398 VOID DIALOG_Symbol(HICON *lphIcon, LPSTR lpszIconFile,
399 INT *lpnIconIndex, INT nSize)
401 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_SYMBOL_DlgProc, Globals.hInstance);
403 Symbol.nSize = nSize;
404 Symbol.lpszIconFile = lpszIconFile;
405 Symbol.lphIcon = lphIcon;
406 Symbol.lpnIconIndex = lpnIconIndex;
408 DialogBox(Globals.hInstance, STRING_SYMBOL,
409 Globals.hMainWnd, lpfnDlg);
410 FreeProcInstance(lpfnDlg);
413 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
415 * DIALOG_SYMBOL_DlgProc
418 static BOOL CALLBACK DIALOG_SYMBOL_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
423 SetDlgItemText(hDlg, PM_ICON_FILE, Symbol.lpszIconFile);
424 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_SETITEMHEIGHT, 0, (LPARAM) 32);
425 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)*Symbol.lphIcon);
426 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)Globals.hDefaultIcon);
427 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_SETCURSEL, 0, 0);
432 PMEASUREITEMSTRUCT measure = (PMEASUREITEMSTRUCT) lParam;
433 measure->itemWidth = 32;
434 measure->itemHeight = 32;
440 PDRAWITEMSTRUCT dis = (PDRAWITEMSTRUCT) lParam;
441 DrawIcon(dis->hDC, dis->rcItem.left, dis->rcItem.top, (HICON)dis->itemData);
450 CHAR filename[MAX_PATHNAME_LEN];
451 if (DIALOG_BrowseSymbols(hDlg, filename, sizeof(filename)))
452 SetDlgItemText(hDlg, PM_ICON_FILE, filename);
457 MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
462 INT nCurSel = SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_GETCURSEL, 0, 0);
464 GetDlgItemText(hDlg, PM_ICON_FILE, Symbol.lpszIconFile, Symbol.nSize);
466 *Symbol.lphIcon = (HICON)SendDlgItemMessage(hDlg, PM_SYMBOL_LIST,
468 (WPARAM) nCurSel, 0);
470 *Symbol.lphIcon = CopyIcon(*Symbol.lphIcon);
473 EndDialog(hDlg, IDOK);
478 EndDialog(hDlg, IDCANCEL);
485 /***********************************************************************
490 VOID DIALOG_Execute()
493 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_EXECUTE_DlgProc, Globals.hInstance);
494 z=DialogBox(Globals.hInstance, STRING_EXECUTE,
495 Globals.hMainWnd, lpfnDlg);
496 FreeProcInstance(lpfnDlg);
499 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
501 * DIALOG_EXECUTE_DlgProc
504 static BOOL CALLBACK DIALOG_EXECUTE_DlgProc(HWND hDlg, UINT msg,
505 WPARAM wParam, LPARAM lParam)
513 CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
518 CHAR filename[MAX_PATHNAME_LEN];
519 if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
520 SetDlgItemText(hDlg, PM_COMMAND, filename);
525 MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
530 CHAR cmdline[MAX_PATHNAME_LEN];
531 GetDlgItemText(hDlg, PM_COMMAND, cmdline, sizeof(cmdline));
533 WinExec(cmdline, IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
534 SW_SHOWMINIMIZED : SW_SHOWNORMAL);
535 if (Globals.bMinOnRun) CloseWindow(Globals.hMainWnd);
537 EndDialog(hDlg, IDOK);
542 EndDialog(hDlg, IDCANCEL);
549 /***********************************************************************
554 static BOOL DIALOG_Browse(HWND hDlg, LPCSTR lpszzFilter,
555 LPSTR lpstrFile, INT nMaxFile)
558 OPENFILENAME openfilename;
560 CHAR szPath[MAX_PATH];
561 CHAR szDir[MAX_PATH];
562 CHAR szDefaultExt[] = "exe";
564 ZeroMemory(&openfilename, sizeof(openfilename));
566 GetCurrentDirectory(sizeof(szDir), szDir);
567 lstrcpy(szPath,"*.exe");
569 /* FIXME is this correct ? */
570 openfilename.lStructSize = sizeof(openfilename);
571 openfilename.hwndOwner = Globals.hMainWnd;
572 openfilename.hInstance = Globals.hInstance;
573 openfilename.lpstrFile = szPath;
574 openfilename.nMaxFile = sizeof(szPath);
575 openfilename.lpstrInitialDir = szDir;
576 openfilename.Flags = 0;
577 openfilename.lpstrDefExt = szDefaultExt;
578 openfilename.lpstrCustomFilter = 0;
579 openfilename.nMaxCustFilter = 0;
580 openfilename.nFilterIndex = 0;
581 openfilename.lpstrFileTitle = 0;
582 openfilename.nMaxFileTitle = 0;
583 openfilename.lpstrInitialDir = 0;
584 openfilename.lpstrTitle = 0;
585 openfilename.nFileOffset = 0;
586 openfilename.nFileExtension = 0;
587 openfilename.lCustData = 0;
588 openfilename.lpfnHook = 0;
589 openfilename.lpTemplateName = 0;
591 return GetOpenFileName(&openfilename);
595 /***********************************************************************
597 * DIALOG_AddFilterItem
600 static VOID DIALOG_AddFilterItem(LPSTR *p, UINT ids, LPCSTR filter)
602 LoadString(Globals.hInstance, ids, *p, MAX_STRING_LEN);
603 *p += strlen(*p) + 1;
605 *p += strlen(*p) + 1;
609 /***********************************************************************
611 * DIALOG_BrowsePrograms
614 static BOOL DIALOG_BrowsePrograms(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
616 CHAR szzFilter[2 * MAX_STRING_LEN + 100];
619 DIALOG_AddFilterItem(&p, IDS_PROGRAMS, "*.exe;*.pif;*.com;*.bat");
620 DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");
622 return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
625 /***********************************************************************
627 * DIALOG_BrowseSymbols
630 static BOOL DIALOG_BrowseSymbols(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
632 CHAR szzFilter[5 * MAX_STRING_LEN + 100];
635 DIALOG_AddFilterItem(&p, IDS_SYMBOL_FILES, "*.ico;*.exe;*.dll");
636 DIALOG_AddFilterItem(&p, IDS_PROGRAMS, "*.exe");
637 DIALOG_AddFilterItem(&p, IDS_LIBRARIES_DLL, "*.dll");
638 DIALOG_AddFilterItem(&p, IDS_SYMBOLS_ICO, "*.ico");
639 DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");
641 return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
644 /* Local Variables: */
645 /* c-file-style: "GNU" */