4 * Copyright 1996 Ulrich Schmid
11 static BOOL
DIALOG_BrowsePrograms(HWND
, LPSTR
, INT
);
12 static BOOL
DIALOG_BrowseSymbols(HWND
, LPSTR
, INT
);
13 static LRESULT
DIALOG_NEW_DlgProc(HWND
, UINT
, WPARAM
, LPARAM
);
14 static LRESULT
DIALOG_COPY_MOVE_DlgProc(HWND
, UINT
, WPARAM
, LPARAM
);
15 static LRESULT
DIALOG_GROUP_DlgProc(HWND
, UINT
, WPARAM
, LPARAM
);
16 static LRESULT
DIALOG_PROGRAM_DlgProc(HWND
, UINT
, WPARAM
, LPARAM
);
17 static LRESULT
DIALOG_SYMBOL_DlgProc(HWND
, UINT
, WPARAM
, LPARAM
);
18 static LRESULT
DIALOG_EXECUTE_DlgProc(HWND
, UINT
, WPARAM
, LPARAM
);
20 /***********************************************************************
30 INT
DIALOG_New(INT nDefault
)
32 WNDPROC lpfnDlg
= MakeProcInstance(DIALOG_NEW_DlgProc
, Globals
.hInstance
);
35 New
.nDefault
= nDefault
;
37 ret
= DialogBox(Globals
.hInstance
, STRING_NEW_Xx
,
38 Globals
.hMainWnd
, (DLGPROC
)lpfnDlg
);
39 FreeProcInstance(lpfnDlg
);
43 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
48 static LRESULT
DIALOG_NEW_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
53 CheckRadioButton(hDlg
, PM_NEW_GROUP
, PM_NEW_PROGRAM
, New
.nDefault
);
61 CheckRadioButton(hDlg
, PM_NEW_GROUP
, PM_NEW_PROGRAM
, wParam
);
65 EndDialog(hDlg
, IsDlgButtonChecked(hDlg
, PM_NEW_GROUP
) ?
66 PM_NEW_GROUP
: PM_NEW_PROGRAM
);
70 EndDialog(hDlg
, IDCANCEL
);
77 /***********************************************************************
84 LPCSTR lpszProgramName
, lpszFromGroupName
;
88 HLOCAL
DIALOG_CopyMove(LPCSTR lpszProgramName
, LPCSTR lpszFromGroupName
,
91 WNDPROC lpfnDlg
= MakeProcInstance(DIALOG_COPY_MOVE_DlgProc
, Globals
.hInstance
);
94 CopyMove
.lpszProgramName
= lpszProgramName
;
95 CopyMove
.lpszFromGroupName
= lpszFromGroupName
;
96 CopyMove
.hToGroup
= 0;
98 ret
= DialogBox(Globals
.hInstance
,
99 bMove
? STRING_MOVE_Xx
: STRING_COPY_Xx
,
100 Globals
.hMainWnd
, (DLGPROC
)lpfnDlg
);
101 FreeProcInstance(lpfnDlg
);
103 return((ret
== IDOK
) ? CopyMove
.hToGroup
: 0);
106 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
108 * DIALOG_COPY_MOVE_DlgProc
111 static LRESULT
DIALOG_COPY_MOVE_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
118 /* List all group names */
119 for (hGroup
= GROUP_FirstGroup(); hGroup
; hGroup
= GROUP_NextGroup(hGroup
))
120 SendDlgItemMessage(hDlg
, PM_TO_GROUP
, CB_ADDSTRING
, 0,
121 (LPARAM
) GROUP_GroupName(hGroup
));
123 SetDlgItemText(hDlg
, PM_PROGRAM
, (LPSTR
)CopyMove
.lpszProgramName
);
124 SetDlgItemText(hDlg
, PM_FROM_GROUP
, (LPSTR
)CopyMove
.lpszFromGroupName
);
132 /* Get selected group */
133 INT nCurSel
= SendDlgItemMessage(hDlg
, PM_TO_GROUP
, CB_GETCURSEL
, 0, 0);
134 INT nLen
= SendDlgItemMessage(hDlg
, PM_TO_GROUP
, CB_GETLBTEXTLEN
, nCurSel
, 0);
135 HLOCAL hBuffer
= LocalAlloc(LMEM_FIXED
, nLen
+ 1);
136 LPSTR buffer
= LocalLock(hBuffer
);
138 SendDlgItemMessage(hDlg
, PM_TO_GROUP
, CB_GETLBTEXT
, nCurSel
, (LPARAM
)buffer
);
139 for (hGroup
= GROUP_FirstGroup(); hGroup
; hGroup
= GROUP_NextGroup(hGroup
))
140 if (!lstrcmp(buffer
, GROUP_GroupName(hGroup
))) break;
143 CopyMove
.hToGroup
= hGroup
;
144 EndDialog(hDlg
, IDOK
);
149 EndDialog(hDlg
, IDCANCEL
);
156 /***********************************************************************
161 BOOL
DIALOG_Delete(UINT ids_text_s
, LPCSTR lpszName
)
163 return (IDYES
== MAIN_MessageBoxIDS_s(ids_text_s
, lpszName
, IDS_DELETE
,
164 MB_YESNO
| MB_DEFBUTTON2
));
168 /***********************************************************************
170 * DIALOG_GroupAttributes
175 LPSTR lpszTitle
, lpszGrpFile
;
179 BOOL
DIALOG_GroupAttributes(LPSTR lpszTitle
, LPSTR lpszGrpFile
, INT nSize
)
181 WNDPROC lpfnDlg
= MakeProcInstance(DIALOG_GROUP_DlgProc
, Globals
.hInstance
);
184 GroupAttributes
.nSize
= nSize
;
185 GroupAttributes
.lpszTitle
= lpszTitle
;
186 GroupAttributes
.lpszGrpFile
= lpszGrpFile
;
188 ret
= DialogBox(Globals
.hInstance
, STRING_GROUP_Xx
,
189 Globals
.hMainWnd
, (DLGPROC
)lpfnDlg
);
190 FreeProcInstance(lpfnDlg
);
194 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
196 * DIALOG_GROUP_DlgProc
199 static LRESULT
DIALOG_GROUP_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
204 SetDlgItemText(hDlg
, PM_DESCRIPTION
, GroupAttributes
.lpszTitle
);
205 SetDlgItemText(hDlg
, PM_FILE
, GroupAttributes
.lpszGrpFile
);
212 GetDlgItemText(hDlg
, PM_DESCRIPTION
, GroupAttributes
.lpszTitle
,
213 GroupAttributes
.nSize
);
214 GetDlgItemText(hDlg
, PM_FILE
, GroupAttributes
.lpszGrpFile
,
215 GroupAttributes
.nSize
);
216 EndDialog(hDlg
, IDOK
);
220 EndDialog(hDlg
, IDCANCEL
);
227 /***********************************************************************
229 * DIALOG_ProgramAttributes
234 LPSTR lpszTitle
, lpszCmdLine
, lpszWorkDir
, lpszIconFile
, lpszTmpIconFile
;
239 HICON
*lphIcon
, hTmpIcon
;
240 INT
*lpnIconIndex
, nTmpIconIndex
;
243 BOOL
DIALOG_ProgramAttributes(LPSTR lpszTitle
, LPSTR lpszCmdLine
,
244 LPSTR lpszWorkDir
, LPSTR lpszIconFile
,
245 HICON
*lphIcon
, INT
*lpnIconIndex
,
246 INT
*lpnHotKey
, INT
*lpnCmdShow
, INT nSize
)
248 CHAR szTmpIconFile
[MAX_PATHNAME_LEN
];
249 WNDPROC lpfnDlg
= MakeProcInstance(DIALOG_PROGRAM_DlgProc
, Globals
.hInstance
);
252 ProgramAttributes
.nSize
= nSize
;
253 ProgramAttributes
.lpszTitle
= lpszTitle
;
254 ProgramAttributes
.lpszCmdLine
= lpszCmdLine
;
255 ProgramAttributes
.lpszWorkDir
= lpszWorkDir
;
256 ProgramAttributes
.lpszIconFile
= lpszIconFile
;
257 ProgramAttributes
.lpnCmdShow
= lpnCmdShow
;
258 ProgramAttributes
.lpnHotKey
= lpnHotKey
;
259 ProgramAttributes
.lphIcon
= lphIcon
;
260 ProgramAttributes
.lpnIconIndex
= lpnIconIndex
;
263 ProgramAttributes
.hTmpIcon
= 0;
265 ProgramAttributes
.hTmpIcon
= *lphIcon
;
267 ProgramAttributes
.nTmpIconIndex
= *lpnIconIndex
;
268 ProgramAttributes
.lpszTmpIconFile
= szTmpIconFile
;
269 lstrcpyn(ProgramAttributes
.lpszTmpIconFile
, lpszIconFile
, MAX_PATHNAME_LEN
);
271 ret
= DialogBox(Globals
.hInstance
, STRING_PROGRAM_Xx
,
272 Globals
.hMainWnd
, (DLGPROC
)lpfnDlg
);
273 FreeProcInstance(lpfnDlg
);
278 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
280 * DIALOG_PROGRAM_DlgProc
283 static LRESULT
DIALOG_PROGRAM_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
285 CHAR buffer
[MAX_STRING_LEN
];
289 SetDlgItemText(hDlg
, PM_DESCRIPTION
, ProgramAttributes
.lpszTitle
);
290 SetDlgItemText(hDlg
, PM_COMMAND_LINE
, ProgramAttributes
.lpszCmdLine
);
291 SetDlgItemText(hDlg
, PM_DIRECTORY
, ProgramAttributes
.lpszWorkDir
);
292 if (!*ProgramAttributes
.lpnHotKey
)
294 LoadString(Globals
.hInstance
, IDS_NO_HOT_KEY
, buffer
, sizeof(buffer
));
295 SetDlgItemText(hDlg
, PM_HOT_KEY
, buffer
);
298 CheckDlgButton(hDlg
, PM_SYMBOL
,
299 (*ProgramAttributes
.lpnCmdShow
== SW_SHOWMINIMIZED
));
300 SendDlgItemMessage(hDlg
, PM_ICON
, STM_SETICON
,
301 (WPARAM
) ProgramAttributes
.hTmpIcon
, 0);
308 CheckDlgButton(hDlg
, PM_SYMBOL
, !IsDlgButtonChecked(hDlg
, PM_SYMBOL
));
313 CHAR filename
[MAX_PATHNAME_LEN
];
314 if (DIALOG_BrowsePrograms(hDlg
, filename
, sizeof(filename
)))
315 SetDlgItemText(hDlg
, PM_COMMAND_LINE
, filename
);
319 case PM_OTHER_SYMBOL
:
321 DIALOG_Symbol(&ProgramAttributes
.hTmpIcon
,
322 ProgramAttributes
.lpszTmpIconFile
,
323 &ProgramAttributes
.nTmpIconIndex
,
326 SendDlgItemMessage(hDlg
, PM_ICON
, STM_SETICON
,
327 (WPARAM
) ProgramAttributes
.hTmpIcon
, 0);
332 GetDlgItemText(hDlg
, PM_DESCRIPTION
,
333 ProgramAttributes
.lpszTitle
,
334 ProgramAttributes
.nSize
);
335 GetDlgItemText(hDlg
, PM_COMMAND_LINE
,
336 ProgramAttributes
.lpszCmdLine
,
337 ProgramAttributes
.nSize
);
338 GetDlgItemText(hDlg
, PM_DIRECTORY
,
339 ProgramAttributes
.lpszWorkDir
,
340 ProgramAttributes
.nSize
);
342 if (ProgramAttributes
.hTmpIcon
)
345 if (*ProgramAttributes
.lphIcon
)
346 DestroyIcon(*ProgramAttributes
.lphIcon
);
348 *ProgramAttributes
.lphIcon
= ProgramAttributes
.hTmpIcon
;
349 *ProgramAttributes
.lpnIconIndex
= ProgramAttributes
.nTmpIconIndex
;
350 lstrcpyn(ProgramAttributes
.lpszIconFile
,
351 ProgramAttributes
.lpszTmpIconFile
,
352 ProgramAttributes
.nSize
);
355 *ProgramAttributes
.lpnCmdShow
=
356 IsDlgButtonChecked(hDlg
, PM_SYMBOL
) ?
357 SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
358 EndDialog(hDlg
, IDOK
);
362 EndDialog(hDlg
, IDCANCEL
);
370 /***********************************************************************
383 VOID
DIALOG_Symbol(HICON
*lphIcon
, LPSTR lpszIconFile
,
384 INT
*lpnIconIndex
, INT nSize
)
386 WNDPROC lpfnDlg
= MakeProcInstance(DIALOG_SYMBOL_DlgProc
, Globals
.hInstance
);
388 Symbol
.nSize
= nSize
;
389 Symbol
.lpszIconFile
= lpszIconFile
;
390 Symbol
.lphIcon
= lphIcon
;
391 Symbol
.lpnIconIndex
= lpnIconIndex
;
393 DialogBox(Globals
.hInstance
, STRING_SYMBOL_Xx
,
394 Globals
.hMainWnd
, (DLGPROC
)lpfnDlg
);
395 FreeProcInstance(lpfnDlg
);
398 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
400 * DIALOG_SYMBOL_DlgProc
403 static LRESULT
DIALOG_SYMBOL_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
408 SetDlgItemText(hDlg
, PM_ICON_FILE
, Symbol
.lpszIconFile
);
409 SendDlgItemMessage(hDlg
, PM_SYMBOL_LIST
, CB_SETITEMHEIGHT
, 0, (LPARAM
) 32);
410 SendDlgItemMessage(hDlg
, PM_SYMBOL_LIST
, CB_ADDSTRING
, 0, (LPARAM
)*Symbol
.lphIcon
);
411 SendDlgItemMessage(hDlg
, PM_SYMBOL_LIST
, CB_ADDSTRING
, 0, (LPARAM
)Globals
.hDefaultIcon
);
412 SendDlgItemMessage(hDlg
, PM_SYMBOL_LIST
, CB_SETCURSEL
, 0, 0);
417 PMEASUREITEMSTRUCT measure
= (PMEASUREITEMSTRUCT
) lParam
;
418 measure
->itemWidth
= 32;
419 measure
->itemHeight
= 32;
425 PDRAWITEMSTRUCT dis
= (PDRAWITEMSTRUCT
) lParam
;
426 DrawIcon(dis
->hDC
, dis
->rcItem
.left
, dis
->rcItem
.top
, (HICON
)dis
->itemData
);
435 CHAR filename
[MAX_PATHNAME_LEN
];
436 if (DIALOG_BrowseSymbols(hDlg
, filename
, sizeof(filename
)))
437 SetDlgItemText(hDlg
, PM_ICON_FILE
, filename
);
442 MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED
, IDS_ERROR
, MB_OK
);
447 INT nCurSel
= SendDlgItemMessage(hDlg
, PM_SYMBOL_LIST
, CB_GETCURSEL
, 0, 0);
449 GetDlgItemText(hDlg
, PM_ICON_FILE
, Symbol
.lpszIconFile
, Symbol
.nSize
);
451 *Symbol
.lphIcon
= (HICON
)SendDlgItemMessage(hDlg
, PM_SYMBOL_LIST
,
453 (WPARAM
) nCurSel
, 0);
455 *Symbol
.lphIcon
= CopyIcon(*Symbol
.lphIcon
);
458 EndDialog(hDlg
, IDOK
);
463 EndDialog(hDlg
, IDCANCEL
);
470 /***********************************************************************
475 VOID
DIALOG_Execute()
477 WNDPROC lpfnDlg
= MakeProcInstance(DIALOG_EXECUTE_DlgProc
, Globals
.hInstance
);
478 DialogBox(Globals
.hInstance
, STRING_EXECUTE_Xx
,
479 Globals
.hMainWnd
, (DLGPROC
)lpfnDlg
);
480 FreeProcInstance(lpfnDlg
);
483 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
485 * DIALOG_EXECUTE_DlgProc
488 static LRESULT
DIALOG_EXECUTE_DlgProc(HWND hDlg
, UINT msg
,
489 WPARAM wParam
, LPARAM lParam
)
497 CheckDlgButton(hDlg
, PM_SYMBOL
, !IsDlgButtonChecked(hDlg
, PM_SYMBOL
));
502 CHAR filename
[MAX_PATHNAME_LEN
];
503 if (DIALOG_BrowsePrograms(hDlg
, filename
, sizeof(filename
)))
504 SetDlgItemText(hDlg
, PM_COMMAND
, filename
);
509 MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED
, IDS_ERROR
, MB_OK
);
514 CHAR cmdline
[MAX_PATHNAME_LEN
];
515 GetDlgItemText(hDlg
, PM_COMMAND
, cmdline
, sizeof(cmdline
));
517 WinExec(cmdline
, IsDlgButtonChecked(hDlg
, PM_SYMBOL
) ?
518 SW_SHOWMINIMIZED
: SW_SHOWNORMAL
);
519 if (Globals
.bMinOnRun
) CloseWindow(Globals
.hMainWnd
);
521 EndDialog(hDlg
, IDOK
);
526 EndDialog(hDlg
, IDCANCEL
);
533 /***********************************************************************
538 static BOOL
DIALOG_Browse(HWND hDlg
, LPCSTR lpszzFilter
,
539 LPSTR lpstrFile
, INT nMaxFile
)
541 OPENFILENAME openfilename
;
543 /* FIXME is this correct ? */
544 openfilename
.lStructSize
= 0;
545 openfilename
.hwndOwner
= hDlg
;
546 openfilename
.hInstance
= Globals
.hInstance
;
547 openfilename
.lpstrFilter
= (LPSTR
)lpszzFilter
;
548 openfilename
.lpstrCustomFilter
= 0;
549 openfilename
.nMaxCustFilter
= 0;
550 openfilename
.nFilterIndex
= 0;
551 openfilename
.lpstrFile
= lpstrFile
;
552 openfilename
.nMaxFile
= sizeof(lpstrFile
);
553 openfilename
.lpstrFileTitle
= 0;
554 openfilename
.nMaxFileTitle
= 0;
555 openfilename
.lpstrInitialDir
= 0;
556 openfilename
.lpstrTitle
= 0;
557 openfilename
.Flags
= 0;
558 openfilename
.nFileOffset
= 0;
559 openfilename
.nFileExtension
= 0;
560 openfilename
.lpstrDefExt
= 0;
561 openfilename
.lCustData
= 0;
562 openfilename
.lpfnHook
= 0;
563 openfilename
.lpTemplateName
= 0;
564 return GetOpenFileName(&openfilename
);
567 /***********************************************************************
569 * DIALOG_AddFilterItem
572 static VOID
DIALOG_AddFilterItem(LPSTR
*p
, UINT ids
, LPCSTR filter
)
574 LoadString(Globals
.hInstance
, ids
, *p
, MAX_STRING_LEN
);
575 *p
+= strlen(*p
) + 1;
577 *p
+= strlen(*p
) + 1;
581 /***********************************************************************
583 * DIALOG_BrowsePrograms
586 static BOOL
DIALOG_BrowsePrograms(HWND hDlg
, LPSTR lpszFile
, INT nMaxFile
)
588 CHAR szzFilter
[2 * MAX_STRING_LEN
+ 100];
591 DIALOG_AddFilterItem(&p
, IDS_PROGRAMS
, "*.exe;*.pif;*.com;*.bat");
592 DIALOG_AddFilterItem(&p
, IDS_ALL_FILES
, "*.*");
594 return(DIALOG_Browse(hDlg
, szzFilter
, lpszFile
, nMaxFile
));
597 /***********************************************************************
599 * DIALOG_BrowseSymbols
602 static BOOL
DIALOG_BrowseSymbols(HWND hDlg
, LPSTR lpszFile
, INT nMaxFile
)
604 CHAR szzFilter
[5 * MAX_STRING_LEN
+ 100];
607 DIALOG_AddFilterItem(&p
, IDS_SYMBOL_FILES
, "*.ico;*.exe;*.dll");
608 DIALOG_AddFilterItem(&p
, IDS_PROGRAMS
, "*.exe");
609 DIALOG_AddFilterItem(&p
, IDS_LIBRARIES_DLL
, "*.dll");
610 DIALOG_AddFilterItem(&p
, IDS_SYMBOLS_ICO
, "*.ico");
611 DIALOG_AddFilterItem(&p
, IDS_ALL_FILES
, "*.*");
613 return(DIALOG_Browse(hDlg
, szzFilter
, lpszFile
, nMaxFile
));
616 /* Local Variables: */
617 /* c-file-style: "GNU" */