4 * Copyright 1994 Martin Ayotte
15 #include "selectors.h"
18 #include "stackframe.h"
20 static DWORD CommDlgLastError
= 0;
22 static HBITMAP hFolder
= 0;
23 static HBITMAP hFolder2
= 0;
24 static HBITMAP hFloppy
= 0;
25 static HBITMAP hHDisk
= 0;
26 static HBITMAP hCDRom
= 0;
28 /***********************************************************************
29 * FileDlg_Init [internal]
31 static BOOL
FileDlg_Init()
33 static BOOL initialized
= 0;
36 if (!hFolder
) hFolder
= LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER
));
37 if (!hFolder2
) hFolder2
= LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER2
));
38 if (!hFloppy
) hFloppy
= LoadBitmap(0, MAKEINTRESOURCE(OBM_FLOPPY
));
39 if (!hHDisk
) hHDisk
= LoadBitmap(0, MAKEINTRESOURCE(OBM_HDISK
));
40 if (!hCDRom
) hCDRom
= LoadBitmap(0, MAKEINTRESOURCE(OBM_CDROM
));
41 if (hFolder
== 0 || hFolder2
== 0 || hFloppy
== 0 ||
42 hHDisk
== 0 || hCDRom
== 0)
44 fprintf(stderr
, "FileDlg_Init // Error loading bitmaps !");
52 /***********************************************************************
53 * GetOpenFileName (COMMDLG.1)
55 BOOL
GetOpenFileName(LPOPENFILENAME lpofn
)
58 HANDLE hDlgTmpl
, hResInfo
;
61 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
63 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
) hDlgTmpl
= lpofn
->hInstance
;
64 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
66 if (!(hResInfo
= FindResource( lpofn
->hInstance
,
67 lpofn
->lpTemplateName
, RT_DIALOG
)))
69 CommDlgLastError
= CDERR_FINDRESFAILURE
;
72 hDlgTmpl
= LoadResource( lpofn
->hInstance
, hResInfo
);
74 else hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_OPEN_FILE
);
77 CommDlgLastError
= CDERR_LOADRESFAILURE
;
81 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
82 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpofn
->hwndOwner
,
83 GetWndProcEntry16("FileOpenDlgProc"),
86 if (!(lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
))
88 if (lpofn
->Flags
& OFN_ENABLETEMPLATE
) FreeResource( hDlgTmpl
);
89 else SYSRES_FreeResource( hDlgTmpl
);
92 printf("GetOpenFileName // return lpstrFile='%s' !\n",
93 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
98 /***********************************************************************
99 * GetSaveFileName (COMMDLG.2)
101 BOOL
GetSaveFileName(LPOPENFILENAME lpofn
)
104 HANDLE hDlgTmpl
, hResInfo
;
107 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
109 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
) hDlgTmpl
= lpofn
->hInstance
;
110 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
112 hInst
= lpofn
->hInstance
;
113 if (!(hResInfo
= FindResource( lpofn
->hInstance
,
114 lpofn
->lpTemplateName
, RT_DIALOG
)))
116 CommDlgLastError
= CDERR_FINDRESFAILURE
;
119 hDlgTmpl
= LoadResource( lpofn
->hInstance
, hResInfo
);
121 else hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_SAVE_FILE
);
123 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
124 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpofn
->hwndOwner
,
125 GetWndProcEntry16("FileSaveDlgProc"),
127 if (!(lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
))
129 if (lpofn
->Flags
& OFN_ENABLETEMPLATE
) FreeResource( hDlgTmpl
);
130 else SYSRES_FreeResource( hDlgTmpl
);
133 printf( "GetSaveFileName // return lpstrFile='%s' !\n",
134 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
138 /***********************************************************************
139 * FILEDLG_StripEditControl [internal]
140 * Strip pathnames off the contents of the edit control.
142 static void FILEDLG_StripEditControl(HWND hwnd
)
146 SendDlgItemMessage(hwnd
, edt1
, WM_GETTEXT
, 511, (LPARAM
)MAKE_SEGPTR(temp
));
147 cp
= strrchr(temp
, '\\');
151 cp
= strrchr(temp
, ':');
157 /***********************************************************************
158 * FILEDLG_ScanDir [internal]
160 static BOOL
FILEDLG_ScanDir(HWND hWnd
, LPSTR newPath
)
162 char str
[512],str2
[512];
164 strncpy(str
,newPath
,511); str
[511]=0;
165 SendDlgItemMessage(hWnd
, edt1
, WM_GETTEXT
, 511, (LPARAM
)MAKE_SEGPTR(str2
));
166 strncat(str
,str2
,511-strlen(str
)); str
[511]=0;
167 if (!DlgDirList(hWnd
, str
, lst1
, 0, 0x0000)) return FALSE
;
168 DlgDirList(hWnd
, "*.*", lst2
, stc1
, 0x8010);
173 /***********************************************************************
174 * FILEDLG_GetFileType [internal]
177 static LPSTR
FILEDLG_GetFileType(LPSTR cfptr
, LPSTR fptr
, WORD index
)
182 for ( ;(n
= strlen(cfptr
)) != 0; i
++)
187 cfptr
+= strlen(cfptr
) + 1;
190 for ( ;(n
= strlen(fptr
)) != 0; i
++)
195 fptr
+= strlen(fptr
) + 1;
200 /***********************************************************************
201 * FILEDLG_WMDrawItem [internal]
203 static LONG
FILEDLG_WMDrawItem(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
205 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)PTR_SEG_TO_LIN(lParam
);
208 HBITMAP hBitmap
, hPrevBitmap
;
213 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst1
) {
214 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
215 SelectObject(lpdis
->hDC
, hBrush
);
216 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
217 SendMessage(lpdis
->hwndItem
, LB_GETTEXT
, lpdis
->itemID
,
218 (LPARAM
)MAKE_SEGPTR(str
));
219 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
221 if (lpdis
->itemState
!= 0) {
222 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
227 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst2
) {
228 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
229 SelectObject(lpdis
->hDC
, hBrush
);
230 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
231 SendMessage(lpdis
->hwndItem
, LB_GETTEXT
, lpdis
->itemID
,
232 (LPARAM
)MAKE_SEGPTR(str
));
235 GetObject(hBitmap
, sizeof(BITMAP
), (LPSTR
)&bm
);
236 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
237 lpdis
->rcItem
.top
, str
, strlen(str
));
238 hMemDC
= CreateCompatibleDC(lpdis
->hDC
);
239 hPrevBitmap
= SelectObject(hMemDC
, hBitmap
);
240 BitBlt(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
241 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
242 SelectObject(hMemDC
, hPrevBitmap
);
244 if (lpdis
->itemState
!= 0) {
245 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
249 if (lpdis
->CtlType
== ODT_COMBOBOX
&& lpdis
->CtlID
== cmb2
) {
250 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
251 SelectObject(lpdis
->hDC
, hBrush
);
252 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
253 SendMessage(lpdis
->hwndItem
, CB_GETLBTEXT
, lpdis
->itemID
,
254 (LPARAM
)MAKE_SEGPTR(str
));
263 GetObject(hBitmap
, sizeof(BITMAP
), (LPSTR
)&bm
);
264 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
265 lpdis
->rcItem
.top
, str
, strlen(str
));
266 hMemDC
= CreateCompatibleDC(lpdis
->hDC
);
267 hPrevBitmap
= SelectObject(hMemDC
, hBitmap
);
268 BitBlt(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
269 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
270 SelectObject(hMemDC
, hPrevBitmap
);
272 if (lpdis
->itemState
!= 0) {
273 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
280 /***********************************************************************
281 * FILEDLG_WMMeasureItem [internal]
283 static LONG
FILEDLG_WMMeasureItem(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
286 LPMEASUREITEMSTRUCT lpmeasure
;
288 GetObject(hFolder2
, sizeof(BITMAP
), (LPSTR
)&bm
);
289 lpmeasure
= (LPMEASUREITEMSTRUCT
)PTR_SEG_TO_LIN(lParam
);
290 lpmeasure
->itemHeight
= bm
.bmHeight
;
294 /***********************************************************************
295 * FILEDLG_WMInitDialog [internal]
298 static LONG
FILEDLG_WMInitDialog(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
301 LPOPENFILENAME lpofn
;
304 SetWindowLong(hWnd
, DWL_USER
, lParam
);
305 lpofn
= (LPOPENFILENAME
)lParam
;
306 /* read custom filter information */
307 if (lpofn
->lpstrCustomFilter
)
309 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
);
310 printf("lpstrCustomFilter = %p\n", pstr
);
314 strncpy(tmpstr
, pstr
, 511); tmpstr
[511]=0;
315 printf("lpstrCustomFilter // add tmpstr='%s' ", tmpstr
);
316 SendDlgItemMessage(hWnd
, cmb1
, CB_ADDSTRING
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr
));
319 printf("associated to '%s'\n", pstr
);
323 /* read filter information */
324 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFilter
);
328 strncpy(tmpstr
, pstr
, 511); tmpstr
[511]=0;
329 printf("lpstrFilter // add tmpstr='%s' ", tmpstr
);
330 SendDlgItemMessage(hWnd
, cmb1
, CB_ADDSTRING
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr
));
333 printf("associated to '%s'\n", pstr
);
336 /* set default filter */
337 if (lpofn
->nFilterIndex
== 0 && lpofn
->lpstrCustomFilter
== (SEGPTR
)NULL
)
338 lpofn
->nFilterIndex
= 1;
339 SendDlgItemMessage(hWnd
, cmb1
, CB_SETCURSEL
, lpofn
->nFilterIndex
- 1, 0);
340 strncpy(tmpstr
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
341 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
), lpofn
->nFilterIndex
- 1),511);
343 printf("nFilterIndex = %ld // SetText of edt1 to '%s'\n",
344 lpofn
->nFilterIndex
, tmpstr
);
345 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr
));
348 DlgDirListComboBox(hWnd
, MAKE_SEGPTR(tmpstr
), cmb2
, 0, 0xC000);
349 /* read initial directory */
350 if (PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
) != NULL
)
352 strncpy(tmpstr
, PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
), 510);
354 if (strlen(tmpstr
) > 0 && tmpstr
[strlen(tmpstr
)-1] != '\\'
355 && tmpstr
[strlen(tmpstr
)-1] != ':')
360 if (!FILEDLG_ScanDir(hWnd
, tmpstr
))
361 fprintf(stderr
, "FileDlg: couldn't read initial directory %s!\n", tmpstr
);
362 /* select current drive in combo 2 */
363 n
= DOS_GetDefaultDrive();
364 SendDlgItemMessage(hWnd
, cmb2
, CB_SETCURSEL
, n
, 0);
365 if (!(lpofn
->Flags
& OFN_SHOWHELP
))
366 ShowWindow(GetDlgItem(hWnd
, pshHelp
), SW_HIDE
);
367 if (lpofn
->Flags
& OFN_HIDEREADONLY
)
368 ShowWindow(GetDlgItem(hWnd
, chx1
), SW_HIDE
);
372 /***********************************************************************
373 * FILEDLG_WMCommand [internal]
375 static LRESULT
FILEDLG_WMCommand(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
378 LPOPENFILENAME lpofn
;
379 char tmpstr
[512], tmpstr2
[512];
382 lpofn
= (LPOPENFILENAME
)GetWindowLong(hWnd
, DWL_USER
);
385 case lst1
: /* file list */
386 FILEDLG_StripEditControl(hWnd
);
387 if (HIWORD(lParam
) == LBN_DBLCLK
)
389 lRet
= SendDlgItemMessage(hWnd
, lst1
, LB_GETCURSEL
, 0, 0);
390 if (lRet
== LB_ERR
) return TRUE
;
391 SendDlgItemMessage(hWnd
, lst1
, LB_GETTEXT
, lRet
,
392 (LPARAM
)MAKE_SEGPTR(tmpstr
));
393 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr
));
395 case lst2
: /* directory list */
396 FILEDLG_StripEditControl(hWnd
);
397 if (HIWORD(lParam
) == LBN_DBLCLK
)
399 lRet
= SendDlgItemMessage(hWnd
, lst2
, LB_GETCURSEL
, 0, 0);
400 if (lRet
== LB_ERR
) return TRUE
;
401 SendDlgItemMessage(hWnd
, lst2
, LB_GETTEXT
, lRet
,
402 (LPARAM
)MAKE_SEGPTR(tmpstr
));
403 if (tmpstr
[0] == '[')
405 tmpstr
[strlen(tmpstr
) - 1] = 0;
406 strcpy(tmpstr
,tmpstr
+1);
408 strcat(tmpstr
, "\\");
412 case cmb1
: /* file type drop list */
413 if (HIWORD(lParam
) == CBN_SELCHANGE
)
419 case cmb2
: /* disk drop list */
420 FILEDLG_StripEditControl(hWnd
);
421 lRet
= SendDlgItemMessage(hWnd
, cmb2
, CB_GETCURSEL
, 0, 0L);
422 if (lRet
== LB_ERR
) return 0;
423 SendDlgItemMessage(hWnd
, cmb2
, CB_GETLBTEXT
, lRet
, (LPARAM
)MAKE_SEGPTR(tmpstr
));
424 sprintf(tmpstr
, "%c:", tmpstr
[2]);
426 lRet
= SendDlgItemMessage(hWnd
, cmb1
, CB_GETCURSEL
, 0, 0);
429 pstr
= FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
430 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
432 strncpy(tmpstr2
, pstr
, 511); tmpstr2
[511]=0;
433 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr2
));
434 FILEDLG_ScanDir(hWnd
, tmpstr
);
442 SendDlgItemMessage(hWnd
, edt1
, WM_GETTEXT
, 511, (LPARAM
)MAKE_SEGPTR(tmpstr
));
443 pstr
= strrchr(tmpstr
, '\\');
445 pstr
= strrchr(tmpstr
, ':');
446 if (strchr(tmpstr
,'*') != NULL
|| strchr(tmpstr
,'?') != NULL
)
448 /* edit control contains wildcards */
451 strncpy(tmpstr2
, pstr
+1, 511); tmpstr2
[511]=0;
456 strcpy(tmpstr2
, tmpstr
);
459 printf("commdlg: %s, %s\n", tmpstr
, tmpstr2
);
460 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr2
));
461 FILEDLG_ScanDir(hWnd
, tmpstr
);
464 /* no wildcards, we might have a directory or a filename */
465 /* try appending a wildcard and reading the directory */
466 pstr2
= tmpstr
+ strlen(tmpstr
);
467 if (pstr
== NULL
|| *(pstr
+1) != 0)
468 strcat(tmpstr
, "\\");
469 lRet
= SendDlgItemMessage(hWnd
, cmb1
, CB_GETCURSEL
, 0, 0);
470 if (lRet
== LB_ERR
) return TRUE
;
471 lpofn
->nFilterIndex
= lRet
+ 1;
472 printf("commdlg: lpofn->nFilterIndex=%ld\n", lpofn
->nFilterIndex
);
474 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
475 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
478 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr2
));
479 /* if ScanDir succeeds, we have changed the directory */
480 if (FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
481 /* if not, this must be a filename */
485 /* strip off the pathname */
487 strncpy(tmpstr2
, pstr
+1, 511); tmpstr2
[511]=0;
488 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr2
));
489 /* Should we MessageBox() if this fails? */
490 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
491 strcpy(tmpstr
, tmpstr2
);
494 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr
));
495 ShowWindow(hWnd
, SW_HIDE
);
498 drive
= DOS_GetDefaultDrive();
499 tmpstr2
[0] = 'A'+ drive
;
502 strncpy(tmpstr2
+ 3, DOS_GetCurrentDir(drive
), 507); tmpstr2
[510]=0;
503 if (strlen(tmpstr2
) > 3)
504 strcat(tmpstr2
, "\\");
505 strncat(tmpstr2
, tmpstr
, 511-strlen(tmpstr2
)); tmpstr2
[511]=0;
506 strcpy(PTR_SEG_TO_LIN(lpofn
->lpstrFile
), tmpstr2
);
508 lpofn
->nFileOffset
= 0;
509 lpofn
->nFileExtension
= 0;
510 while(tmpstr2
[lpofn
->nFileExtension
] != '.' && tmpstr2
[lpofn
->nFileExtension
] != '\0')
511 lpofn
->nFileExtension
++;
512 if (lpofn
->nFileExtension
== '\0')
513 lpofn
->nFileExtension
= 0;
515 lpofn
->nFileExtension
++;
516 if (PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
) != NULL
)
518 lRet
= SendDlgItemMessage(hWnd
, lst1
, LB_GETCURSEL
, 0, 0);
519 SendDlgItemMessage(hWnd
, lst1
, LB_GETTEXT
, lRet
,
520 (LPARAM
)MAKE_SEGPTR(tmpstr
));
521 printf("strcpy'ing '%s'\n",tmpstr
); fflush(stdout
);
522 strcpy(PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
), tmpstr
);
524 EndDialog(hWnd
, TRUE
);
527 EndDialog(hWnd
, FALSE
);
534 /***********************************************************************
535 * FileOpenDlgProc (COMMDLG.6)
537 LRESULT
FileOpenDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
542 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
544 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
546 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
);
548 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
551 SetBkColor((HDC
)wParam
, 0x00C0C0C0);
552 switch (HIWORD(lParam
))
555 SetTextColor((HDC
)wParam
, 0x00000000);
557 case CTLCOLOR_STATIC
:
558 SetTextColor((HDC
)wParam
, 0x00000000);
568 /***********************************************************************
569 * FileSaveDlgProc (COMMDLG.7)
571 LRESULT
FileSaveDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
575 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
578 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
581 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
);
584 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
589 SetBkColor((HDC)wParam, 0x00C0C0C0);
590 switch (HIWORD(lParam))
593 SetTextColor((HDC)wParam, 0x00000000);
595 case CTLCOLOR_STATIC:
596 SetTextColor((HDC)wParam, 0x00000000);
606 /***********************************************************************
607 * ChooseColor (COMMDLG.5)
609 BOOL
ChooseColor(LPCHOOSECOLOR lpChCol
)
611 HANDLE hInst
, hDlgTmpl
;
614 hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_CHOOSE_COLOR
);
615 hInst
= WIN_GetWindowInstance( lpChCol
->hwndOwner
);
616 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpChCol
->hwndOwner
,
617 GetWndProcEntry16("ColorDlgProc"),
619 SYSRES_FreeResource( hDlgTmpl
);
624 /***********************************************************************
625 * ColorDlgProc (COMMDLG.8)
627 LRESULT
ColorDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
632 printf("ColorDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
633 ShowWindow(hWnd
, SW_SHOWNORMAL
);
639 EndDialog(hWnd
, TRUE
);
642 EndDialog(hWnd
, FALSE
);
651 /***********************************************************************
652 * FindTextDlg (COMMDLG.11)
654 BOOL
FindText(LPFINDREPLACE lpFind
)
656 HANDLE hInst
, hDlgTmpl
;
659 hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_FIND_TEXT
);
660 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
661 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpFind
->hwndOwner
,
662 GetWndProcEntry16("FindTextDlgProc"),
664 SYSRES_FreeResource( hDlgTmpl
);
669 /***********************************************************************
670 * ReplaceTextDlg (COMMDLG.12)
672 BOOL
ReplaceText(LPFINDREPLACE lpFind
)
674 HANDLE hInst
, hDlgTmpl
;
677 hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_REPLACE_TEXT
);
678 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
679 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpFind
->hwndOwner
,
680 GetWndProcEntry16("ReplaceTextDlgProc"),
682 SYSRES_FreeResource( hDlgTmpl
);
687 /***********************************************************************
688 * FindTextDlgProc (COMMDLG.13)
690 LRESULT
FindTextDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
695 printf("FindTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
696 ShowWindow(hWnd
, SW_SHOWNORMAL
);
702 EndDialog(hWnd
, TRUE
);
705 EndDialog(hWnd
, FALSE
);
714 /***********************************************************************
715 * ReplaceTextDlgProc (COMMDLG.14)
717 LRESULT
ReplaceTextDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
722 printf("ReplaceTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
723 ShowWindow(hWnd
, SW_SHOWNORMAL
);
729 EndDialog(hWnd
, TRUE
);
732 EndDialog(hWnd
, FALSE
);
741 /***********************************************************************
742 * PrintDlg (COMMDLG.20)
744 BOOL
PrintDlg(LPPRINTDLG lpPrint
)
746 HANDLE hInst
, hDlgTmpl
;
749 printf("PrintDlg(%p) // Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
751 if (lpPrint
->Flags
& PD_RETURNDEFAULT
)
752 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
755 if (lpPrint
->Flags
& PD_PRINTSETUP
)
756 hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_PRINT_SETUP
);
758 hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_PRINT
);
760 hInst
= WIN_GetWindowInstance( lpPrint
->hwndOwner
);
761 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpPrint
->hwndOwner
,
762 (lpPrint
->Flags
& PD_PRINTSETUP
) ?
763 GetWndProcEntry16("PrintSetupDlgProc") :
764 GetWndProcEntry16("PrintDlgProc"),
766 SYSRES_FreeResource( hDlgTmpl
);
771 /***********************************************************************
772 * PrintDlgProc (COMMDLG.21)
774 LRESULT
PrintDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
779 printf("PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
780 ShowWindow(hWnd
, SW_SHOWNORMAL
);
786 EndDialog(hWnd
, TRUE
);
789 EndDialog(hWnd
, FALSE
);
798 /***********************************************************************
799 * PrintSetupDlgProc (COMMDLG.22)
801 LRESULT
PrintSetupDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
806 printf("PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
807 ShowWindow(hWnd
, SW_SHOWNORMAL
);
812 EndDialog(hWnd
, TRUE
);
815 EndDialog(hWnd
, FALSE
);
824 /***********************************************************************
825 * CommDlgExtendedError (COMMDLG.26)
827 DWORD
CommDlgExtendedError(void)
829 return CommDlgLastError
;
833 /***********************************************************************
834 * GetFileTitle (COMMDLG.27)
836 short GetFileTitle(LPCSTR lpFile
, LPSTR lpTitle
, UINT cbBuf
)
839 printf("GetFileTitle(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
840 if (lpFile
== NULL
|| lpTitle
== NULL
)
842 len
= strlen(lpFile
);
845 if (strpbrk(lpFile
, "*[]"))
848 if (lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
850 for (i
= len
; i
>= 0; i
--)
851 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
856 printf("\n---> '%s' ", &lpFile
[i
]);
858 len
= strlen(lpFile
+i
)+1;
862 strncpy(lpTitle
, &lpFile
[i
], len
);