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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define WIN32_LEAN_AND_MEAN
30 /***********************************************************************
35 static BOOL DIALOG_Browse(HWND hDlg, LPCSTR lpszzFilter,
36 LPSTR lpstrFile, INT nMaxFile)
39 OPENFILENAME openfilename;
42 CHAR szDefaultExt[] = "exe";
44 ZeroMemory(&openfilename, sizeof(openfilename));
46 GetCurrentDirectory(sizeof(szDir), szDir);
48 openfilename.lStructSize = sizeof(openfilename);
49 openfilename.hwndOwner = Globals.hMainWnd;
50 openfilename.hInstance = Globals.hInstance;
51 openfilename.lpstrFilter = lpszzFilter;
52 openfilename.lpstrFile = lpstrFile;
53 openfilename.nMaxFile = nMaxFile;
54 openfilename.lpstrInitialDir = szDir;
55 openfilename.Flags = 0;
56 openfilename.lpstrDefExt = szDefaultExt;
57 openfilename.lpstrCustomFilter = 0;
58 openfilename.nMaxCustFilter = 0;
59 openfilename.nFilterIndex = 0;
60 openfilename.lpstrFileTitle = 0;
61 openfilename.nMaxFileTitle = 0;
62 openfilename.lpstrInitialDir = 0;
63 openfilename.lpstrTitle = 0;
64 openfilename.nFileOffset = 0;
65 openfilename.nFileExtension = 0;
66 openfilename.lCustData = 0;
67 openfilename.lpfnHook = 0;
68 openfilename.lpTemplateName = 0;
70 return GetOpenFileName(&openfilename);
73 /***********************************************************************
75 * DIALOG_AddFilterItem
78 static VOID DIALOG_AddFilterItem(LPSTR *p, UINT ids, LPCSTR filter)
80 LoadString(Globals.hInstance, ids, *p, MAX_STRING_LEN);
87 /***********************************************************************
89 * DIALOG_BrowsePrograms
92 static BOOL DIALOG_BrowsePrograms(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
94 CHAR szzFilter[2 * MAX_STRING_LEN + 100];
97 DIALOG_AddFilterItem(&p, IDS_PROGRAMS, "*.exe;*.pif;*.com;*.bat");
98 DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");
100 return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
103 /***********************************************************************
105 * DIALOG_BrowseSymbols
108 static BOOL DIALOG_BrowseSymbols(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
110 CHAR szzFilter[5 * MAX_STRING_LEN + 100];
113 DIALOG_AddFilterItem(&p, IDS_SYMBOL_FILES, "*.ico;*.exe;*.dll");
114 DIALOG_AddFilterItem(&p, IDS_PROGRAMS, "*.exe");
115 DIALOG_AddFilterItem(&p, IDS_LIBRARIES_DLL, "*.dll");
116 DIALOG_AddFilterItem(&p, IDS_SYMBOLS_ICO, "*.ico");
117 DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");
119 return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
127 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
131 static INT_PTR CALLBACK DIALOG_NEW_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
136 CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, New.nDefault);
144 CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, wParam);
148 EndDialog(hDlg, IsDlgButtonChecked(hDlg, PM_NEW_GROUP) ?
149 PM_NEW_GROUP : PM_NEW_PROGRAM);
153 EndDialog(hDlg, IDCANCEL);
160 /***********************************************************************
164 INT DIALOG_New(INT nDefault)
166 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_NEW_DlgProc, Globals.hInstance);
169 New.nDefault = nDefault;
171 ret = DialogBox(Globals.hInstance, STRING_NEW,
172 Globals.hMainWnd, lpfnDlg);
173 FreeProcInstance(lpfnDlg);
180 LPCSTR lpszProgramName, lpszFromGroupName;
184 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
186 * DIALOG_COPY_MOVE_DlgProc
188 static INT_PTR CALLBACK DIALOG_COPY_MOVE_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
195 /* List all group names */
196 for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
197 SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_ADDSTRING, 0,
198 (LPARAM) GROUP_GroupName(hGroup));
200 SetDlgItemText(hDlg, PM_PROGRAM, CopyMove.lpszProgramName);
201 SetDlgItemText(hDlg, PM_FROM_GROUP, CopyMove.lpszFromGroupName);
209 /* Get selected group */
210 INT nCurSel = SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETCURSEL, 0, 0);
211 INT nLen = SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETLBTEXTLEN, nCurSel, 0);
212 HLOCAL hBuffer = LocalAlloc(LMEM_FIXED, nLen + 1);
213 LPSTR buffer = LocalLock(hBuffer);
215 SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETLBTEXT, nCurSel, (LPARAM)buffer);
216 for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
217 if (!lstrcmp(buffer, GROUP_GroupName(hGroup))) break;
220 CopyMove.hToGroup = hGroup;
221 EndDialog(hDlg, IDOK);
226 EndDialog(hDlg, IDCANCEL);
233 /***********************************************************************
237 HLOCAL DIALOG_CopyMove(LPCSTR lpszProgramName, LPCSTR lpszFromGroupName,
240 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_COPY_MOVE_DlgProc, Globals.hInstance);
243 CopyMove.lpszProgramName = lpszProgramName;
244 CopyMove.lpszFromGroupName = lpszFromGroupName;
245 CopyMove.hToGroup = 0;
247 ret = DialogBox(Globals.hInstance,
248 bMove ? STRING_MOVE : STRING_COPY,
249 Globals.hMainWnd, lpfnDlg);
250 FreeProcInstance(lpfnDlg);
252 return((ret == IDOK) ? CopyMove.hToGroup : 0);
255 /***********************************************************************
260 BOOL DIALOG_Delete(UINT ids_text_s, LPCSTR lpszName)
262 return (IDYES == MAIN_MessageBoxIDS_s(ids_text_s, lpszName, IDS_DELETE,
263 MB_YESNO | MB_DEFBUTTON2));
269 LPSTR lpszTitle, lpszGrpFile;
273 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
275 * DIALOG_GROUP_DlgProc
277 static INT_PTR CALLBACK DIALOG_GROUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
282 SetDlgItemText(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle);
283 SetDlgItemText(hDlg, PM_FILE, GroupAttributes.lpszGrpFile);
290 GetDlgItemText(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle,
291 GroupAttributes.nSize);
292 GetDlgItemText(hDlg, PM_FILE, GroupAttributes.lpszGrpFile,
293 GroupAttributes.nSize);
294 EndDialog(hDlg, IDOK);
298 EndDialog(hDlg, IDCANCEL);
305 /***********************************************************************
307 * DIALOG_GroupAttributes
309 BOOL DIALOG_GroupAttributes(LPSTR lpszTitle, LPSTR lpszGrpFile, INT nSize)
311 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_GROUP_DlgProc, Globals.hInstance);
314 GroupAttributes.nSize = nSize;
315 GroupAttributes.lpszTitle = lpszTitle;
316 GroupAttributes.lpszGrpFile = lpszGrpFile;
318 ret = DialogBox(Globals.hInstance, STRING_GROUP,
319 Globals.hMainWnd, lpfnDlg);
320 FreeProcInstance(lpfnDlg);
333 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
335 * DIALOG_SYMBOL_DlgProc
337 static INT_PTR CALLBACK DIALOG_SYMBOL_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
342 SetDlgItemText(hDlg, PM_ICON_FILE, Symbol.lpszIconFile);
343 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_SETITEMHEIGHT, 0, (LPARAM) 32);
344 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)*Symbol.lphIcon);
345 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)Globals.hDefaultIcon);
346 SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_SETCURSEL, 0, 0);
351 PMEASUREITEMSTRUCT measure = (PMEASUREITEMSTRUCT) lParam;
352 measure->itemWidth = 32;
353 measure->itemHeight = 32;
359 PDRAWITEMSTRUCT dis = (PDRAWITEMSTRUCT) lParam;
360 DrawIcon(dis->hDC, dis->rcItem.left, dis->rcItem.top, (HICON)dis->itemData);
369 CHAR filename[MAX_PATHNAME_LEN];
371 if (DIALOG_BrowseSymbols(hDlg, filename, sizeof(filename)))
372 SetDlgItemText(hDlg, PM_ICON_FILE, filename);
377 MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
382 INT nCurSel = SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_GETCURSEL, 0, 0);
384 GetDlgItemText(hDlg, PM_ICON_FILE, Symbol.lpszIconFile, Symbol.nSize);
386 *Symbol.lphIcon = (HICON)SendDlgItemMessage(hDlg, PM_SYMBOL_LIST,
388 (WPARAM) nCurSel, 0);
390 *Symbol.lphIcon = CopyIcon(*Symbol.lphIcon);
393 EndDialog(hDlg, IDOK);
398 EndDialog(hDlg, IDCANCEL);
405 /***********************************************************************
409 static VOID DIALOG_Symbol(HICON *lphIcon, LPSTR lpszIconFile,
410 INT *lpnIconIndex, INT nSize)
412 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_SYMBOL_DlgProc, Globals.hInstance);
414 Symbol.nSize = nSize;
415 Symbol.lpszIconFile = lpszIconFile;
416 Symbol.lphIcon = lphIcon;
417 Symbol.lpnIconIndex = lpnIconIndex;
419 DialogBox(Globals.hInstance, STRING_SYMBOL,
420 Globals.hMainWnd, lpfnDlg);
421 FreeProcInstance(lpfnDlg);
427 LPSTR lpszTitle, lpszCmdLine, lpszWorkDir, lpszIconFile, lpszTmpIconFile;
432 HICON *lphIcon, hTmpIcon;
433 INT *lpnIconIndex, nTmpIconIndex;
436 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
438 * DIALOG_PROGRAM_DlgProc
440 static INT_PTR CALLBACK DIALOG_PROGRAM_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
442 CHAR buffer[MAX_STRING_LEN];
446 SetDlgItemText(hDlg, PM_DESCRIPTION, ProgramAttributes.lpszTitle);
447 SetDlgItemText(hDlg, PM_COMMAND_LINE, ProgramAttributes.lpszCmdLine);
448 SetDlgItemText(hDlg, PM_DIRECTORY, ProgramAttributes.lpszWorkDir);
449 if (!*ProgramAttributes.lpnHotKey)
451 LoadString(Globals.hInstance, IDS_NO_HOT_KEY, buffer, sizeof(buffer));
452 SetDlgItemText(hDlg, PM_HOT_KEY, buffer);
455 CheckDlgButton(hDlg, PM_SYMBOL,
456 (*ProgramAttributes.lpnCmdShow == SW_SHOWMINIMIZED));
457 SendDlgItemMessage(hDlg, PM_ICON, STM_SETICON,
458 (WPARAM) ProgramAttributes.hTmpIcon, 0);
465 CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
470 CHAR filename[MAX_PATHNAME_LEN];
472 if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
473 SetDlgItemText(hDlg, PM_COMMAND_LINE, filename);
477 case PM_OTHER_SYMBOL:
479 DIALOG_Symbol(&ProgramAttributes.hTmpIcon,
480 ProgramAttributes.lpszTmpIconFile,
481 &ProgramAttributes.nTmpIconIndex,
484 SendDlgItemMessage(hDlg, PM_ICON, STM_SETICON,
485 (WPARAM) ProgramAttributes.hTmpIcon, 0);
490 GetDlgItemText(hDlg, PM_DESCRIPTION,
491 ProgramAttributes.lpszTitle,
492 ProgramAttributes.nSize);
493 GetDlgItemText(hDlg, PM_COMMAND_LINE,
494 ProgramAttributes.lpszCmdLine,
495 ProgramAttributes.nSize);
496 GetDlgItemText(hDlg, PM_DIRECTORY,
497 ProgramAttributes.lpszWorkDir,
498 ProgramAttributes.nSize);
500 if (ProgramAttributes.hTmpIcon)
503 if (*ProgramAttributes.lphIcon)
504 DestroyIcon(*ProgramAttributes.lphIcon);
506 *ProgramAttributes.lphIcon = ProgramAttributes.hTmpIcon;
507 *ProgramAttributes.lpnIconIndex = ProgramAttributes.nTmpIconIndex;
508 lstrcpyn(ProgramAttributes.lpszIconFile,
509 ProgramAttributes.lpszTmpIconFile,
510 ProgramAttributes.nSize);
513 *ProgramAttributes.lpnCmdShow =
514 IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
515 SW_SHOWMINIMIZED : SW_SHOWNORMAL;
516 EndDialog(hDlg, IDOK);
520 EndDialog(hDlg, IDCANCEL);
528 /***********************************************************************
530 * DIALOG_ProgramAttributes
532 BOOL DIALOG_ProgramAttributes(LPSTR lpszTitle, LPSTR lpszCmdLine,
533 LPSTR lpszWorkDir, LPSTR lpszIconFile,
534 HICON *lphIcon, INT *lpnIconIndex,
535 INT *lpnHotKey, INT *lpnCmdShow, INT nSize)
537 CHAR szTmpIconFile[MAX_PATHNAME_LEN];
538 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_PROGRAM_DlgProc, Globals.hInstance);
541 ProgramAttributes.nSize = nSize;
542 ProgramAttributes.lpszTitle = lpszTitle;
543 ProgramAttributes.lpszCmdLine = lpszCmdLine;
544 ProgramAttributes.lpszWorkDir = lpszWorkDir;
545 ProgramAttributes.lpszIconFile = lpszIconFile;
546 ProgramAttributes.lpnCmdShow = lpnCmdShow;
547 ProgramAttributes.lpnHotKey = lpnHotKey;
548 ProgramAttributes.lphIcon = lphIcon;
549 ProgramAttributes.lpnIconIndex = lpnIconIndex;
552 ProgramAttributes.hTmpIcon = 0;
554 ProgramAttributes.hTmpIcon = *lphIcon;
556 ProgramAttributes.nTmpIconIndex = *lpnIconIndex;
557 ProgramAttributes.lpszTmpIconFile = szTmpIconFile;
558 lstrcpyn(ProgramAttributes.lpszTmpIconFile, lpszIconFile, MAX_PATHNAME_LEN);
560 ret = DialogBox(Globals.hInstance, STRING_PROGRAM,
561 Globals.hMainWnd, lpfnDlg);
562 FreeProcInstance(lpfnDlg);
568 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
570 * DIALOG_EXECUTE_DlgProc
572 static INT_PTR CALLBACK DIALOG_EXECUTE_DlgProc(HWND hDlg, UINT msg,
573 WPARAM wParam, LPARAM lParam)
581 CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
586 CHAR filename[MAX_PATHNAME_LEN];
588 if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
589 SetDlgItemText(hDlg, PM_COMMAND, filename);
594 MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
599 CHAR cmdline[MAX_PATHNAME_LEN];
600 GetDlgItemText(hDlg, PM_COMMAND, cmdline, sizeof(cmdline));
602 WinExec(cmdline, IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
603 SW_SHOWMINIMIZED : SW_SHOWNORMAL);
604 if (Globals.bMinOnRun) CloseWindow(Globals.hMainWnd);
606 EndDialog(hDlg, IDOK);
611 EndDialog(hDlg, IDCANCEL);
618 /***********************************************************************
623 VOID DIALOG_Execute(void)
625 DLGPROC lpfnDlg = MakeProcInstance(DIALOG_EXECUTE_DlgProc, Globals.hInstance);
626 DialogBox(Globals.hInstance, STRING_EXECUTE, Globals.hMainWnd, lpfnDlg);
627 FreeProcInstance(lpfnDlg);
630 /* Local Variables: */
631 /* c-file-style: "GNU" */