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];
175 SendDlgItemMessage(hWnd
, edt1
, WM_GETTEXT
, 511, MAKE_SEGPTR(str2
));
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
, WORD wParam
, LONG 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
, WORD wParam
, LONG 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
, WORD wParam
, LONG 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 strcpy(tmpstr
, pstr
);
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 strcpy(tmpstr
, pstr
);
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 strcpy(tmpstr
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
351 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
), lpofn
->nFilterIndex
- 1));
352 printf("nFilterIndex = %ld // SetText of edt1 to '%s'\n",
353 lpofn
->nFilterIndex
, tmpstr
);
354 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr
));
357 DlgDirListComboBox(hWnd
, MAKE_SEGPTR(tmpstr
), cmb2
, 0, 0xC000);
358 /* read initial directory */
359 if (PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
) != NULL
)
361 strcpy(tmpstr
, PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
));
362 if (strlen(tmpstr
) > 0 && tmpstr
[strlen(tmpstr
)-1] != '\\'
363 && tmpstr
[strlen(tmpstr
)-1] != ':')
368 if (!FILEDLG_ScanDir(hWnd
, tmpstr
))
369 fprintf(stderr
, "FileDlg: couldn't read initial directory %s!\n", tmpstr
);
370 /* select current drive in combo 2 */
371 n
= DOS_GetDefaultDrive();
372 SendDlgItemMessage(hWnd
, cmb2
, CB_SETCURSEL
, n
, 0);
373 if (!(lpofn
->Flags
& OFN_SHOWHELP
))
374 ShowWindow(GetDlgItem(hWnd
, pshHelp
), SW_HIDE
);
375 if (lpofn
->Flags
& OFN_HIDEREADONLY
)
376 ShowWindow(GetDlgItem(hWnd
, chx1
), SW_HIDE
);
380 /***********************************************************************
381 * FILEDLG_WMCommand [internal]
383 static LONG
FILEDLG_WMCommand(HWND hWnd
, WORD wParam
, LONG lParam
)
386 LPOPENFILENAME lpofn
;
387 char tmpstr
[512], tmpstr2
[512];
390 lpofn
= (LPOPENFILENAME
)GetWindowLong(hWnd
, DWL_USER
);
393 case lst1
: /* file list */
394 FILEDLG_StripEditControl(hWnd
);
395 if (HIWORD(lParam
) == LBN_DBLCLK
)
397 lRet
= SendDlgItemMessage(hWnd
, lst1
, LB_GETCURSEL
, 0, 0);
398 if (lRet
== LB_ERR
) return TRUE
;
399 SendDlgItemMessage(hWnd
, lst1
, LB_GETTEXT
, lRet
,
400 MAKE_SEGPTR(tmpstr
));
401 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr
));
403 case lst2
: /* directory list */
404 FILEDLG_StripEditControl(hWnd
);
405 if (HIWORD(lParam
) == LBN_DBLCLK
)
407 lRet
= SendDlgItemMessage(hWnd
, lst2
, LB_GETCURSEL
, 0, 0);
408 if (lRet
== LB_ERR
) return TRUE
;
409 SendDlgItemMessage(hWnd
, lst2
, LB_GETTEXT
, lRet
,
410 MAKE_SEGPTR(tmpstr
));
411 if (tmpstr
[0] == '[')
413 tmpstr
[strlen(tmpstr
) - 1] = 0;
414 strcpy(tmpstr
,tmpstr
+1);
416 strcat(tmpstr
, "\\");
420 case cmb1
: /* file type drop list */
421 if (HIWORD(lParam
) == CBN_SELCHANGE
)
427 case cmb2
: /* disk drop list */
428 FILEDLG_StripEditControl(hWnd
);
429 lRet
= SendDlgItemMessage(hWnd
, cmb2
, CB_GETCURSEL
, 0, 0L);
430 if (lRet
== LB_ERR
) return 0;
431 SendDlgItemMessage(hWnd
, cmb2
, CB_GETLBTEXT
, lRet
, MAKE_SEGPTR(tmpstr
));
432 sprintf(tmpstr
, "%c:", tmpstr
[2]);
434 lRet
= SendDlgItemMessage(hWnd
, cmb1
, CB_GETCURSEL
, 0, 0);
437 pstr
= FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
438 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
440 strcpy(tmpstr2
, pstr
);
441 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
442 FILEDLG_ScanDir(hWnd
, tmpstr
);
450 SendDlgItemMessage(hWnd
, edt1
, WM_GETTEXT
, 511, MAKE_SEGPTR(tmpstr
));
451 pstr
= strrchr(tmpstr
, '\\');
453 pstr
= strrchr(tmpstr
, ':');
454 if (strchr(tmpstr
,'*') != NULL
|| strchr(tmpstr
,'?') != NULL
)
456 /* edit control contains wildcards */
459 strcpy(tmpstr2
, pstr
+1);
464 strcpy(tmpstr2
, tmpstr
);
467 printf("commdlg: %s, %s\n", tmpstr
, tmpstr2
);
468 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
469 FILEDLG_ScanDir(hWnd
, tmpstr
);
472 /* no wildcards, we might have a directory or a filename */
473 /* try appending a wildcard and reading the directory */
474 pstr2
= tmpstr
+ strlen(tmpstr
);
475 if (pstr
== NULL
|| *(pstr
+1) != 0)
476 strcat(tmpstr
, "\\");
477 lRet
= SendDlgItemMessage(hWnd
, cmb1
, CB_GETCURSEL
, 0, 0);
478 if (lRet
== LB_ERR
) return TRUE
;
479 lpofn
->nFilterIndex
= lRet
+ 1;
480 printf("commdlg: lpofn->nFilterIndex=%ld\n", lpofn
->nFilterIndex
);
482 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
483 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
485 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
486 /* if ScanDir succeeds, we have changed the directory */
487 if (FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
488 /* if not, this must be a filename */
492 /* strip off the pathname */
494 strcpy(tmpstr2
, pstr
+1);
495 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr2
));
496 /* Should we MessageBox() if this fails? */
497 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
498 strcpy(tmpstr
, tmpstr2
);
501 SendDlgItemMessage(hWnd
, edt1
, WM_SETTEXT
, 0, MAKE_SEGPTR(tmpstr
));
502 ShowWindow(hWnd
, SW_HIDE
);
505 drive
= DOS_GetDefaultDrive();
506 tmpstr2
[0] = 'A'+ drive
;
509 strcpy(tmpstr2
+ 3, DOS_GetCurrentDir(drive
));
510 if (strlen(tmpstr2
) > 3)
511 strcat(tmpstr2
, "\\");
512 strcat(tmpstr2
, tmpstr
);
513 strcpy(PTR_SEG_TO_LIN(lpofn
->lpstrFile
), tmpstr2
);
515 lpofn
->nFileOffset
= 0;
516 lpofn
->nFileExtension
= 0;
517 while(tmpstr2
[lpofn
->nFileExtension
] != '.' && tmpstr2
[lpofn
->nFileExtension
] != '\0')
518 lpofn
->nFileExtension
++;
519 if (lpofn
->nFileExtension
== '\0')
520 lpofn
->nFileExtension
= 0;
522 lpofn
->nFileExtension
++;
523 if (PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
) != NULL
)
525 lRet
= SendDlgItemMessage(hWnd
, lst1
, LB_GETCURSEL
, 0, 0);
526 SendDlgItemMessage(hWnd
, lst1
, LB_GETTEXT
, lRet
,
527 MAKE_SEGPTR(tmpstr
));
528 strcpy(PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
), tmpstr
);
530 EndDialog(hWnd
, TRUE
);
533 EndDialog(hWnd
, FALSE
);
540 /***********************************************************************
541 * FileOpenDlgProc (COMMDLG.6)
543 LRESULT
FileOpenDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
548 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
550 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
552 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
);
554 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
557 SetBkColor((HDC
)wParam
, 0x00C0C0C0);
558 switch (HIWORD(lParam
))
561 SetTextColor((HDC
)wParam
, 0x00000000);
563 case CTLCOLOR_STATIC
:
564 SetTextColor((HDC
)wParam
, 0x00000000);
574 /***********************************************************************
575 * FileSaveDlgProc (COMMDLG.7)
577 LRESULT
FileSaveDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
581 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
584 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
587 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
);
590 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
595 SetBkColor((HDC)wParam, 0x00C0C0C0);
596 switch (HIWORD(lParam))
599 SetTextColor((HDC)wParam, 0x00000000);
601 case CTLCOLOR_STATIC:
602 SetTextColor((HDC)wParam, 0x00000000);
612 /***********************************************************************
613 * ChooseColor (COMMDLG.5)
615 BOOL
ChooseColor(LPCHOOSECOLOR lpChCol
)
617 HANDLE hInst
, hDlgTmpl
;
620 hDlgTmpl
= GLOBAL_CreateBlock(GMEM_FIXED
, sysres_DIALOG_CHOOSE_COLOR
.bytes
,
621 sysres_DIALOG_CHOOSE_COLOR
.size
,
622 GetCurrentPDB(), FALSE
, FALSE
, TRUE
, NULL
);
623 hInst
= WIN_GetWindowInstance( lpChCol
->hwndOwner
);
624 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpChCol
->hwndOwner
,
625 GetWndProcEntry16("ColorDlgProc"),
627 GLOBAL_FreeBlock( hDlgTmpl
);
632 /***********************************************************************
633 * ColorDlgProc (COMMDLG.8)
635 LRESULT
ColorDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
640 printf("ColorDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
641 ShowWindow(hWnd
, SW_SHOWNORMAL
);
647 EndDialog(hWnd
, TRUE
);
650 EndDialog(hWnd
, FALSE
);
659 /***********************************************************************
660 * FindTextDlg (COMMDLG.11)
662 BOOL
FindText(LPFINDREPLACE lpFind
)
664 HANDLE hInst
, hDlgTmpl
;
667 hDlgTmpl
= GLOBAL_CreateBlock(GMEM_FIXED
, sysres_DIALOG_FIND_TEXT
.bytes
,
668 sysres_DIALOG_FIND_TEXT
.size
,
669 GetCurrentPDB(), FALSE
, FALSE
, TRUE
, NULL
);
670 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
671 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpFind
->hwndOwner
,
672 GetWndProcEntry16("FindTextDlgProc"),
674 GLOBAL_FreeBlock( hDlgTmpl
);
679 /***********************************************************************
680 * ReplaceTextDlg (COMMDLG.12)
682 BOOL
ReplaceText(LPFINDREPLACE lpFind
)
684 HANDLE hInst
, hDlgTmpl
;
687 hDlgTmpl
= GLOBAL_CreateBlock(GMEM_FIXED
, sysres_DIALOG_REPLACE_TEXT
.bytes
,
688 sysres_DIALOG_REPLACE_TEXT
.size
,
689 GetCurrentPDB(), FALSE
, FALSE
, TRUE
, NULL
);
690 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
691 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpFind
->hwndOwner
,
692 GetWndProcEntry16("ReplaceTextDlgProc"),
694 GLOBAL_FreeBlock( hDlgTmpl
);
699 /***********************************************************************
700 * FindTextDlgProc (COMMDLG.13)
702 LRESULT
FindTextDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
707 printf("FindTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
708 ShowWindow(hWnd
, SW_SHOWNORMAL
);
714 EndDialog(hWnd
, TRUE
);
717 EndDialog(hWnd
, FALSE
);
726 /***********************************************************************
727 * ReplaceTextDlgProc (COMMDLG.14)
729 LRESULT
ReplaceTextDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
734 printf("ReplaceTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
735 ShowWindow(hWnd
, SW_SHOWNORMAL
);
741 EndDialog(hWnd
, TRUE
);
744 EndDialog(hWnd
, FALSE
);
753 /***********************************************************************
754 * PrintDlg (COMMDLG.20)
756 BOOL
PrintDlg(LPPRINTDLG lpPrint
)
758 HANDLE hInst
, hDlgTmpl
;
761 printf("PrintDlg(%p) // Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
763 if (lpPrint
->Flags
& PD_RETURNDEFAULT
)
764 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
767 if (lpPrint
->Flags
& PD_PRINTSETUP
)
768 hDlgTmpl
= GLOBAL_CreateBlock( GMEM_FIXED
,
769 sysres_DIALOG_PRINT_SETUP
.bytes
,
770 sysres_DIALOG_PRINT_SETUP
.size
,
771 GetCurrentPDB(), FALSE
,
774 hDlgTmpl
= GLOBAL_CreateBlock( GMEM_FIXED
, sysres_DIALOG_PRINT
.bytes
,
775 sysres_DIALOG_PRINT
.size
,
776 GetCurrentPDB(), FALSE
,
779 hInst
= WIN_GetWindowInstance( lpPrint
->hwndOwner
);
780 bRet
= DialogBoxIndirectParam( hInst
, hDlgTmpl
, lpPrint
->hwndOwner
,
781 (lpPrint
->Flags
& PD_PRINTSETUP
) ?
782 GetWndProcEntry16("PrintSetupDlgProc") :
783 GetWndProcEntry16("PrintDlgProc"),
785 GLOBAL_FreeBlock( hDlgTmpl
);
790 /***********************************************************************
791 * PrintDlgProc (COMMDLG.21)
793 LRESULT
PrintDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
798 printf("PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
799 ShowWindow(hWnd
, SW_SHOWNORMAL
);
805 EndDialog(hWnd
, TRUE
);
808 EndDialog(hWnd
, FALSE
);
817 /***********************************************************************
818 * PrintSetupDlgProc (COMMDLG.22)
820 LRESULT
PrintSetupDlgProc(HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
)
825 printf("PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
826 ShowWindow(hWnd
, SW_SHOWNORMAL
);
831 EndDialog(hWnd
, TRUE
);
834 EndDialog(hWnd
, FALSE
);
843 /***********************************************************************
844 * CommDlgExtendError (COMMDLG.26)
846 DWORD
CommDlgExtendError(void)
848 return CommDlgLastError
;
852 /***********************************************************************
853 * GetFileTitle (COMMDLG.27)
855 int GetFileTitle(LPCSTR lpFile
, LPSTR lpTitle
, UINT cbBuf
)
858 printf("GetFileTitle(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
859 if (lpFile
== NULL
|| lpTitle
== NULL
)
861 len
= strlen(lpFile
);
864 if (strpbrk(lpFile
, "*[]"))
867 if (lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
869 for (i
= len
; i
>= 0; i
--)
870 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
875 printf("\n---> '%s' ", &lpFile
[i
]);
876 len
= min(cbBuf
, strlen(&lpFile
[i
]) + 1);
877 strncpy(lpTitle
, &lpFile
[i
], len
+ 1);