4 * Copyright 1994 Martin Ayotte
16 #include "selectors.h"
17 #include "../rc/sysres.h"
19 #include "stackframe.h"
21 static DWORD CommDlgLastError
= 0;
23 static HBITMAP hFolder
= 0;
24 static HBITMAP hFolder2
= 0;
25 static HBITMAP hFloppy
= 0;
26 static HBITMAP hHDisk
= 0;
27 static HBITMAP hCDRom
= 0;
29 /***********************************************************************
30 * FileDlg_Init [internal]
32 static BOOL
FileDlg_Init()
34 static BOOL initialized
= 0;
37 if (!hFolder
) hFolder
= LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER
));
38 if (!hFolder2
) hFolder2
= LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER2
));
39 if (!hFloppy
) hFloppy
= LoadBitmap(0, MAKEINTRESOURCE(OBM_FLOPPY
));
40 if (!hHDisk
) hHDisk
= LoadBitmap(0, MAKEINTRESOURCE(OBM_HDISK
));
41 if (!hCDRom
) hCDRom
= LoadBitmap(0, MAKEINTRESOURCE(OBM_CDROM
));
42 if (hFolder
== 0 || hFolder2
== 0 || hFloppy
== 0 ||
43 hHDisk
== 0 || hCDRom
== 0)
45 fprintf(stderr
, "FileDlg_Init // Error loading bitmaps !");
53 /***********************************************************************
54 * GetOpenFileName (COMMDLG.1)
56 BOOL
GetOpenFileName(LPOPENFILENAME lpofn
)
59 HANDLE hDlgTmpl
, hResInfo
;
62 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
64 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
) hDlgTmpl
= lpofn
->hInstance
;
65 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
67 if (!(hResInfo
= FindResource( lpofn
->hInstance
,
68 lpofn
->lpTemplateName
, RT_DIALOG
)))
70 CommDlgLastError
= CDERR_FINDRESFAILURE
;
73 hDlgTmpl
= LoadResource( lpofn
->hInstance
, hResInfo
);
75 else hDlgTmpl
= GLOBAL_CreateBlock( GMEM_FIXED
,
76 sysres_DIALOG_OPEN_FILE
.bytes
,
77 sysres_DIALOG_OPEN_FILE
.size
,
78 GetCurrentPDB(), FALSE
, FALSE
,
82 CommDlgLastError
= CDERR_LOADRESFAILURE
;
86 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
87 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpofn
->hwndOwner
,
88 GetWndProcEntry16("FileOpenDlgProc"),
91 if (!(lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
))
93 if (lpofn
->Flags
& OFN_ENABLETEMPLATE
) FreeResource( hDlgTmpl
);
94 else GLOBAL_FreeBlock( hDlgTmpl
);
97 printf("GetOpenFileName // return lpstrFile='%s' !\n",
98 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
103 /***********************************************************************
104 * GetSaveFileName (COMMDLG.2)
106 BOOL
GetSaveFileName(LPOPENFILENAME lpofn
)
109 HANDLE hDlgTmpl
, hResInfo
;
112 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
114 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
) hDlgTmpl
= lpofn
->hInstance
;
115 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
117 hInst
= lpofn
->hInstance
;
118 if (!(hResInfo
= FindResource( lpofn
->hInstance
,
119 lpofn
->lpTemplateName
, RT_DIALOG
)))
121 CommDlgLastError
= CDERR_FINDRESFAILURE
;
124 hDlgTmpl
= LoadResource( lpofn
->hInstance
, hResInfo
);
126 else hDlgTmpl
= GLOBAL_CreateBlock( GMEM_FIXED
,
127 sysres_DIALOG_SAVE_FILE
.bytes
,
128 sysres_DIALOG_SAVE_FILE
.size
,
129 GetCurrentPDB(), FALSE
, FALSE
,
133 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
134 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpofn
->hwndOwner
,
135 GetWndProcEntry16("FileSaveDlgProc"),
137 if (!(lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
))
139 if (lpofn
->Flags
& OFN_ENABLETEMPLATE
) FreeResource( hDlgTmpl
);
140 else GLOBAL_FreeBlock( hDlgTmpl
);
143 printf( "GetSaveFileName // return lpstrFile='%s' !\n",
144 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
148 /***********************************************************************
149 * FILEDLG_StripEditControl [internal]
150 * Strip pathnames off the contents of the edit control.
152 static void FILEDLG_StripEditControl(HWND hwnd
)
156 SendDlgItemMessage(hwnd
, edt1
, WM_GETTEXT
, 511, MAKE_SEGPTR(temp
));
157 cp
= strrchr(temp
, '\\');
161 cp
= strrchr(temp
, ':');
167 /***********************************************************************
168 * FILEDLG_ScanDir [internal]
170 static BOOL
FILEDLG_ScanDir(HWND hWnd
, LPSTR newPath
)
172 char str
[512],str2
[512];
174 strncpy(str
,newPath
,511); str
[511]=0;
175 SendDlgItemMessage(hWnd
, edt1
, WM_GETTEXT
, 511, MAKE_SEGPTR(str2
));
176 strncat(str
,str2
,511-strlen(str
)); str
[511]=0;
177 if (!DlgDirList(hWnd
, str
, lst1
, 0, 0x0000)) return FALSE
;
178 DlgDirList(hWnd
, "*.*", lst2
, stc1
, 0x8010);
183 /***********************************************************************
184 * FILEDLG_GetFileType [internal]
187 static LPSTR
FILEDLG_GetFileType(LPSTR cfptr
, LPSTR fptr
, WORD index
)
192 for ( ;(n
= strlen(cfptr
)) != 0; i
++)
197 cfptr
+= strlen(cfptr
) + 1;
200 for ( ;(n
= strlen(fptr
)) != 0; i
++)
205 fptr
+= strlen(fptr
) + 1;
210 /***********************************************************************
211 * FILEDLG_WMDrawItem [internal]
213 static LONG
FILEDLG_WMDrawItem(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
215 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)PTR_SEG_TO_LIN(lParam
);
218 HBITMAP hBitmap
, hPrevBitmap
;
223 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst1
) {
224 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
225 SelectObject(lpdis
->hDC
, hBrush
);
226 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
227 SendMessage(lpdis
->hwndItem
, LB_GETTEXT
, lpdis
->itemID
,
229 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
231 if (lpdis
->itemState
!= 0) {
232 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
237 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst2
) {
238 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
239 SelectObject(lpdis
->hDC
, hBrush
);
240 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
241 SendMessage(lpdis
->hwndItem
, LB_GETTEXT
, lpdis
->itemID
,
245 GetObject(hBitmap
, sizeof(BITMAP
), (LPSTR
)&bm
);
246 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
247 lpdis
->rcItem
.top
, str
, strlen(str
));
248 hMemDC
= CreateCompatibleDC(lpdis
->hDC
);
249 hPrevBitmap
= SelectObject(hMemDC
, hBitmap
);
250 BitBlt(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
251 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
252 SelectObject(hMemDC
, hPrevBitmap
);
254 if (lpdis
->itemState
!= 0) {
255 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
259 if (lpdis
->CtlType
== ODT_COMBOBOX
&& lpdis
->CtlID
== cmb2
) {
260 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
261 SelectObject(lpdis
->hDC
, hBrush
);
262 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
263 SendMessage(lpdis
->hwndItem
, CB_GETLBTEXT
, lpdis
->itemID
,
273 GetObject(hBitmap
, sizeof(BITMAP
), (LPSTR
)&bm
);
274 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
275 lpdis
->rcItem
.top
, str
, strlen(str
));
276 hMemDC
= CreateCompatibleDC(lpdis
->hDC
);
277 hPrevBitmap
= SelectObject(hMemDC
, hBitmap
);
278 BitBlt(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
279 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
280 SelectObject(hMemDC
, hPrevBitmap
);
282 if (lpdis
->itemState
!= 0) {
283 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
290 /***********************************************************************
291 * FILEDLG_WMMeasureItem [internal]
293 static LONG
FILEDLG_WMMeasureItem(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
296 LPMEASUREITEMSTRUCT lpmeasure
;
298 GetObject(hFolder2
, sizeof(BITMAP
), (LPSTR
)&bm
);
299 lpmeasure
= (LPMEASUREITEMSTRUCT
)PTR_SEG_TO_LIN(lParam
);
300 lpmeasure
->itemHeight
= bm
.bmHeight
;
304 /***********************************************************************
305 * FILEDLG_WMInitDialog [internal]
308 static LONG
FILEDLG_WMInitDialog(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
311 LPOPENFILENAME lpofn
;
314 SetWindowLong(hWnd
, DWL_USER
, lParam
);
315 lpofn
= (LPOPENFILENAME
)lParam
;
316 /* read custom filter information */
317 if (lpofn
->lpstrCustomFilter
)
319 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
);
320 printf("lpstrCustomFilter = %p\n", pstr
);
324 strncpy(tmpstr
, pstr
, 511); tmpstr
[511]=0;
325 printf("lpstrCustomFilter // add tmpstr='%s' ", tmpstr
);
326 SendDlgItemMessage(hWnd
, cmb1
, CB_ADDSTRING
, 0, MAKE_SEGPTR(tmpstr
));
329 printf("associated to '%s'\n", pstr
);
333 /* read filter information */
334 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFilter
);
338 strncpy(tmpstr
, pstr
, 511); tmpstr
[511]=0;
339 printf("lpstrFilter // add tmpstr='%s' ", tmpstr
);
340 SendDlgItemMessage(hWnd
, cmb1
, CB_ADDSTRING
, 0, MAKE_SEGPTR(tmpstr
));
343 printf("associated to '%s'\n", pstr
);
346 /* set default filter */
347 if (lpofn
->nFilterIndex
== 0 && lpofn
->lpstrCustomFilter
== (SEGPTR
)NULL
)
348 lpofn
->nFilterIndex
= 1;
349 SendDlgItemMessage(hWnd
, cmb1
, CB_SETCURSEL
, lpofn
->nFilterIndex
- 1, 0);
350 strncpy(tmpstr
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
351 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
), lpofn
->nFilterIndex
- 1),511);
353 printf("nFilterIndex = %ld // SetText of edt1 to '%s'\n",
354 lpofn
->nFilterIndex
, tmpstr
);
355 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr
));
358 DlgDirListComboBox(hWnd
, MAKE_SEGPTR(tmpstr
), cmb2
, 0, 0xC000);
359 /* read initial directory */
360 if (PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
) != NULL
)
362 strncpy(tmpstr
, PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
), 510);
364 if (strlen(tmpstr
) > 0 && tmpstr
[strlen(tmpstr
)-1] != '\\'
365 && tmpstr
[strlen(tmpstr
)-1] != ':')
370 if (!FILEDLG_ScanDir(hWnd
, tmpstr
))
371 fprintf(stderr
, "FileDlg: couldn't read initial directory %s!\n", tmpstr
);
372 /* select current drive in combo 2 */
373 n
= DOS_GetDefaultDrive();
374 SendDlgItemMessage(hWnd
, cmb2
, CB_SETCURSEL
, n
, 0);
375 if (!(lpofn
->Flags
& OFN_SHOWHELP
))
376 ShowWindow(GetDlgItem(hWnd
, pshHelp
), SW_HIDE
);
377 if (lpofn
->Flags
& OFN_HIDEREADONLY
)
378 ShowWindow(GetDlgItem(hWnd
, chx1
), SW_HIDE
);
382 /***********************************************************************
383 * FILEDLG_WMCommand [internal]
385 static LRESULT
FILEDLG_WMCommand(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
388 LPOPENFILENAME lpofn
;
389 char tmpstr
[512], tmpstr2
[512];
392 lpofn
= (LPOPENFILENAME
)GetWindowLong(hWnd
, DWL_USER
);
395 case lst1
: /* file list */
396 FILEDLG_StripEditControl(hWnd
);
397 if (HIWORD(lParam
) == LBN_DBLCLK
)
399 lRet
= SendDlgItemMessage(hWnd
, lst1
, LB_GETCURSEL
, 0, 0);
400 if (lRet
== LB_ERR
) return TRUE
;
401 SendDlgItemMessage(hWnd
, lst1
, LB_GETTEXT
, lRet
,
402 MAKE_SEGPTR(tmpstr
));
403 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr
));
405 case lst2
: /* directory list */
406 FILEDLG_StripEditControl(hWnd
);
407 if (HIWORD(lParam
) == LBN_DBLCLK
)
409 lRet
= SendDlgItemMessage(hWnd
, lst2
, LB_GETCURSEL
, 0, 0);
410 if (lRet
== LB_ERR
) return TRUE
;
411 SendDlgItemMessage(hWnd
, lst2
, LB_GETTEXT
, lRet
,
412 MAKE_SEGPTR(tmpstr
));
413 if (tmpstr
[0] == '[')
415 tmpstr
[strlen(tmpstr
) - 1] = 0;
416 strcpy(tmpstr
,tmpstr
+1);
418 strcat(tmpstr
, "\\");
422 case cmb1
: /* file type drop list */
423 if (HIWORD(lParam
) == CBN_SELCHANGE
)
429 case cmb2
: /* disk drop list */
430 FILEDLG_StripEditControl(hWnd
);
431 lRet
= SendDlgItemMessage(hWnd
, cmb2
, CB_GETCURSEL
, 0, 0L);
432 if (lRet
== LB_ERR
) return 0;
433 SendDlgItemMessage(hWnd
, cmb2
, CB_GETLBTEXT
, lRet
, MAKE_SEGPTR(tmpstr
));
434 sprintf(tmpstr
, "%c:", tmpstr
[2]);
436 lRet
= SendDlgItemMessage(hWnd
, cmb1
, CB_GETCURSEL
, 0, 0);
439 pstr
= FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
440 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
442 strncpy(tmpstr2
, pstr
, 511); tmpstr2
[511]=0;
443 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
444 FILEDLG_ScanDir(hWnd
, tmpstr
);
452 SendDlgItemMessage(hWnd
, edt1
, WM_GETTEXT
, 511, MAKE_SEGPTR(tmpstr
));
453 pstr
= strrchr(tmpstr
, '\\');
455 pstr
= strrchr(tmpstr
, ':');
456 if (strchr(tmpstr
,'*') != NULL
|| strchr(tmpstr
,'?') != NULL
)
458 /* edit control contains wildcards */
461 strncpy(tmpstr2
, pstr
+1, 511); tmpstr2
[511]=0;
466 strcpy(tmpstr2
, tmpstr
);
469 printf("commdlg: %s, %s\n", tmpstr
, tmpstr2
);
470 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
471 FILEDLG_ScanDir(hWnd
, tmpstr
);
474 /* no wildcards, we might have a directory or a filename */
475 /* try appending a wildcard and reading the directory */
476 pstr2
= tmpstr
+ strlen(tmpstr
);
477 if (pstr
== NULL
|| *(pstr
+1) != 0)
478 strcat(tmpstr
, "\\");
479 lRet
= SendDlgItemMessage(hWnd
, cmb1
, CB_GETCURSEL
, 0, 0);
480 if (lRet
== LB_ERR
) return TRUE
;
481 lpofn
->nFilterIndex
= lRet
+ 1;
482 printf("commdlg: lpofn->nFilterIndex=%ld\n", lpofn
->nFilterIndex
);
484 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
485 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
488 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
489 /* if ScanDir succeeds, we have changed the directory */
490 if (FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
491 /* if not, this must be a filename */
495 /* strip off the pathname */
497 strncpy(tmpstr2
, pstr
+1, 511); tmpstr2
[511]=0;
498 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
499 /* Should we MessageBox() if this fails? */
500 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
501 strcpy(tmpstr
, tmpstr2
);
504 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr
));
505 ShowWindow(hWnd
, SW_HIDE
);
508 drive
= DOS_GetDefaultDrive();
509 tmpstr2
[0] = 'A'+ drive
;
512 strncpy(tmpstr2
+ 3, DOS_GetCurrentDir(drive
), 507); tmpstr2
[510]=0;
513 if (strlen(tmpstr2
) > 3)
514 strcat(tmpstr2
, "\\");
515 strncat(tmpstr2
, tmpstr
, 511-strlen(tmpstr2
)); tmpstr2
[511]=0;
516 strcpy(PTR_SEG_TO_LIN(lpofn
->lpstrFile
), tmpstr2
);
518 lpofn
->nFileOffset
= 0;
519 lpofn
->nFileExtension
= 0;
520 while(tmpstr2
[lpofn
->nFileExtension
] != '.' && tmpstr2
[lpofn
->nFileExtension
] != '\0')
521 lpofn
->nFileExtension
++;
522 if (lpofn
->nFileExtension
== '\0')
523 lpofn
->nFileExtension
= 0;
525 lpofn
->nFileExtension
++;
526 if (PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
) != NULL
)
528 lRet
= SendDlgItemMessage(hWnd
, lst1
, LB_GETCURSEL
, 0, 0);
529 SendDlgItemMessage(hWnd
, lst1
, LB_GETTEXT
, lRet
,
530 MAKE_SEGPTR(tmpstr
));
531 printf("strcpy'ing '%s'\n",tmpstr
); fflush(stdout
);
532 strcpy(PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
), tmpstr
);
534 EndDialog(hWnd
, TRUE
);
537 EndDialog(hWnd
, FALSE
);
544 /***********************************************************************
545 * FileOpenDlgProc (COMMDLG.6)
547 LRESULT
FileOpenDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
552 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
554 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
556 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
);
558 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
561 SetBkColor((HDC
)wParam
, 0x00C0C0C0);
562 switch (HIWORD(lParam
))
565 SetTextColor((HDC
)wParam
, 0x00000000);
567 case CTLCOLOR_STATIC
:
568 SetTextColor((HDC
)wParam
, 0x00000000);
578 /***********************************************************************
579 * FileSaveDlgProc (COMMDLG.7)
581 LRESULT
FileSaveDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
585 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
588 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
591 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
);
594 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
599 SetBkColor((HDC)wParam, 0x00C0C0C0);
600 switch (HIWORD(lParam))
603 SetTextColor((HDC)wParam, 0x00000000);
605 case CTLCOLOR_STATIC:
606 SetTextColor((HDC)wParam, 0x00000000);
616 /***********************************************************************
617 * ChooseColor (COMMDLG.5)
619 BOOL
ChooseColor(LPCHOOSECOLOR lpChCol
)
621 HANDLE hInst
, hDlgTmpl
;
624 hDlgTmpl
= GLOBAL_CreateBlock(GMEM_FIXED
, sysres_DIALOG_CHOOSE_COLOR
.bytes
,
625 sysres_DIALOG_CHOOSE_COLOR
.size
,
626 GetCurrentPDB(), FALSE
, FALSE
, TRUE
, NULL
);
627 hInst
= WIN_GetWindowInstance( lpChCol
->hwndOwner
);
628 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpChCol
->hwndOwner
,
629 GetWndProcEntry16("ColorDlgProc"),
631 GLOBAL_FreeBlock( hDlgTmpl
);
636 /***********************************************************************
637 * ColorDlgProc (COMMDLG.8)
639 LRESULT
ColorDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
644 printf("ColorDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
645 ShowWindow(hWnd
, SW_SHOWNORMAL
);
651 EndDialog(hWnd
, TRUE
);
654 EndDialog(hWnd
, FALSE
);
663 /***********************************************************************
664 * FindTextDlg (COMMDLG.11)
666 BOOL
FindText(LPFINDREPLACE lpFind
)
668 HANDLE hInst
, hDlgTmpl
;
671 hDlgTmpl
= GLOBAL_CreateBlock(GMEM_FIXED
, sysres_DIALOG_FIND_TEXT
.bytes
,
672 sysres_DIALOG_FIND_TEXT
.size
,
673 GetCurrentPDB(), FALSE
, FALSE
, TRUE
, NULL
);
674 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
675 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpFind
->hwndOwner
,
676 GetWndProcEntry16("FindTextDlgProc"),
678 GLOBAL_FreeBlock( hDlgTmpl
);
683 /***********************************************************************
684 * ReplaceTextDlg (COMMDLG.12)
686 BOOL
ReplaceText(LPFINDREPLACE lpFind
)
688 HANDLE hInst
, hDlgTmpl
;
691 hDlgTmpl
= GLOBAL_CreateBlock(GMEM_FIXED
, sysres_DIALOG_REPLACE_TEXT
.bytes
,
692 sysres_DIALOG_REPLACE_TEXT
.size
,
693 GetCurrentPDB(), FALSE
, FALSE
, TRUE
, NULL
);
694 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
695 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpFind
->hwndOwner
,
696 GetWndProcEntry16("ReplaceTextDlgProc"),
698 GLOBAL_FreeBlock( hDlgTmpl
);
703 /***********************************************************************
704 * FindTextDlgProc (COMMDLG.13)
706 LRESULT
FindTextDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
711 printf("FindTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
712 ShowWindow(hWnd
, SW_SHOWNORMAL
);
718 EndDialog(hWnd
, TRUE
);
721 EndDialog(hWnd
, FALSE
);
730 /***********************************************************************
731 * ReplaceTextDlgProc (COMMDLG.14)
733 LRESULT
ReplaceTextDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
738 printf("ReplaceTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
739 ShowWindow(hWnd
, SW_SHOWNORMAL
);
745 EndDialog(hWnd
, TRUE
);
748 EndDialog(hWnd
, FALSE
);
757 /***********************************************************************
758 * PrintDlg (COMMDLG.20)
760 BOOL
PrintDlg(LPPRINTDLG lpPrint
)
762 HANDLE hInst
, hDlgTmpl
;
765 printf("PrintDlg(%p) // Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
767 if (lpPrint
->Flags
& PD_RETURNDEFAULT
)
768 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
771 if (lpPrint
->Flags
& PD_PRINTSETUP
)
772 hDlgTmpl
= GLOBAL_CreateBlock( GMEM_FIXED
,
773 sysres_DIALOG_PRINT_SETUP
.bytes
,
774 sysres_DIALOG_PRINT_SETUP
.size
,
775 GetCurrentPDB(), FALSE
,
778 hDlgTmpl
= GLOBAL_CreateBlock( GMEM_FIXED
, sysres_DIALOG_PRINT
.bytes
,
779 sysres_DIALOG_PRINT
.size
,
780 GetCurrentPDB(), FALSE
,
783 hInst
= WIN_GetWindowInstance( lpPrint
->hwndOwner
);
784 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpPrint
->hwndOwner
,
785 (lpPrint
->Flags
& PD_PRINTSETUP
) ?
786 GetWndProcEntry16("PrintSetupDlgProc") :
787 GetWndProcEntry16("PrintDlgProc"),
789 GLOBAL_FreeBlock( hDlgTmpl
);
794 /***********************************************************************
795 * PrintDlgProc (COMMDLG.21)
797 LRESULT
PrintDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
802 printf("PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
803 ShowWindow(hWnd
, SW_SHOWNORMAL
);
809 EndDialog(hWnd
, TRUE
);
812 EndDialog(hWnd
, FALSE
);
821 /***********************************************************************
822 * PrintSetupDlgProc (COMMDLG.22)
824 LRESULT
PrintSetupDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
829 printf("PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
830 ShowWindow(hWnd
, SW_SHOWNORMAL
);
835 EndDialog(hWnd
, TRUE
);
838 EndDialog(hWnd
, FALSE
);
847 /***********************************************************************
848 * CommDlgExtendError (COMMDLG.26)
850 DWORD
CommDlgExtendError(void)
852 return CommDlgLastError
;
856 /***********************************************************************
857 * GetFileTitle (COMMDLG.27)
859 int GetFileTitle(LPCSTR lpFile
, LPSTR lpTitle
, UINT cbBuf
)
862 printf("GetFileTitle(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
863 if (lpFile
== NULL
|| lpTitle
== NULL
)
865 len
= strlen(lpFile
);
868 if (strpbrk(lpFile
, "*[]"))
871 if (lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
873 for (i
= len
; i
>= 0; i
--)
874 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
879 printf("\n---> '%s' ", &lpFile
[i
]);
880 len
= MIN(cbBuf
, strlen(&lpFile
[i
]) + 1);
881 strncpy(lpTitle
, &lpFile
[i
], len
+ 1);