4 * Copyright 1994 Martin Ayotte
16 #include "selectors.h"
17 #include "../rc/sysres.h"
19 #include "stackframe.h"
21 #define OPENFILEDLG2 11
22 #define SAVEFILEDLG2 12
24 static DWORD CommDlgLastError
= 0;
26 static HBITMAP hFolder
= 0;
27 static HBITMAP hFolder2
= 0;
28 static HBITMAP hFloppy
= 0;
29 static HBITMAP hHDisk
= 0;
30 static HBITMAP hCDRom
= 0;
32 /***********************************************************************
33 * FileDlg_Init [internal]
35 static BOOL
FileDlg_Init()
37 static BOOL initialized
= 0;
40 if (!hFolder
) hFolder
= LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER
));
41 if (!hFolder2
) hFolder2
= LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER2
));
42 if (!hFloppy
) hFloppy
= LoadBitmap(0, MAKEINTRESOURCE(OBM_FLOPPY
));
43 if (!hHDisk
) hHDisk
= LoadBitmap(0, MAKEINTRESOURCE(OBM_HDISK
));
44 if (!hCDRom
) hCDRom
= LoadBitmap(0, MAKEINTRESOURCE(OBM_CDROM
));
45 if (hFolder
== 0 || hFolder2
== 0 || hFloppy
== 0 ||
46 hHDisk
== 0 || hCDRom
== 0)
48 fprintf(stderr
, "FileDlg_Init // Error loading bitmaps !");
56 /***********************************************************************
57 * GetOpenFileName [COMMDLG.1]
59 BOOL
GetOpenFileName(LPOPENFILENAME lpofn
)
67 if (!FileDlg_Init()) return FALSE
;
69 if (lpofn
== NULL
) return FALSE
;
70 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
) {
71 dlgTemplate
= GlobalLock(lpofn
->hInstance
);
73 CommDlgLastError
= CDERR_LOADRESFAILURE
;
77 if (lpofn
->Flags
& OFN_ENABLETEMPLATE
) {
78 hInst
= lpofn
->hInstance
;
79 hResInfo
= FindResource(hInst
, lpofn
->lpTemplateName
, RT_DIALOG
);
81 CommDlgLastError
= CDERR_FINDRESFAILURE
;
84 hDlgTmpl
= LoadResource(hInst
, hResInfo
);
86 CommDlgLastError
= CDERR_LOADRESFAILURE
;
89 dlgTemplate
= GlobalLock(hDlgTmpl
);
91 dlgTemplate
= sysres_DIALOG_3
;
94 hInst
= GetWindowWord(lpofn
->hwndOwner
, GWW_HINSTANCE
);
95 bRet
= DialogBoxIndirectParamPtr(hInst
, dlgTemplate
, lpofn
->hwndOwner
,
96 GetWndProcEntry16("FileOpenDlgProc"),
99 printf("GetOpenFileName // return lpstrFile='%s' !\n",
100 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
105 /***********************************************************************
106 * GetSaveFileName [COMMDLG.2]
108 BOOL
GetSaveFileName(LPOPENFILENAME lpofn
)
116 if (!FileDlg_Init()) return FALSE
;
118 if (lpofn
== NULL
) return FALSE
;
119 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
) {
120 dlgTemplate
= GlobalLock(lpofn
->hInstance
);
122 CommDlgLastError
= CDERR_LOADRESFAILURE
;
126 if (lpofn
->Flags
& OFN_ENABLETEMPLATE
) {
127 hInst
= lpofn
->hInstance
;
128 hResInfo
= FindResource(hInst
, lpofn
->lpTemplateName
, RT_DIALOG
);
130 CommDlgLastError
= CDERR_FINDRESFAILURE
;
133 hDlgTmpl
= LoadResource(hInst
, hResInfo
);
135 CommDlgLastError
= CDERR_LOADRESFAILURE
;
138 dlgTemplate
= GlobalLock(hDlgTmpl
);
140 dlgTemplate
= sysres_DIALOG_4
; /* SAVEFILEDIALOG */
143 hInst
= GetWindowWord(lpofn
->hwndOwner
, GWW_HINSTANCE
);
144 bRet
= DialogBoxIndirectParamPtr(hInst
, dlgTemplate
, lpofn
->hwndOwner
,
145 GetWndProcEntry16("FileSaveDlgProc"),
147 printf("GetSaveFileName // return lpstrFile='%s' !\n",
148 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
152 /***********************************************************************
153 * FILEDLG_StripEditControl [internal]
154 * Strip pathnames off the contents of the edit control.
156 static void FILEDLG_StripEditControl(HWND hwnd
)
160 SendDlgItemMessage(hwnd
, edt1
, WM_GETTEXT
, 511, MAKE_SEGPTR(temp
));
161 cp
= strrchr(temp
, '\\');
165 cp
= strrchr(temp
, ':');
171 /***********************************************************************
172 * FILEDLG_ScanDir [internal]
174 static BOOL
FILEDLG_ScanDir(HWND hWnd
, LPSTR newPath
)
176 char str
[512],str2
[512];
179 SendDlgItemMessage(hWnd
, edt1
, WM_GETTEXT
, 511, MAKE_SEGPTR(str2
));
181 if (!DlgDirList(hWnd
, str
, lst1
, 0, 0x0000)) return FALSE
;
182 DlgDirList(hWnd
, "*.*", lst2
, stc1
, 0x8010);
187 /***********************************************************************
188 * FILEDLG_GetFileType [internal]
190 static LPSTR
FILEDLG_GetFileType(LPSTR ptr
, WORD index
)
194 if (ptr
== NULL
) return NULL
;
200 if (i
== index
) return ptr
;
207 /***********************************************************************
208 * FILEDLG_WMDrawItem [internal]
210 static LONG
FILEDLG_WMDrawItem(HWND hWnd
, WORD wParam
, LONG lParam
)
212 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)PTR_SEG_TO_LIN(lParam
);
215 HBITMAP hBitmap
, hPrevBitmap
;
219 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst1
) {
220 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
221 SelectObject(lpdis
->hDC
, hBrush
);
222 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
223 str
= (LPSTR
) PTR_SEG_TO_LIN(lpdis
->itemData
);
225 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
227 if (lpdis
->itemState
!= 0) {
228 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
234 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst2
) {
235 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
236 SelectObject(lpdis
->hDC
, hBrush
);
237 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
238 str
= (LPSTR
) PTR_SEG_TO_LIN(lpdis
->itemData
);
241 GetObject(hBitmap
, sizeof(BITMAP
), (LPSTR
)&bm
);
242 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
243 lpdis
->rcItem
.top
, str
, strlen(str
));
244 hMemDC
= CreateCompatibleDC(lpdis
->hDC
);
245 hPrevBitmap
= SelectObject(hMemDC
, hBitmap
);
246 BitBlt(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
247 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
248 SelectObject(hMemDC
, hPrevBitmap
);
250 if (lpdis
->itemState
!= 0) {
251 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
256 if (lpdis
->CtlType
== ODT_COMBOBOX
&& lpdis
->CtlID
== cmb2
) {
257 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
258 SelectObject(lpdis
->hDC
, hBrush
);
259 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
260 str
= (LPSTR
) PTR_SEG_TO_LIN(lpdis
->itemData
);
270 GetObject(hBitmap
, sizeof(BITMAP
), (LPSTR
)&bm
);
271 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
272 lpdis
->rcItem
.top
, str
, strlen(str
));
273 hMemDC
= CreateCompatibleDC(lpdis
->hDC
);
274 hPrevBitmap
= SelectObject(hMemDC
, hBitmap
);
275 BitBlt(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
276 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
277 SelectObject(hMemDC
, hPrevBitmap
);
279 if (lpdis
->itemState
!= 0) {
280 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
288 /***********************************************************************
289 * FILEDLG_WMMeasureItem [internal]
291 static LONG
FILEDLG_WMMeasureItem(HWND hWnd
, WORD wParam
, LONG lParam
)
294 LPMEASUREITEMSTRUCT lpmeasure
;
296 GetObject(hFolder2
, sizeof(BITMAP
), (LPSTR
)&bm
);
297 lpmeasure
= (LPMEASUREITEMSTRUCT
)PTR_SEG_TO_LIN(lParam
);
298 lpmeasure
->itemHeight
= bm
.bmHeight
;
302 /***********************************************************************
303 * FILEDLG_WMInitDialog [internal]
305 static LONG
FILEDLG_WMInitDialog(HWND hWnd
, WORD wParam
, LONG lParam
)
308 LPOPENFILENAME lpofn
;
312 SetWindowLong(hWnd
, DWL_USER
, lParam
);
313 lpofn
= (LPOPENFILENAME
)lParam
;
315 /* read filter information */
316 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFilter
);
319 strcpy(tmpstr
, pstr
);
320 SendDlgItemMessage(hWnd
, cmb1
, CB_ADDSTRING
, 0, MAKE_SEGPTR(tmpstr
));
326 /* set default filter */
327 SendDlgItemMessage(hWnd
, cmb1
, CB_SETCURSEL
,
328 lpofn
->nFilterIndex
- 1, 0);
329 strcpy(tmpstr
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
330 lpofn
->nFilterIndex
));
331 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr
));
335 DlgDirListComboBox(hWnd
, MAKE_SEGPTR(tmpstr
), cmb2
, 0, 0xC000);
337 /* read initial directory */
338 if (PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
) != NULL
) {
339 strcpy(tmpstr
, PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
));
340 if (strlen(tmpstr
) > 0 && tmpstr
[strlen(tmpstr
)-1] != '\\'
341 && tmpstr
[strlen(tmpstr
)-1] != ':')
348 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) {
349 fprintf(stderr
, "FileDlg: couldn't read initial directory!\n");
352 /* select current drive in combo 2 */
353 n
= DOS_GetDefaultDrive();
354 SendDlgItemMessage(hWnd
, cmb2
, CB_SETCURSEL
, n
, 0);
356 if (!(lpofn
->Flags
& OFN_SHOWHELP
)) {
357 ShowWindow(GetDlgItem(hWnd
, pshHelp
), SW_HIDE
);
359 if (lpofn
->Flags
& OFN_HIDEREADONLY
) {
360 ShowWindow(GetDlgItem(hWnd
, chx1
), SW_HIDE
);
365 /***********************************************************************
366 * FILEDLG_WMCommand [internal]
368 static LONG
FILEDLG_WMCommand(HWND hWnd
, WORD wParam
, LONG lParam
)
371 LPOPENFILENAME lpofn
;
372 char tmpstr
[512], tmpstr2
[512];
375 lpofn
= (LPOPENFILENAME
)GetWindowLong(hWnd
, DWL_USER
);
378 FILEDLG_StripEditControl(hWnd
);
379 if (HIWORD(lParam
) == LBN_DBLCLK
) {
380 lRet
= SendDlgItemMessage(hWnd
, lst1
, LB_GETCURSEL
, 0, 0);
381 if (lRet
== LB_ERR
) return TRUE
;
382 SendDlgItemMessage(hWnd
, lst1
, LB_GETTEXT
, lRet
, MAKE_SEGPTR(tmpstr
));
383 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr
));
384 return SendMessage(hWnd
, WM_COMMAND
, IDOK
, 0);
388 FILEDLG_StripEditControl(hWnd
);
389 if (HIWORD(lParam
) == LBN_DBLCLK
) {
390 lRet
= SendDlgItemMessage(hWnd
, lst2
, LB_GETCURSEL
, 0, 0);
391 if (lRet
== LB_ERR
) return TRUE
;
392 SendDlgItemMessage(hWnd
, lst2
, LB_GETTEXT
, lRet
, MAKE_SEGPTR(tmpstr
));
394 if (tmpstr
[0] == '[') {
395 tmpstr
[strlen(tmpstr
) - 1] = 0;
396 strcpy(tmpstr
,tmpstr
+1);
398 strcat(tmpstr
, "\\");
399 FILEDLG_ScanDir(hWnd
, tmpstr
);
404 if (HIWORD(lParam
) == CBN_SELCHANGE
) {
405 lRet
= SendDlgItemMessage(hWnd
, cmb1
, CB_GETCURSEL
, 0, 0);
406 if (lRet
== LB_ERR
) return TRUE
;
407 strcpy(tmpstr
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
409 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr
));
410 FILEDLG_ScanDir(hWnd
, "");
415 FILEDLG_StripEditControl(hWnd
);
416 lRet
= SendDlgItemMessage(hWnd
, cmb2
, CB_GETCURSEL
, 0, 0L);
417 if (lRet
== LB_ERR
) return 0;
418 SendDlgItemMessage(hWnd
, cmb2
, CB_GETLBTEXT
, lRet
, MAKE_SEGPTR(tmpstr
));
419 sprintf(tmpstr
, "%c:", tmpstr
[2]);
420 FILEDLG_ScanDir(hWnd
, tmpstr
);
430 SendDlgItemMessage(hWnd
, edt1
, WM_GETTEXT
, 511, MAKE_SEGPTR(tmpstr
));
432 pstr
= strrchr(tmpstr
, '\\');
433 if (pstr
== NULL
) pstr
= strrchr(tmpstr
, ':');
435 if (strchr(tmpstr
,'*') != NULL
|| strchr(tmpstr
,'?') != NULL
) {
436 /* edit control contains wildcards */
438 strcpy(tmpstr2
, pstr
+1);
441 strcpy(tmpstr2
, tmpstr
);
444 printf("commdlg: %s, %s\n", tmpstr
, tmpstr2
);
445 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
446 FILEDLG_ScanDir(hWnd
, tmpstr
);
450 /* no wildcards, we might have a directory or a filename */
451 /* try appending a wildcard and reading the directory */
452 pstr2
= tmpstr
+ strlen(tmpstr
);
453 if (pstr
== NULL
|| *(pstr
+1) != 0) {
454 strcat(tmpstr
, "\\");
456 lRet
= SendDlgItemMessage(hWnd
, cmb1
, CB_GETCURSEL
, 0, 0);
457 if (lRet
== LB_ERR
) return TRUE
;
458 strcpy(tmpstr2
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
460 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
461 /* if ScanDir succeeds, we have changed the directory */
462 if (FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
464 /* if not, this must be a filename */
468 /* strip off the pathname */
470 strcpy(tmpstr2
, pstr
+1);
471 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
472 /* Should we MessageBox() if this fails? */
473 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
474 strcpy(tmpstr
, tmpstr2
);
476 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr
));
479 ShowWindow(hWnd
, SW_HIDE
);
480 strcpy(PTR_SEG_TO_LIN(lpofn
->lpstrFile
), tmpstr
);
481 lpofn
->nFileOffset
= 0;
482 lpofn
->nFileExtension
= strlen(PTR_SEG_TO_LIN(lpofn
->lpstrFile
)) - 3;
483 if (PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
) != NULL
) {
484 lRet
= SendDlgItemMessage(hWnd
, lst1
, LB_GETCURSEL
, 0, 0);
485 SendDlgItemMessage(hWnd
, lst1
, LB_GETTEXT
, lRet
, MAKE_SEGPTR(tmpstr
));
486 strcpy(PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
), tmpstr
);
488 EndDialog(hWnd
, TRUE
);
491 EndDialog(hWnd
, FALSE
);
497 /***********************************************************************
498 * FileOpenDlgProc [COMMDLG.6]
500 BOOL
FileOpenDlgProc(HWND hWnd
, WORD wMsg
, WORD wParam
, LONG lParam
)
504 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
507 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
510 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
);
513 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
518 SetBkColor((HDC)wParam, 0x00C0C0C0);
519 switch (HIWORD(lParam))
522 SetTextColor((HDC)wParam, 0x00000000);
524 case CTLCOLOR_STATIC:
525 SetTextColor((HDC)wParam, 0x00000000);
535 /***********************************************************************
536 * FileSaveDlgProc [COMMDLG.7]
538 BOOL
FileSaveDlgProc(HWND hWnd
, WORD wMsg
, WORD wParam
, LONG lParam
)
542 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
545 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
548 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
);
551 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
556 SetBkColor((HDC)wParam, 0x00C0C0C0);
557 switch (HIWORD(lParam))
560 SetTextColor((HDC)wParam, 0x00000000);
562 case CTLCOLOR_STATIC:
563 SetTextColor((HDC)wParam, 0x00000000);
573 /***********************************************************************
574 * ChooseColor [COMMDLG.5]
576 BOOL
ChooseColor(LPCHOOSECOLOR lpChCol
)
580 wndPtr
= WIN_FindWndPtr(lpChCol
->hwndOwner
);
581 bRet
= DialogBoxIndirectParamPtr(wndPtr
->hInstance
, sysres_DIALOG_8
,
582 lpChCol
->hwndOwner
, GetWndProcEntry16("ColorDlgProc"),
588 /***********************************************************************
589 * ColorDlgProc [COMMDLG.8]
591 BOOL
ColorDlgProc(HWND hWnd
, WORD wMsg
, WORD wParam
, LONG lParam
)
595 printf("ColorDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
596 ShowWindow(hWnd
, SW_SHOWNORMAL
);
602 EndDialog(hWnd
, TRUE
);
605 EndDialog(hWnd
, FALSE
);
614 /***********************************************************************
615 * FindTextDlg [COMMDLG.11]
617 BOOL
FindText(LPFINDREPLACE lpFind
)
623 lpTemplate
= sysres_DIALOG_9
;
624 wndPtr
= WIN_FindWndPtr(lpFind
->hwndOwner
);
625 bRet
= DialogBoxIndirectParamPtr(wndPtr
->hInstance
, lpTemplate
,
626 lpFind
->hwndOwner
, GetWndProcEntry16("FindTextDlgProc"),
632 /***********************************************************************
633 * ReplaceTextDlg [COMMDLG.12]
635 BOOL
ReplaceText(LPFINDREPLACE lpFind
)
641 lpTemplate
= sysres_DIALOG_10
;
642 wndPtr
= WIN_FindWndPtr(lpFind
->hwndOwner
);
643 bRet
= DialogBoxIndirectParamPtr(wndPtr
->hInstance
, lpTemplate
,
644 lpFind
->hwndOwner
, GetWndProcEntry16("ReplaceTextDlgProc"),
650 /***********************************************************************
651 * FindTextDlgProc [COMMDLG.13]
653 BOOL
FindTextDlgProc(HWND hWnd
, WORD wMsg
, WORD wParam
, LONG lParam
)
657 printf("FindTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
658 ShowWindow(hWnd
, SW_SHOWNORMAL
);
664 EndDialog(hWnd
, TRUE
);
667 EndDialog(hWnd
, FALSE
);
676 /***********************************************************************
677 * ReplaceTextDlgProc [COMMDLG.14]
679 BOOL
ReplaceTextDlgProc(HWND hWnd
, WORD wMsg
, WORD wParam
, LONG lParam
)
683 printf("ReplaceTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
684 ShowWindow(hWnd
, SW_SHOWNORMAL
);
690 EndDialog(hWnd
, TRUE
);
693 EndDialog(hWnd
, FALSE
);
702 /***********************************************************************
703 * PrintDlg [COMMDLG.20]
705 BOOL
PrintDlg(LPPRINTDLG lpPrint
)
711 printf("PrintDlg(%p) // Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
712 if (lpPrint
->Flags
& PD_PRINTSETUP
) {
713 lpTemplate
= sysres_DIALOG_6
;
715 lpTemplate
= sysres_DIALOG_5
;
717 wndPtr
= WIN_FindWndPtr(lpPrint
->hwndOwner
);
718 if (lpPrint
->Flags
& PD_PRINTSETUP
)
719 bRet
= DialogBoxIndirectParamPtr(wndPtr
->hInstance
, lpTemplate
,
720 lpPrint
->hwndOwner
, GetWndProcEntry16("PrintSetupDlgProc"),
723 bRet
= DialogBoxIndirectParamPtr(wndPtr
->hInstance
, lpTemplate
,
724 lpPrint
->hwndOwner
, GetWndProcEntry16("PrintDlgProc"),
730 /***********************************************************************
731 * PrintDlgProc [COMMDLG.21]
733 BOOL
PrintDlgProc(HWND hWnd
, WORD wMsg
, WORD wParam
, LONG lParam
)
737 printf("PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
738 ShowWindow(hWnd
, SW_SHOWNORMAL
);
744 EndDialog(hWnd
, TRUE
);
747 EndDialog(hWnd
, FALSE
);
756 /***********************************************************************
757 * PrintSetupDlgProc [COMMDLG.22]
759 BOOL
PrintSetupDlgProc(HWND hWnd
, WORD wMsg
, WORD wParam
, LONG lParam
)
763 printf("PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
764 ShowWindow(hWnd
, SW_SHOWNORMAL
);
770 EndDialog(hWnd
, TRUE
);
773 EndDialog(hWnd
, FALSE
);
782 /***********************************************************************
783 * CommDlgExtendError [COMMDLG.26]
785 DWORD
CommDlgExtendError(void)
787 return CommDlgLastError
;
791 /***********************************************************************
792 * GetFileTitle [COMMDLG.27]
794 int GetFileTitle(LPCSTR lpFile
, LPSTR lpTitle
, UINT cbBuf
)
797 printf("GetFileTitle(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
798 if (lpFile
== NULL
|| lpTitle
== NULL
) return -1;
799 len
= strlen(lpFile
);
800 if (len
== 0) return -1;
801 if (strchr(lpFile
, '*') != NULL
) return -1;
802 if (strchr(lpFile
, '[') != NULL
) return -1;
803 if (strchr(lpFile
, ']') != NULL
) return -1;
805 if (lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':') return -1;
806 for (i
= len
; i
>= 0; i
--) {
807 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':') {
812 printf("\n---> '%s' ", &lpFile
[i
]);
813 len
= min(cbBuf
, strlen(&lpFile
[i
]) + 1);
814 strncpy(lpTitle
, &lpFile
[i
], len
+ 1);