4 * Copyright 1994 Martin Ayotte
15 #include "selectors.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
= SYSRES_LoadResource( SYSRES_DIALOG_OPEN_FILE
);
78 CommDlgLastError
= CDERR_LOADRESFAILURE
;
82 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
83 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpofn
->hwndOwner
,
84 GetWndProcEntry16("FileOpenDlgProc"),
87 if (!(lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
))
89 if (lpofn
->Flags
& OFN_ENABLETEMPLATE
) FreeResource( hDlgTmpl
);
90 else SYSRES_FreeResource( hDlgTmpl
);
93 printf("GetOpenFileName // return lpstrFile='%s' !\n",
94 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
99 /***********************************************************************
100 * GetSaveFileName (COMMDLG.2)
102 BOOL
GetSaveFileName(LPOPENFILENAME lpofn
)
105 HANDLE hDlgTmpl
, hResInfo
;
108 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
110 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
) hDlgTmpl
= lpofn
->hInstance
;
111 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
113 hInst
= lpofn
->hInstance
;
114 if (!(hResInfo
= FindResource( lpofn
->hInstance
,
115 lpofn
->lpTemplateName
, RT_DIALOG
)))
117 CommDlgLastError
= CDERR_FINDRESFAILURE
;
120 hDlgTmpl
= LoadResource( lpofn
->hInstance
, hResInfo
);
122 else hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_SAVE_FILE
);
124 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
125 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpofn
->hwndOwner
,
126 GetWndProcEntry16("FileSaveDlgProc"),
128 if (!(lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
))
130 if (lpofn
->Flags
& OFN_ENABLETEMPLATE
) FreeResource( hDlgTmpl
);
131 else SYSRES_FreeResource( hDlgTmpl
);
134 printf( "GetSaveFileName // return lpstrFile='%s' !\n",
135 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
139 /***********************************************************************
140 * FILEDLG_StripEditControl [internal]
141 * Strip pathnames off the contents of the edit control.
143 static void FILEDLG_StripEditControl(HWND hwnd
)
147 SendDlgItemMessage(hwnd
, edt1
, WM_GETTEXT
, 511, (LPARAM
)MAKE_SEGPTR(temp
));
148 cp
= strrchr(temp
, '\\');
152 cp
= strrchr(temp
, ':');
158 /***********************************************************************
159 * FILEDLG_ScanDir [internal]
161 static BOOL
FILEDLG_ScanDir(HWND hWnd
, LPSTR newPath
)
163 char str
[512],str2
[512];
165 strncpy(str
,newPath
,511); str
[511]=0;
166 SendDlgItemMessage(hWnd
, edt1
, WM_GETTEXT
, 511, (LPARAM
)MAKE_SEGPTR(str2
));
167 strncat(str
,str2
,511-strlen(str
)); str
[511]=0;
168 if (!DlgDirList(hWnd
, MAKE_SEGPTR(str
), lst1
, 0, 0x0000)) return FALSE
;
169 strcpy( str
, "*.*" );
170 DlgDirList(hWnd
, MAKE_SEGPTR(str
), lst2
, stc1
, 0x8010);
174 /***********************************************************************
175 * FILEDLG_GetFileType [internal]
178 static LPSTR
FILEDLG_GetFileType(LPSTR cfptr
, LPSTR fptr
, WORD index
)
183 for ( ;(n
= strlen(cfptr
)) != 0; i
++)
188 cfptr
+= strlen(cfptr
) + 1;
191 for ( ;(n
= strlen(fptr
)) != 0; i
++)
196 fptr
+= strlen(fptr
) + 1;
201 /***********************************************************************
202 * FILEDLG_WMDrawItem [internal]
204 static LONG
FILEDLG_WMDrawItem(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
206 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)PTR_SEG_TO_LIN(lParam
);
209 HBITMAP hBitmap
, hPrevBitmap
;
214 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst1
) {
215 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
216 SelectObject(lpdis
->hDC
, hBrush
);
217 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
218 SendMessage(lpdis
->hwndItem
, LB_GETTEXT
, lpdis
->itemID
,
219 (LPARAM
)MAKE_SEGPTR(str
));
220 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
222 if (lpdis
->itemState
!= 0) {
223 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
228 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst2
) {
229 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
230 SelectObject(lpdis
->hDC
, hBrush
);
231 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
232 SendMessage(lpdis
->hwndItem
, LB_GETTEXT
, lpdis
->itemID
,
233 (LPARAM
)MAKE_SEGPTR(str
));
236 GetObject(hBitmap
, sizeof(BITMAP
), (LPSTR
)&bm
);
237 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
238 lpdis
->rcItem
.top
, str
, strlen(str
));
239 hMemDC
= CreateCompatibleDC(lpdis
->hDC
);
240 hPrevBitmap
= SelectObject(hMemDC
, hBitmap
);
241 BitBlt(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
242 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
243 SelectObject(hMemDC
, hPrevBitmap
);
245 if (lpdis
->itemState
!= 0) {
246 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
250 if (lpdis
->CtlType
== ODT_COMBOBOX
&& lpdis
->CtlID
== cmb2
) {
251 hBrush
= SelectObject(lpdis
->hDC
, GetStockObject(LTGRAY_BRUSH
));
252 SelectObject(lpdis
->hDC
, hBrush
);
253 FillRect(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
254 SendMessage(lpdis
->hwndItem
, CB_GETLBTEXT
, lpdis
->itemID
,
255 (LPARAM
)MAKE_SEGPTR(str
));
264 GetObject(hBitmap
, sizeof(BITMAP
), (LPSTR
)&bm
);
265 TextOut(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
266 lpdis
->rcItem
.top
, str
, strlen(str
));
267 hMemDC
= CreateCompatibleDC(lpdis
->hDC
);
268 hPrevBitmap
= SelectObject(hMemDC
, hBitmap
);
269 BitBlt(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
270 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
271 SelectObject(hMemDC
, hPrevBitmap
);
273 if (lpdis
->itemState
!= 0) {
274 InvertRect(lpdis
->hDC
, &lpdis
->rcItem
);
281 /***********************************************************************
282 * FILEDLG_WMMeasureItem [internal]
284 static LONG
FILEDLG_WMMeasureItem(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
287 LPMEASUREITEMSTRUCT lpmeasure
;
289 GetObject(hFolder2
, sizeof(BITMAP
), (LPSTR
)&bm
);
290 lpmeasure
= (LPMEASUREITEMSTRUCT
)PTR_SEG_TO_LIN(lParam
);
291 lpmeasure
->itemHeight
= bm
.bmHeight
;
295 /***********************************************************************
296 * FILEDLG_WMInitDialog [internal]
299 static LONG
FILEDLG_WMInitDialog(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
302 LPOPENFILENAME lpofn
;
305 SetWindowLong(hWnd
, DWL_USER
, lParam
);
306 lpofn
= (LPOPENFILENAME
)lParam
;
307 /* read custom filter information */
308 if (lpofn
->lpstrCustomFilter
)
310 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
);
311 printf("lpstrCustomFilter = %p\n", pstr
);
315 strncpy(tmpstr
, pstr
, 511); tmpstr
[511]=0;
316 printf("lpstrCustomFilter // add tmpstr='%s' ", tmpstr
);
317 SendDlgItemMessage(hWnd
, cmb1
, CB_ADDSTRING
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr
));
320 printf("associated to '%s'\n", pstr
);
324 /* read filter information */
325 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFilter
);
329 strncpy(tmpstr
, pstr
, 511); tmpstr
[511]=0;
330 printf("lpstrFilter // add tmpstr='%s' ", tmpstr
);
331 SendDlgItemMessage(hWnd
, cmb1
, CB_ADDSTRING
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr
));
334 printf("associated to '%s'\n", pstr
);
337 /* set default filter */
338 if (lpofn
->nFilterIndex
== 0 && lpofn
->lpstrCustomFilter
== (SEGPTR
)NULL
)
339 lpofn
->nFilterIndex
= 1;
340 SendDlgItemMessage(hWnd
, cmb1
, CB_SETCURSEL
, lpofn
->nFilterIndex
- 1, 0);
341 strncpy(tmpstr
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
342 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
), lpofn
->nFilterIndex
- 1),511);
344 printf("nFilterIndex = %ld // SetText of edt1 to '%s'\n",
345 lpofn
->nFilterIndex
, tmpstr
);
346 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr
));
349 DlgDirListComboBox(hWnd
, MAKE_SEGPTR(tmpstr
), cmb2
, 0, 0xC000);
350 /* read initial directory */
351 if (PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
) != NULL
)
353 strncpy(tmpstr
, PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
), 510);
355 if (strlen(tmpstr
) > 0 && tmpstr
[strlen(tmpstr
)-1] != '\\'
356 && tmpstr
[strlen(tmpstr
)-1] != ':')
361 if (!FILEDLG_ScanDir(hWnd
, tmpstr
))
362 fprintf(stderr
, "FileDlg: couldn't read initial directory %s!\n", tmpstr
);
363 /* select current drive in combo 2 */
364 n
= DRIVE_GetCurrentDrive();
365 SendDlgItemMessage(hWnd
, cmb2
, CB_SETCURSEL
, n
, 0);
366 if (!(lpofn
->Flags
& OFN_SHOWHELP
))
367 ShowWindow(GetDlgItem(hWnd
, pshHelp
), SW_HIDE
);
368 if (lpofn
->Flags
& OFN_HIDEREADONLY
)
369 ShowWindow(GetDlgItem(hWnd
, chx1
), SW_HIDE
);
373 /***********************************************************************
374 * FILEDLG_WMCommand [internal]
376 static LRESULT
FILEDLG_WMCommand(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
379 LPOPENFILENAME lpofn
;
380 char tmpstr
[512], tmpstr2
[512];
382 UINT control
,notification
;
384 /* Notifications are packaged differently in Win32 */
386 control
= LOWORD(wParam
);
387 notification
= HIWORD(wParam
);
390 notification
= HIWORD(lParam
);
393 lpofn
= (LPOPENFILENAME
)GetWindowLong(hWnd
, DWL_USER
);
396 case lst1
: /* file list */
397 FILEDLG_StripEditControl(hWnd
);
398 if (notification
== LBN_DBLCLK
)
400 lRet
= SendDlgItemMessage(hWnd
, lst1
, LB_GETCURSEL
, 0, 0);
401 if (lRet
== LB_ERR
) return TRUE
;
402 SendDlgItemMessage(hWnd
, lst1
, LB_GETTEXT
, lRet
,
403 (LPARAM
)MAKE_SEGPTR(tmpstr
));
404 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr
));
406 case lst2
: /* directory list */
407 FILEDLG_StripEditControl(hWnd
);
408 if (notification
== LBN_DBLCLK
)
410 lRet
= SendDlgItemMessage(hWnd
, lst2
, LB_GETCURSEL
, 0, 0);
411 if (lRet
== LB_ERR
) return TRUE
;
412 SendDlgItemMessage(hWnd
, lst2
, LB_GETTEXT
, lRet
,
413 (LPARAM
)MAKE_SEGPTR(tmpstr
));
414 if (tmpstr
[0] == '[')
416 tmpstr
[strlen(tmpstr
) - 1] = 0;
417 strcpy(tmpstr
,tmpstr
+1);
419 strcat(tmpstr
, "\\");
423 case cmb1
: /* file type drop list */
424 if (notification
== CBN_SELCHANGE
)
430 case cmb2
: /* disk drop list */
431 FILEDLG_StripEditControl(hWnd
);
432 lRet
= SendDlgItemMessage(hWnd
, cmb2
, CB_GETCURSEL
, 0, 0L);
433 if (lRet
== LB_ERR
) return 0;
434 SendDlgItemMessage(hWnd
, cmb2
, CB_GETLBTEXT
, lRet
, (LPARAM
)MAKE_SEGPTR(tmpstr
));
435 sprintf(tmpstr
, "%c:", tmpstr
[2]);
437 lRet
= SendDlgItemMessage(hWnd
, cmb1
, CB_GETCURSEL
, 0, 0);
440 pstr
= FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
441 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
443 strncpy(tmpstr2
, pstr
, 511); tmpstr2
[511]=0;
444 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr2
));
445 FILEDLG_ScanDir(hWnd
, tmpstr
);
453 SendDlgItemMessage(hWnd
, edt1
, WM_GETTEXT
, 511, (LPARAM
)MAKE_SEGPTR(tmpstr
));
454 pstr
= strrchr(tmpstr
, '\\');
456 pstr
= strrchr(tmpstr
, ':');
457 if (strchr(tmpstr
,'*') != NULL
|| strchr(tmpstr
,'?') != NULL
)
459 /* edit control contains wildcards */
462 strncpy(tmpstr2
, pstr
+1, 511); tmpstr2
[511]=0;
467 strcpy(tmpstr2
, tmpstr
);
470 printf("commdlg: %s, %s\n", tmpstr
, tmpstr2
);
471 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr2
));
472 FILEDLG_ScanDir(hWnd
, tmpstr
);
475 /* no wildcards, we might have a directory or a filename */
476 /* try appending a wildcard and reading the directory */
477 pstr2
= tmpstr
+ strlen(tmpstr
);
478 if (pstr
== NULL
|| *(pstr
+1) != 0)
479 strcat(tmpstr
, "\\");
480 lRet
= SendDlgItemMessage(hWnd
, cmb1
, CB_GETCURSEL
, 0, 0);
481 if (lRet
== LB_ERR
) return TRUE
;
482 lpofn
->nFilterIndex
= lRet
+ 1;
483 printf("commdlg: lpofn->nFilterIndex=%ld\n", lpofn
->nFilterIndex
);
485 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
486 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
489 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr2
));
490 /* if ScanDir succeeds, we have changed the directory */
491 if (FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
492 /* if not, this must be a filename */
496 /* strip off the pathname */
498 strncpy(tmpstr2
, pstr
+1, 511); tmpstr2
[511]=0;
499 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr2
));
500 /* Should we MessageBox() if this fails? */
501 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
502 strcpy(tmpstr
, tmpstr2
);
505 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, (LPARAM
)MAKE_SEGPTR(tmpstr
));
506 ShowWindow(hWnd
, SW_HIDE
);
508 int drive
= DRIVE_GetCurrentDrive();
509 tmpstr2
[0] = 'A'+ drive
;
512 strncpy(tmpstr2
+ 3, DRIVE_GetDosCwd(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 (LPARAM
)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
= SYSRES_LoadResource( SYSRES_DIALOG_CHOOSE_COLOR
);
625 hInst
= WIN_GetWindowInstance( lpChCol
->hwndOwner
);
626 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpChCol
->hwndOwner
,
627 GetWndProcEntry16("ColorDlgProc"),
629 SYSRES_FreeResource( hDlgTmpl
);
634 /***********************************************************************
635 * ColorDlgProc (COMMDLG.8)
637 LRESULT
ColorDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
642 printf("ColorDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
643 ShowWindow(hWnd
, SW_SHOWNORMAL
);
649 EndDialog(hWnd
, TRUE
);
652 EndDialog(hWnd
, FALSE
);
661 /***********************************************************************
662 * FindTextDlg (COMMDLG.11)
664 BOOL
FindText(LPFINDREPLACE lpFind
)
666 HANDLE hInst
, hDlgTmpl
;
669 hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_FIND_TEXT
);
670 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
671 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpFind
->hwndOwner
,
672 GetWndProcEntry16("FindTextDlgProc"),
674 SYSRES_FreeResource( hDlgTmpl
);
679 /***********************************************************************
680 * ReplaceTextDlg (COMMDLG.12)
682 BOOL
ReplaceText(LPFINDREPLACE lpFind
)
684 HANDLE hInst
, hDlgTmpl
;
687 hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_REPLACE_TEXT
);
688 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
689 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpFind
->hwndOwner
,
690 GetWndProcEntry16("ReplaceTextDlgProc"),
692 SYSRES_FreeResource( hDlgTmpl
);
697 /***********************************************************************
698 * FindTextDlgProc (COMMDLG.13)
700 LRESULT
FindTextDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
705 printf("FindTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
706 ShowWindow(hWnd
, SW_SHOWNORMAL
);
712 EndDialog(hWnd
, TRUE
);
715 EndDialog(hWnd
, FALSE
);
724 /***********************************************************************
725 * ReplaceTextDlgProc (COMMDLG.14)
727 LRESULT
ReplaceTextDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
732 printf("ReplaceTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
733 ShowWindow(hWnd
, SW_SHOWNORMAL
);
739 EndDialog(hWnd
, TRUE
);
742 EndDialog(hWnd
, FALSE
);
751 /***********************************************************************
752 * PrintDlg (COMMDLG.20)
754 BOOL
PrintDlg(LPPRINTDLG lpPrint
)
756 HANDLE hInst
, hDlgTmpl
;
759 printf("PrintDlg(%p) // Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
761 if (lpPrint
->Flags
& PD_RETURNDEFAULT
)
762 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
765 if (lpPrint
->Flags
& PD_PRINTSETUP
)
766 hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_PRINT_SETUP
);
768 hDlgTmpl
= SYSRES_LoadResource( SYSRES_DIALOG_PRINT
);
770 hInst
= WIN_GetWindowInstance( lpPrint
->hwndOwner
);
771 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpPrint
->hwndOwner
,
772 (lpPrint
->Flags
& PD_PRINTSETUP
) ?
773 GetWndProcEntry16("PrintSetupDlgProc") :
774 GetWndProcEntry16("PrintDlgProc"),
776 SYSRES_FreeResource( hDlgTmpl
);
781 /***********************************************************************
782 * PrintDlgProc (COMMDLG.21)
784 LRESULT
PrintDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
789 printf("PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
790 ShowWindow(hWnd
, SW_SHOWNORMAL
);
796 EndDialog(hWnd
, TRUE
);
799 EndDialog(hWnd
, FALSE
);
808 /***********************************************************************
809 * PrintSetupDlgProc (COMMDLG.22)
811 LRESULT
PrintSetupDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
816 printf("PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
817 ShowWindow(hWnd
, SW_SHOWNORMAL
);
822 EndDialog(hWnd
, TRUE
);
825 EndDialog(hWnd
, FALSE
);
834 /***********************************************************************
835 * CommDlgExtendedError (COMMDLG.26)
837 DWORD
CommDlgExtendedError(void)
839 return CommDlgLastError
;
843 /***********************************************************************
844 * GetFileTitle (COMMDLG.27)
846 short GetFileTitle(LPCSTR lpFile
, LPSTR lpTitle
, UINT cbBuf
)
849 printf("GetFileTitle(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
850 if (lpFile
== NULL
|| lpTitle
== NULL
)
852 len
= strlen(lpFile
);
855 if (strpbrk(lpFile
, "*[]"))
858 if (lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
860 for (i
= len
; i
>= 0; i
--)
861 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
866 printf("\n---> '%s' ", &lpFile
[i
]);
868 len
= strlen(lpFile
+i
)+1;
872 strncpy(lpTitle
, &lpFile
[i
], len
);