4 * Copyright 1996 Ulrich Schmid
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 static BOOL DIALOG_BrowsePrograms(HWND, LPSTR, INT);
25 static BOOL DIALOG_BrowseSymbols(HWND, LPSTR, INT);
26 static BOOL CALLBACK DIALOG_NEW_DlgProc(HWND, UINT, WPARAM, LPARAM);
27 static BOOL CALLBACK DIALOG_COPY_MOVE_DlgProc(HWND, UINT, WPARAM, LPARAM);
28 static BOOL CALLBACK DIALOG_GROUP_DlgProc(HWND, UINT, WPARAM, LPARAM);
29 static BOOL CALLBACK DIALOG_PROGRAM_DlgProc(HWND, UINT, WPARAM, LPARAM);
30 static BOOL CALLBACK DIALOG_SYMBOL_DlgProc(HWND, UINT, WPARAM, LPARAM);
31 static BOOL CALLBACK DIALOG_EXECUTE_DlgProc(HWND, UINT, WPARAM, LPARAM);
33 /***********************************************************************
43 INT DIALOG_New(INT nDefault)
45 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_NEW_DlgProc, Globals.hInstance);
48 New.nDefault = nDefault;
50 ret = DialogBox(Globals.hInstance, STRING_NEW_Xx,
51 Globals.hMainWnd, lpfnDlg);
52 FreeProcInstance(lpfnDlg);
56 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
61 static BOOL CALLBACK DIALOG_NEW_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
66 CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, New.nDefault);
74 CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, wParam);
78 EndDialog(hDlg, IsDlgButtonChecked(hDlg, PM_NEW_GROUP) ?
79 PM_NEW_GROUP : PM_NEW_PROGRAM);
83 EndDialog(hDlg, IDCANCEL);
90 /***********************************************************************
97 LPCSTR lpszProgramName, lpszFromGroupName;
101 HLOCAL DIALOG_CopyMove(LPCSTR lpszProgramName, LPCSTR lpszFromGroupName,
104 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_COPY_MOVE_DlgProc, Globals.hInstance);
107 CopyMove.lpszProgramName = lpszProgramName;
108 CopyMove.lpszFromGroupName = lpszFromGroupName;
109 CopyMove.hToGroup = 0;
111 ret = DialogBox(Globals.hInstance,
112 bMove ? STRING_MOVE_Xx : STRING_COPY_Xx,
113 Globals.hMainWnd, lpfnDlg);
114 FreeProcInstance(lpfnDlg);
116 return((ret == IDOK) ? CopyMove.hToGroup : 0);
119 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
121 * DIALOG_COPY_MOVE_DlgProc
124 static BOOL CALLBACK DIALOG_COPY_MOVE_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
131 /* List all group names */
132 for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
133 SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_ADDSTRING, 0,
134 (LPARAM) GROUP_GroupName(hGroup));
136 SetDlgItemText(hDlg, PM_PROGRAM, (LPSTR)CopyMove.lpszProgramName);
137 SetDlgItemText(hDlg, PM_FROM_GROUP, (LPSTR)CopyMove.lpszFromGroupName);
145 /* Get selected group */
146 INT nCurSel = SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETCURSEL, 0, 0);
147 INT nLen = SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETLBTEXTLEN, nCurSel, 0);
148 HLOCAL hBuffer = LocalAlloc(LMEM_FIXED, nLen + 1);
149 LPSTR buffer = LocalLock(hBuffer);
151 SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETLBTEXT, nCurSel, (LPARAM)buffer);
152 for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
153 if (!lstrcmp(buffer, GROUP_GroupName(hGroup))) break;
156 CopyMove.hToGroup = hGroup;
157 EndDialog(hDlg, IDOK);
162 EndDialog(hDlg, IDCANCEL);
169 /***********************************************************************
174 BOOL DIALOG_Delete(UINT ids_text_s, LPCSTR lpszName)
176 return (IDYES == MAIN_MessageBoxIDS_s(ids_text_s, lpszName, IDS_DELETE,
177 MB_YESNO | MB_DEFBUTTON2));
181 /***********************************************************************
183 * DIALOG_GroupAttributes
188 LPSTR lpszTitle, lpszGrpFile;
192 BOOL DIALOG_GroupAttributes(LPSTR lpszTitle, LPSTR lpszGrpFile, INT nSize)
194 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_GROUP_DlgProc, Globals.hInstance);
197 GroupAttributes.nSize = nSize;
198 GroupAttributes.lpszTitle = lpszTitle;
199 GroupAttributes.lpszGrpFile = lpszGrpFile;
201 ret = DialogBox(Globals.hInstance, STRING_GROUP_Xx,
202 Globals.hMainWnd, lpfnDlg);
203 FreeProcInstance(lpfnDlg);
207 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
209 * DIALOG_GROUP_DlgProc
212 static BOOL CALLBACK DIALOG_GROUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
217 SetDlgItemText(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle);
218 SetDlgItemText(hDlg, PM_FILE, GroupAttributes.lpszGrpFile);
225 GetDlgItemText(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle,
226 GroupAttributes.nSize);
227 GetDlgItemText(hDlg, PM_FILE, GroupAttributes.lpszGrpFile,
228 GroupAttributes.nSize);
229 EndDialog(hDlg, IDOK);
233 EndDialog(hDlg, IDCANCEL);
240 /***********************************************************************
242 * DIALOG_ProgramAttributes
247 LPSTR lpszTitle, lpszCmdLine, lpszWorkDir, lpszIconFile, lpszTmpIconFile;
252 HICON *lphIcon, hTmpIcon;
253 INT *lpnIconIndex, nTmpIconIndex;
256 BOOL DIALOG_ProgramAttributes(LPSTR lpszTitle, LPSTR lpszCmdLine,
257 LPSTR lpszWorkDir, LPSTR lpszIconFile,
258 HICON *lphIcon, INT *lpnIconIndex,
259 INT *lpnHotKey, INT *lpnCmdShow, INT nSize)
261 CHAR szTmpIconFile[MAX_PATHNAME_LEN];
262 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_PROGRAM_DlgProc, Globals.hInstance);
265 ProgramAttributes.nSize = nSize;
266 ProgramAttributes.lpszTitle = lpszTitle;
267 ProgramAttributes.lpszCmdLine = lpszCmdLine;
268 ProgramAttributes.lpszWorkDir = lpszWorkDir;
269 ProgramAttributes.lpszIconFile = lpszIconFile;
270 ProgramAttributes.lpnCmdShow = lpnCmdShow;
271 ProgramAttributes.lpnHotKey = lpnHotKey;
272 ProgramAttributes.lphIcon = lphIcon;
273 ProgramAttributes.lpnIconIndex = lpnIconIndex;
276 ProgramAttributes.hTmpIcon = 0;
278 ProgramAttributes.hTmpIcon = *lphIcon;
280 ProgramAttributes.nTmpIconIndex = *lpnIconIndex;
281 ProgramAttributes.lpszTmpIconFile = szTmpIconFile;
282 lstrcpyn(ProgramAttributes.lpszTmpIconFile, lpszIconFile, MAX_PATHNAME_LEN);
284 ret = DialogBox(Globals.hInstance, STRING_PROGRAM_Xx,
285 Globals.hMainWnd, lpfnDlg);
286 FreeProcInstance(lpfnDlg);
291 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
293 * DIALOG_PROGRAM_DlgProc
296 static BOOL CALLBACK DIALOG_PROGRAM_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
298 CHAR buffer[MAX_STRING_LEN];
302 SetDlgItemText(hDlg, PM_DESCRIPTION, ProgramAttributes.lpszTitle);
303 SetDlgItemText(hDlg, PM_COMMAND_LINE, ProgramAttributes.lpszCmdLine);
304 SetDlgItemText(hDlg, PM_DIRECTORY, ProgramAttributes.lpszWorkDir);
305 if (!*ProgramAttributes.lpnHotKey)
307 LoadString(Globals.hInstance, IDS_NO_HOT_KEY, buffer, sizeof(buffer));
308 SetDlgItemText(hDlg, PM_HOT_KEY, buffer);
311 CheckDlgButton(hDlg, PM_SYMBOL,
312 (*ProgramAttributes.lpnCmdShow == SW_SHOWMINIMIZED));
313 SendDlgItemMessage(hDlg, PM_ICON, STM_SETICON,
314 (WPARAM) ProgramAttributes.hTmpIcon, 0);
321 CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
326 CHAR filename[MAX_PATHNAME_LEN];
327 if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
328 SetDlgItemText(hDlg, PM_COMMAND_LINE, filename);
332 case PM_OTHER_SYMBOL:
334 DIALOG_Symbol(&ProgramAttributes.hTmpIcon,
335 ProgramAttributes.lpszTmpIconFile,
336 &ProgramAttributes.nTmpIconIndex,
339 SendDlgItemMessage(hDlg, PM_ICON, STM_SETICON,
340 (WPARAM) ProgramAttributes.hTmpIcon, 0);
345 GetDlgItemText(hDlg, PM_DESCRIPTION,
346 ProgramAttributes.lpszTitle,
347 ProgramAttributes.nSize);
348 GetDlgItemText(hDlg, PM_COMMAND_LINE,
349 ProgramAttributes.lpszCmdLine,
350 ProgramAttributes.nSize);
351 GetDlgItemText(hDlg, PM_DIRECTORY,
352 ProgramAttributes.lpszWorkDir,
353 ProgramAttributes.nSize);
355 if (ProgramAttributes.hTmpIcon)
358 if (*ProgramAttributes.lphIcon)
359 DestroyIcon(*ProgramAttributes.lphIcon);
361 *ProgramAttributes.lphIcon = ProgramAttributes.hTmpIcon;
362 *ProgramAttributes.lpnIconIndex = ProgramAttributes.nTmpIconIndex;
363 lstrcpyn(ProgramAttributes.lpszIconFile,
364 ProgramAttributes.lpszTmpIconFile,
365 ProgramAttributes.nSize);
368 *ProgramAttributes.lpnCmdShow =
369 IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
370 SW_SHOWMINIMIZED : SW_SHOWNORMAL;
371 EndDialog(hDlg, IDOK);
375 EndDialog(hDlg, IDCANCEL);
383 /***********************************************************************
396 VOID DIALOG_Symbol(HICON *lphIcon, LPSTR lpszIconFile,
397 INT *lpnIconIndex, INT nSize)
399 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_SYMBOL_DlgProc, Globals.hInstance);
401 Symbol.nSize = nSize;
402 Symbol.lpszIconFile = lpszIconFile;
403 Symbol.lphIcon = lphIcon;
404 Symbol.lpnIconIndex = lpnIconIndex;
406 DialogBox(Globals.hInstance, STRING_SYMBOL_Xx,
407 Globals.hMainWnd, lpfnDlg);
408 FreeProcInstance(lpfnDlg);
411 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
413 * DIALOG_SYMBOL_DlgProc
416 static BOOL CALLBACK DIALOG_SYMBOL_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
421 SetDlgItemText(hDlg, PM_ICON_FILE, Symbol.lpszIconFile);
422 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_SETITEMHEIGHT, 0, (LPARAM) 32);
423 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)*Symbol.lphIcon);
424 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)Globals.hDefaultIcon);
425 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_SETCURSEL, 0, 0);
430 PMEASUREITEMSTRUCT measure = (PMEASUREITEMSTRUCT) lParam;
431 measure->itemWidth = 32;
432 measure->itemHeight = 32;
438 PDRAWITEMSTRUCT dis = (PDRAWITEMSTRUCT) lParam;
439 DrawIcon(dis->hDC, dis->rcItem.left, dis->rcItem.top, (HICON)dis->itemData);
448 CHAR filename[MAX_PATHNAME_LEN];
449 if (DIALOG_BrowseSymbols(hDlg, filename, sizeof(filename)))
450 SetDlgItemText(hDlg, PM_ICON_FILE, filename);
455 MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
460 INT nCurSel = SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_GETCURSEL, 0, 0);
462 GetDlgItemText(hDlg, PM_ICON_FILE, Symbol.lpszIconFile, Symbol.nSize);
464 *Symbol.lphIcon = (HICON)SendDlgItemMessage(hDlg, PM_SYMBOL_LIST,
466 (WPARAM) nCurSel, 0);
468 *Symbol.lphIcon = CopyIcon(*Symbol.lphIcon);
471 EndDialog(hDlg, IDOK);
476 EndDialog(hDlg, IDCANCEL);
483 /***********************************************************************
488 VOID DIALOG_Execute()
490 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_EXECUTE_DlgProc, Globals.hInstance);
491 DialogBox(Globals.hInstance, STRING_EXECUTE_Xx,
492 Globals.hMainWnd, lpfnDlg);
493 FreeProcInstance(lpfnDlg);
496 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
498 * DIALOG_EXECUTE_DlgProc
501 static BOOL CALLBACK DIALOG_EXECUTE_DlgProc(HWND hDlg, UINT msg,
502 WPARAM wParam, LPARAM lParam)
510 CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
515 CHAR filename[MAX_PATHNAME_LEN];
516 if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
517 SetDlgItemText(hDlg, PM_COMMAND, filename);
522 MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
527 CHAR cmdline[MAX_PATHNAME_LEN];
528 GetDlgItemText(hDlg, PM_COMMAND, cmdline, sizeof(cmdline));
530 WinExec(cmdline, IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
531 SW_SHOWMINIMIZED : SW_SHOWNORMAL);
532 if (Globals.bMinOnRun) CloseWindow(Globals.hMainWnd);
534 EndDialog(hDlg, IDOK);
539 EndDialog(hDlg, IDCANCEL);
546 /***********************************************************************
551 static BOOL DIALOG_Browse(HWND hDlg, LPCSTR lpszzFilter,
552 LPSTR lpstrFile, INT nMaxFile)
554 OPENFILENAME openfilename;
556 /* FIXME is this correct ? */
557 openfilename.lStructSize = 0;
558 openfilename.hwndOwner = hDlg;
559 openfilename.hInstance = Globals.hInstance;
560 openfilename.lpstrFilter = (LPSTR)lpszzFilter;
561 openfilename.lpstrCustomFilter = 0;
562 openfilename.nMaxCustFilter = 0;
563 openfilename.nFilterIndex = 0;
564 openfilename.lpstrFile = lpstrFile;
565 openfilename.nMaxFile = nMaxFile;
566 openfilename.lpstrFileTitle = 0;
567 openfilename.nMaxFileTitle = 0;
568 openfilename.lpstrInitialDir = 0;
569 openfilename.lpstrTitle = 0;
570 openfilename.Flags = 0;
571 openfilename.nFileOffset = 0;
572 openfilename.nFileExtension = 0;
573 openfilename.lpstrDefExt = 0;
574 openfilename.lCustData = 0;
575 openfilename.lpfnHook = 0;
576 openfilename.lpTemplateName = 0;
577 return GetOpenFileName(&openfilename);
580 /***********************************************************************
582 * DIALOG_AddFilterItem
585 static VOID DIALOG_AddFilterItem(LPSTR *p, UINT ids, LPCSTR filter)
587 LoadString(Globals.hInstance, ids, *p, MAX_STRING_LEN);
588 *p += strlen(*p) + 1;
590 *p += strlen(*p) + 1;
594 /***********************************************************************
596 * DIALOG_BrowsePrograms
599 static BOOL DIALOG_BrowsePrograms(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
601 CHAR szzFilter[2 * MAX_STRING_LEN + 100];
604 DIALOG_AddFilterItem(&p, IDS_PROGRAMS, "*.exe;*.pif;*.com;*.bat");
605 DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");
607 return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
610 /***********************************************************************
612 * DIALOG_BrowseSymbols
615 static BOOL DIALOG_BrowseSymbols(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
617 CHAR szzFilter[5 * MAX_STRING_LEN + 100];
620 DIALOG_AddFilterItem(&p, IDS_SYMBOL_FILES, "*.ico;*.exe;*.dll");
621 DIALOG_AddFilterItem(&p, IDS_PROGRAMS, "*.exe");
622 DIALOG_AddFilterItem(&p, IDS_LIBRARIES_DLL, "*.dll");
623 DIALOG_AddFilterItem(&p, IDS_SYMBOLS_ICO, "*.ico");
624 DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");
626 return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
629 /* Local Variables: */
630 /* c-file-style: "GNU" */