2 * COMMDLG - File Dialogs
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
11 #include "wine/winbase16.h"
12 #include "wine/winuser16.h"
21 #include "debugtools.h"
26 DEFAULT_DEBUG_CHANNEL(commdlg)
30 static HICON16 hFolder = 0;
31 static HICON16 hFolder2 = 0;
32 static HICON16 hFloppy = 0;
33 static HICON16 hHDisk = 0;
34 static HICON16 hCDRom = 0;
35 static HICON16 hNet = 0;
36 static int fldrHeight = 0;
37 static int fldrWidth = 0;
39 static const char defaultfilter[]=" \0\0";
40 #define OFN_PROP "FILEDLG_OFN_LPARAM"
42 /***********************************************************************
44 * Windows 3.1 OpenFileName/SaveFileName dialog
47 /***********************************************************************
48 * FileDlg_Init [internal]
50 static BOOL FileDlg_Init(void)
52 static BOOL initialized = 0;
53 CURSORICONINFO *fldrInfo;
56 if (!hFolder) hFolder = LoadIcon16(0, MAKEINTRESOURCE16(OIC_FOLDER));
57 if (!hFolder2) hFolder2 = LoadIcon16(0, MAKEINTRESOURCE16(OIC_FOLDER2));
58 if (!hFloppy) hFloppy = LoadIcon16(0, MAKEINTRESOURCE16(OIC_FLOPPY));
59 if (!hHDisk) hHDisk = LoadIcon16(0, MAKEINTRESOURCE16(OIC_HDISK));
60 if (!hCDRom) hCDRom = LoadIcon16(0, MAKEINTRESOURCE16(OIC_CDROM));
61 if (!hNet) hNet = LoadIcon16(0, MAKEINTRESOURCE16(OIC_NETWORK));
62 if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
63 hHDisk == 0 || hCDRom == 0 || hNet == 0)
65 ERR("Error loading icons !\n");
68 fldrInfo = (CURSORICONINFO *) GlobalLock16( hFolder2 );
71 ERR("Error measuring icons !\n");
74 fldrHeight = fldrInfo -> nHeight;
75 fldrWidth = fldrInfo -> nWidth;
76 GlobalUnlock16( hFolder2 );
82 /***********************************************************************
83 * FileOpenDlgProc [internal]
85 * FIXME: Convert to real 32-bit message processing
87 static LRESULT WINAPI FileOpenDlgProc(HWND hDlg, UINT msg,
88 WPARAM wParam, LPARAM lParam)
94 if (WINPROC_MapMsg32ATo16( hDlg, msg, wParam,
95 &msg16, &mp16.wParam, &mp16.lParam ) == -1)
97 mp16.lResult = FileOpenDlgProc16( (HWND16)hDlg, msg16,
98 mp16.wParam, mp16.lParam );
100 WINPROC_UnmapMsg32ATo16( hDlg, msg, wParam, lParam, &mp16 );
104 /***********************************************************************
105 * FileSaveDlgProc [internal]
107 * FIXME: Convert to real 32-bit message processing
109 static LRESULT WINAPI FileSaveDlgProc(HWND hDlg, UINT msg,
110 WPARAM wParam, LPARAM lParam)
115 mp16.lParam = lParam;
116 if (WINPROC_MapMsg32ATo16( hDlg, msg, wParam,
117 &msg16, &mp16.wParam, &mp16.lParam ) == -1)
119 mp16.lResult = FileSaveDlgProc16( (HWND16)hDlg, msg16,
120 mp16.wParam, mp16.lParam );
122 WINPROC_UnmapMsg32ATo16( hDlg, msg, wParam, lParam, &mp16 );
126 /***********************************************************************
127 * GetOpenFileName16 (COMMDLG.1)
129 * Creates a dialog box for the user to select a file to open.
132 * TRUE on success: user selected a valid file
133 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
136 * unknown, there are some FIXME's left.
138 BOOL16 WINAPI GetOpenFileName16(
139 SEGPTR ofn /* addess of structure with data*/
143 HANDLE hDlgTmpl = 0, hResInfo;
144 BOOL bRet = FALSE, win32Format = FALSE;
146 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
148 char defaultopen[]="Open File";
151 if (!lpofn || !FileDlg_Init()) return FALSE;
153 if (lpofn->Flags & OFN_WINE) {
154 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
156 if (!(template = LockResource( MapHModuleSL(lpofn->hInstance ))))
158 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
162 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
164 if (!(hResInfo = FindResourceA(MapHModuleSL(lpofn->hInstance),
165 PTR_SEG_TO_LIN(lpofn->lpTemplateName), RT_DIALOGA)))
167 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
170 if (!(hDlgTmpl = LoadResource( MapHModuleSL(lpofn->hInstance),
172 !(template = LockResource( hDlgTmpl )))
174 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
178 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "OPEN_FILE", RT_DIALOGA)))
180 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
183 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
184 !(template = LockResource( hDlgTmpl )))
186 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
192 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
194 if (!(template = LockResource16( lpofn->hInstance )))
196 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
200 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
202 if (!(hResInfo = FindResource16(lpofn->hInstance,
203 lpofn->lpTemplateName,
206 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
209 if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
210 !(template = LockResource16( hDlgTmpl )))
212 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
216 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "OPEN_FILE", RT_DIALOGA)))
218 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
221 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
222 !(template = LockResource( hDlgTmpl )))
224 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
231 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
233 if (!(lpofn->lpstrFilter))
235 str = SEGPTR_ALLOC(sizeof(defaultfilter));
236 TRACE("Alloc %p default for Filetype in GetOpenFileName\n",str);
237 memcpy(str,defaultfilter,sizeof(defaultfilter));
238 lpofn->lpstrFilter=SEGPTR_GET(str);
241 if (!(lpofn->lpstrTitle))
243 str1 = SEGPTR_ALLOC(strlen(defaultopen)+1);
244 TRACE("Alloc %p default for Title in GetOpenFileName\n",str1);
245 strcpy(str1,defaultopen);
246 lpofn->lpstrTitle=SEGPTR_GET(str1);
249 /* FIXME: doesn't handle win32 format correctly yet */
250 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
252 (DLGPROC16)FileOpenDlgProc,
254 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
258 TRACE("Freeing %p default for Title in GetOpenFileName\n",str1);
265 TRACE("Freeing %p default for Filetype in GetOpenFileName\n",str);
267 lpofn->lpstrFilter=0;
271 if (lpofn->Flags & OFN_WINE)
272 FreeResource( hDlgTmpl );
274 FreeResource16( hDlgTmpl );
277 TRACE("return lpstrFile='%s' !\n",
278 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
283 /***********************************************************************
284 * GetSaveFileName (COMMDLG.2)
286 * Creates a dialog box for the user to select a file to save.
289 * TRUE on succes: user enters a valid file
290 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
293 * unknown. There are some FIXME's left.
295 BOOL16 WINAPI GetSaveFileName16(
296 SEGPTR ofn /* addess of structure with data*/
301 BOOL bRet = FALSE, win32Format = FALSE;
302 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
305 char defaultsave[]="Save as";
306 char *str =0,*str1=0;
308 if (!lpofn || !FileDlg_Init()) return FALSE;
310 if (lpofn->Flags & OFN_WINE) {
311 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
313 if (!(template = LockResource( MapHModuleSL(lpofn->hInstance ))))
315 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
319 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
322 if (!(hResInfo = FindResourceA(MapHModuleSL(lpofn->hInstance),
323 PTR_SEG_TO_LIN(lpofn->lpTemplateName),
326 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
329 if (!(hDlgTmpl = LoadResource(MapHModuleSL(lpofn->hInstance),
331 !(template = LockResource(hDlgTmpl)))
333 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
339 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "SAVE_FILE", RT_DIALOGA)))
341 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
344 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
345 !(template = LockResource( hDlgTmpl )))
347 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
353 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
355 if (!(template = LockResource16( lpofn->hInstance )))
357 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
361 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
364 if (!(hResInfo = FindResource16(lpofn->hInstance,
365 lpofn->lpTemplateName,
368 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
371 if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
372 !(template = LockResource16( hDlgTmpl )))
374 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
379 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "SAVE_FILE", RT_DIALOGA)))
381 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
384 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
385 !(template = LockResource( hDlgTmpl )))
387 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
394 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
396 if (!(lpofn->lpstrFilter))
398 str = SEGPTR_ALLOC(sizeof(defaultfilter));
399 TRACE("Alloc default for Filetype in GetSaveFileName\n");
400 memcpy(str,defaultfilter,sizeof(defaultfilter));
401 lpofn->lpstrFilter=SEGPTR_GET(str);
404 if (!(lpofn->lpstrTitle))
406 str1 = SEGPTR_ALLOC(sizeof(defaultsave)+1);
407 TRACE("Alloc default for Title in GetSaveFileName\n");
408 strcpy(str1,defaultsave);
409 lpofn->lpstrTitle=SEGPTR_GET(str1);
412 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
414 (DLGPROC16)FileSaveDlgProc,
416 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
420 TRACE("Freeing %p default for Title in GetSaveFileName\n",str1);
427 TRACE("Freeing %p default for Filetype in GetSaveFileName\n",str);
429 lpofn->lpstrFilter=0;
433 if (lpofn->Flags & OFN_WINE)
434 FreeResource( hDlgTmpl );
436 FreeResource16( hDlgTmpl );
439 TRACE("return lpstrFile='%s' !\n",
440 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
444 /***********************************************************************
445 * FILEDLG_StripEditControl [internal]
446 * Strip pathnames off the contents of the edit control.
448 static void FILEDLG_StripEditControl(HWND16 hwnd)
452 GetDlgItemTextA( hwnd, edt1, temp, sizeof(temp) );
453 cp = strrchr(temp, '\\');
457 cp = strrchr(temp, ':');
461 /* FIXME: shouldn't we do something with the result here? ;-) */
464 /***********************************************************************
465 * FILEDLG_ScanDir [internal]
467 static BOOL FILEDLG_ScanDir(HWND16 hWnd, LPSTR newPath)
474 lstrcpynA(buffer, newPath, sizeof(buffer));
476 if (str[0] && (str[1] == ':')) {
477 drive = toupper(str[0]) - 'A';
479 if (!DRIVE_SetCurrentDrive(drive))
482 drive = DRIVE_GetCurrentDrive();
485 if (str[0] && !DRIVE_Chdir(drive, str)) {
489 GetDlgItemTextA(hWnd, edt1, buffer, sizeof(buffer));
490 if ((hlb = GetDlgItem(hWnd, lst1)) != 0) {
491 char* scptr; /* ptr on semi-colon */
492 char* filter = buffer;
494 TRACE("Using filter %s\n", filter);
495 SendMessageA(hlb, LB_RESETCONTENT, 0, 0);
497 scptr = strchr(filter, ';');
498 if (scptr) *scptr = 0;
499 TRACE("Using file spec %s\n", filter);
500 if (SendMessageA(hlb, LB_DIR, 0, (LPARAM)filter) == LB_ERR)
502 if (scptr) *scptr = ';';
503 filter = (scptr) ? (scptr + 1) : 0;
507 strcpy(buffer, "*.*");
508 return DlgDirListA(hWnd, buffer, lst2, stc1, DDL_EXCLUSIVE | DDL_DIRECTORY);
511 /***********************************************************************
512 * FILEDLG_GetFileType [internal]
515 static LPSTR FILEDLG_GetFileType(LPSTR cfptr, LPSTR fptr, WORD index)
520 for ( ;(n = strlen(cfptr)) != 0; i++)
525 cfptr += strlen(cfptr) + 1;
528 for ( ;(n = strlen(fptr)) != 0; i++)
533 fptr += strlen(fptr) + 1;
535 return "*.*"; /* FIXME */
538 /***********************************************************************
539 * FILEDLG_WMDrawItem [internal]
541 static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int savedlg)
543 LPDRAWITEMSTRUCT16 lpdis = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
546 COLORREF oldText = 0, oldBk = 0;
548 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
550 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
551 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
552 (LPARAM)SEGPTR_GET(str));
554 if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
556 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
557 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
560 SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
562 ExtTextOut16(lpdis->hDC, lpdis->rcItem.left + 1,
563 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
564 &(lpdis->rcItem), str, strlen(str), NULL);
566 if (lpdis->itemState & ODS_SELECTED)
567 DrawFocusRect16( lpdis->hDC, &(lpdis->rcItem) );
569 if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
571 SetBkColor( lpdis->hDC, oldBk );
572 SetTextColor( lpdis->hDC, oldText );
578 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
580 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
581 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
582 (LPARAM)SEGPTR_GET(str));
584 if (lpdis->itemState & ODS_SELECTED)
586 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
587 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
589 ExtTextOut16(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
590 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
591 &(lpdis->rcItem), str, strlen(str), NULL);
593 if (lpdis->itemState & ODS_SELECTED)
594 DrawFocusRect16( lpdis->hDC, &(lpdis->rcItem) );
596 if (lpdis->itemState & ODS_SELECTED)
598 SetBkColor( lpdis->hDC, oldBk );
599 SetTextColor( lpdis->hDC, oldText );
601 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);
605 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
607 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
608 SendMessage16(lpdis->hwndItem, CB_GETLBTEXT16, lpdis->itemID,
609 (LPARAM)SEGPTR_GET(str));
610 switch(DRIVE_GetType( str[2] - 'a' ))
612 case TYPE_FLOPPY: hIcon = hFloppy; break;
613 case TYPE_CDROM: hIcon = hCDRom; break;
614 case TYPE_NETWORK: hIcon = hNet; break;
616 default: hIcon = hHDisk; break;
618 if (lpdis->itemState & ODS_SELECTED)
620 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
621 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
623 ExtTextOut16(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
624 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
625 &(lpdis->rcItem), str, strlen(str), NULL);
627 if (lpdis->itemState & ODS_SELECTED)
629 SetBkColor( lpdis->hDC, oldBk );
630 SetTextColor( lpdis->hDC, oldText );
632 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);
639 /***********************************************************************
640 * FILEDLG_WMMeasureItem [internal]
642 static LONG FILEDLG_WMMeasureItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
644 LPMEASUREITEMSTRUCT16 lpmeasure;
646 lpmeasure = (LPMEASUREITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
647 lpmeasure->itemHeight = fldrHeight;
651 /***********************************************************************
652 * FILEDLG_HookCallChk [internal]
654 static int FILEDLG_HookCallChk(LPOPENFILENAME16 lpofn)
657 if (lpofn->Flags & OFN_ENABLEHOOK)
663 /***********************************************************************
664 * FILEDLG_CallWindowProc [internal]
666 * Adapt the structures back for win32 calls so the callee can read lpCustData
668 static BOOL FILEDLG_CallWindowProc(LPOPENFILENAME16 lpofn,HWND hwnd,
669 UINT wMsg,WPARAM wParam,LPARAM lParam
674 WINDOWPROCTYPE ProcType; /* Type of Hook Function to be called. */
676 /* TRUE if lParam points to the OPENFILENAME16 Structure */
677 needstruct = (PTR_SEG_TO_LIN(lParam) == lpofn);
679 ProcType = (lpofn->Flags & OFN_WINE)
680 ? (lpofn->Flags & OFN_UNICODE) /* 32-Bit call to GetOpenFileName */
681 ? WIN_PROC_32W : WIN_PROC_32A
682 : WIN_PROC_16; /* 16-Bit call to GetOpenFileName */
684 if (!(lpofn->Flags & OFN_WINE))
685 /* Call to 16-Bit Hooking function... No Problem at all. */
686 return (BOOL)CallWindowProc16(
687 (WNDPROC16)lpofn->lpfnHook,hwnd,(UINT16)wMsg,(WPARAM16)wParam,lParam
692 /* Parameter lParam points to lpofn... Convert Structure Data... */
693 if (lpofn->Flags & OFN_UNICODE)
697 /* FIXME: probably needs more converted */
698 ofnw.lCustData = lpofn->lCustData;
699 return (BOOL)CallWindowProcW(
700 (WNDPROC)lpofn->lpfnHook,hwnd,wMsg,wParam,(LPARAM)&ofnw
703 else /* ! |OFN_UNICODE */
707 /* FIXME: probably needs more converted */
708 ofna.lCustData = lpofn->lCustData;
709 return (BOOL)CallWindowProcA(
710 (WNDPROC)lpofn->lpfnHook,hwnd,wMsg,wParam,(LPARAM)&ofna
714 else /* ! needstruct */
716 HWINDOWPROC hWindowProc=NULL;
718 if (WINPROC_SetProc(&hWindowProc, (WNDPROC16)lpofn->lpfnHook, ProcType, WIN_PROC_WINDOW))
720 /* Call Window Procedure converting 16-Bit Type Parameters to 32-Bit Type Parameters */
721 result = CallWindowProc16( (WNDPROC16)hWindowProc,
722 hwnd, wMsg, wParam, lParam );
724 result = LOWORD(result);
726 WINPROC_FreeProc( hWindowProc, WIN_PROC_WINDOW );
735 /***********************************************************************
736 * FILEDLG_WMInitDialog [internal]
739 static LONG FILEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
742 LPOPENFILENAME16 lpofn;
744 LPSTR pstr, old_pstr;
745 SetPropA(hWnd,OFN_PROP,lParam);
746 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(lParam);
747 if (lpofn->lpstrTitle) SetWindowText16( hWnd, lpofn->lpstrTitle );
748 /* read custom filter information */
749 if (lpofn->lpstrCustomFilter)
751 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter);
753 TRACE("lpstrCustomFilter = %p\n", pstr);
757 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
758 (LPARAM)lpofn->lpstrCustomFilter + n );
759 n += strlen(pstr) + 1;
760 pstr += strlen(pstr) + 1;
761 TRACE("add str='%s' "
762 "associated to '%s'\n", old_pstr, pstr);
763 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
764 n += strlen(pstr) + 1;
765 pstr += strlen(pstr) + 1;
768 /* read filter information */
769 if (lpofn->lpstrFilter) {
770 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFilter);
774 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
775 (LPARAM)lpofn->lpstrFilter + n );
776 n += strlen(pstr) + 1;
777 pstr += strlen(pstr) + 1;
778 TRACE("add str='%s' "
779 "associated to '%s'\n", old_pstr, pstr);
780 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
781 n += strlen(pstr) + 1;
782 pstr += strlen(pstr) + 1;
785 /* set default filter */
786 if (lpofn->nFilterIndex == 0 && lpofn->lpstrCustomFilter == (SEGPTR)NULL)
787 lpofn->nFilterIndex = 1;
788 SendDlgItemMessage16(hWnd, cmb1, CB_SETCURSEL16, lpofn->nFilterIndex - 1, 0);
789 lstrcpynA(tmpstr, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
790 PTR_SEG_TO_LIN(lpofn->lpstrFilter), lpofn->nFilterIndex - 1),512);
791 TRACE("nFilterIndex = %ld, SetText of edt1 to '%s'\n",
792 lpofn->nFilterIndex, tmpstr);
793 SetDlgItemTextA( hWnd, edt1, tmpstr );
796 DlgDirListComboBoxA(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
797 /* read initial directory */
798 if (PTR_SEG_TO_LIN(lpofn->lpstrInitialDir) != NULL)
801 lstrcpynA(tmpstr, PTR_SEG_TO_LIN(lpofn->lpstrInitialDir), 511);
803 if (len > 0 && tmpstr[len-1] != '\\' && tmpstr[len-1] != ':') {
810 if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
812 if (!FILEDLG_ScanDir(hWnd, tmpstr))
813 WARN("Couldn't read initial directory %s!\n",tmpstr);
815 /* select current drive in combo 2, omit missing drives */
816 for(i=0, n=-1; i<=DRIVE_GetCurrentDrive(); i++)
817 if (DRIVE_IsValid(i)) n++;
818 SendDlgItemMessage16(hWnd, cmb2, CB_SETCURSEL16, n, 0);
819 if (!(lpofn->Flags & OFN_SHOWHELP))
820 ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
821 if (lpofn->Flags & OFN_HIDEREADONLY)
822 ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
823 if (FILEDLG_HookCallChk(lpofn))
824 return (BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,WM_INITDIALOG,wParam,lParam );
829 /***********************************************************************
830 * FILEDLG_WMCommand [internal]
832 BOOL in_update=FALSE;
834 static LRESULT FILEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
837 LPOPENFILENAME16 lpofn;
839 char tmpstr[512], tmpstr2[512];
841 UINT16 control,notification;
843 /* Notifications are packaged differently in Win32 */
845 notification = HIWORD(lParam);
847 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetPropA(hWnd,OFN_PROP));
850 case lst1: /* file list */
851 FILEDLG_StripEditControl(hWnd);
852 if (notification == LBN_DBLCLK)
854 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
855 if (lRet == LB_ERR) return TRUE;
856 if ((pstr = SEGPTR_ALLOC(512)))
858 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
859 (LPARAM)SEGPTR_GET(pstr));
860 SetDlgItemTextA( hWnd, edt1, pstr );
863 if (FILEDLG_HookCallChk(lpofn))
864 FILEDLG_CallWindowProc(lpofn,hWnd,
865 RegisterWindowMessageA( LBSELCHSTRING ),
866 control, MAKELONG(lRet,CD_LBSELCHANGE));
867 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
869 case lst2: /* directory list */
870 FILEDLG_StripEditControl(hWnd);
871 if (notification == LBN_DBLCLK)
873 lRet = SendDlgItemMessage16(hWnd, lst2, LB_GETCURSEL16, 0, 0);
874 if (lRet == LB_ERR) return TRUE;
875 pstr = SEGPTR_ALLOC(512);
876 SendDlgItemMessage16(hWnd, lst2, LB_GETTEXT16, lRet,
877 (LPARAM)SEGPTR_GET(pstr));
878 strcpy( tmpstr, pstr );
880 if (tmpstr[0] == '[')
882 tmpstr[strlen(tmpstr) - 1] = 0;
883 strcpy(tmpstr,tmpstr+1);
885 strcat(tmpstr, "\\");
889 case cmb1: /* file type drop list */
890 if (notification == CBN_SELCHANGE)
900 case cmb2: /* disk drop list */
901 FILEDLG_StripEditControl(hWnd);
902 lRet = SendDlgItemMessage16(hWnd, cmb2, CB_GETCURSEL16, 0, 0L);
903 if (lRet == LB_ERR) return 0;
904 pstr = SEGPTR_ALLOC(512);
905 SendDlgItemMessage16(hWnd, cmb2, CB_GETLBTEXT16, lRet,
906 (LPARAM)SEGPTR_GET(pstr));
907 sprintf(tmpstr, "%c:", pstr[2]);
910 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
913 pstr = (LPSTR)SendDlgItemMessage16(hWnd, cmb1, CB_GETITEMDATA16, lRet, 0);
914 TRACE("Selected filter : %s\n", pstr);
915 SetDlgItemTextA( hWnd, edt1, pstr );
916 FILEDLG_ScanDir(hWnd, tmpstr);
920 ofn2=*lpofn; /* for later restoring */
921 GetDlgItemTextA( hWnd, edt1, tmpstr, sizeof(tmpstr) );
922 pstr = strrchr(tmpstr, '\\');
924 pstr = strrchr(tmpstr, ':');
925 if (strchr(tmpstr,'*') != NULL || strchr(tmpstr,'?') != NULL)
927 /* edit control contains wildcards */
930 lstrcpynA(tmpstr2, pstr+1, 512);
935 strcpy(tmpstr2, tmpstr);
938 TRACE("tmpstr=%s, tmpstr2=%s\n", tmpstr, tmpstr2);
939 SetDlgItemTextA( hWnd, edt1, tmpstr2 );
940 FILEDLG_ScanDir(hWnd, tmpstr);
943 /* no wildcards, we might have a directory or a filename */
944 /* try appending a wildcard and reading the directory */
945 pstr2 = tmpstr + strlen(tmpstr);
946 if (pstr == NULL || *(pstr+1) != 0)
947 strcat(tmpstr, "\\");
948 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
949 if (lRet == LB_ERR) return TRUE;
950 lpofn->nFilterIndex = lRet + 1;
951 TRACE("lpofn->nFilterIndex=%ld\n", lpofn->nFilterIndex);
953 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
954 PTR_SEG_TO_LIN(lpofn->lpstrFilter),
955 lRet), sizeof(tmpstr2));
956 SetDlgItemTextA( hWnd, edt1, tmpstr2 );
958 /* if ScanDir succeeds, we have changed the directory */
959 if (FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
960 /* if not, this must be a filename */
964 /* strip off the pathname */
966 SetDlgItemTextA( hWnd, edt1, pstr + 1 );
967 lstrcpynA(tmpstr2, pstr+1, sizeof(tmpstr2) );
968 /* Should we MessageBox() if this fails? */
969 if (!FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
970 strcpy(tmpstr, tmpstr2);
972 else SetDlgItemTextA( hWnd, edt1, tmpstr );
974 ShowWindow16(hWnd, SW_HIDE); /* this should not be necessary ?! (%%%) */
978 int drive = DRIVE_GetCurrentDrive();
979 tmpstr2[0] = 'A'+ drive;
982 lstrcpynA(tmpstr2 + 3, DRIVE_GetDosCwd(drive), 507);
983 lenstr2=strlen(tmpstr2);
985 tmpstr2[lenstr2++]='\\';
986 lstrcpynA(tmpstr2+lenstr2, tmpstr, 512-lenstr2);
987 if (lpofn->lpstrFile)
988 lstrcpynA(PTR_SEG_TO_LIN(lpofn->lpstrFile), tmpstr2,lpofn->nMaxFile);
990 lpofn->nFileOffset = strrchr(tmpstr2,'\\') - tmpstr2 +1;
991 lpofn->nFileExtension = 0;
992 while(tmpstr2[lpofn->nFileExtension] != '.' && tmpstr2[lpofn->nFileExtension] != '\0')
993 lpofn->nFileExtension++;
994 if (tmpstr2[lpofn->nFileExtension] == '\0')
995 lpofn->nFileExtension = 0;
997 lpofn->nFileExtension++;
1001 if (FILEDLG_HookCallChk(lpofn))
1002 FILEDLG_CallWindowProc(lpofn,hWnd,
1003 RegisterWindowMessageA( LBSELCHSTRING ),
1004 control, MAKELONG(lRet,CD_LBSELCHANGE));
1009 if (PTR_SEG_TO_LIN(lpofn->lpstrFileTitle) != NULL)
1011 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
1012 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
1013 lpofn->lpstrFileTitle );
1015 if (FILEDLG_HookCallChk(lpofn))
1017 lRet= (BOOL16)FILEDLG_CallWindowProc(lpofn,
1018 hWnd, RegisterWindowMessageA( FILEOKSTRING ), 0, lParam );
1021 *lpofn=ofn2; /* restore old state */
1023 ShowWindow16(hWnd, SW_SHOW); /* only if above (%%%) SW_HIDE used */
1028 if ((lpofn->Flags & OFN_ALLOWMULTISELECT) && (lpofn->Flags & OFN_EXPLORER)) {
1029 if (lpofn->lpstrFile) {
1030 LPSTR str = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile);
1031 LPSTR ptr = strrchr(str, '\\');
1032 str[strlen(str) + 1] = '\0';
1036 EndDialog(hWnd, TRUE);
1039 EndDialog(hWnd, FALSE);
1045 /***********************************************************************
1046 * FileOpenDlgProc16 (COMMDLG.6)
1048 LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1051 LPOPENFILENAME16 lpofn =(LPOPENFILENAME16)PTR_SEG_TO_LIN(GetPropA(hWnd,OFN_PROP));
1053 if (wMsg!=WM_INITDIALOG)
1054 if (FILEDLG_HookCallChk(lpofn))
1056 LRESULT lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
1058 return lRet; /* else continue message processing */
1063 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
1064 case WM_MEASUREITEM:
1065 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
1067 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, FALSE);
1069 return FILEDLG_WMCommand(hWnd, wParam, lParam);
1072 SetBkColor((HDC16)wParam, 0x00C0C0C0);
1073 switch (HIWORD(lParam))
1076 SetTextColor((HDC16)wParam, 0x00000000);
1078 case CTLCOLOR_STATIC:
1079 SetTextColor((HDC16)wParam, 0x00000000);
1088 /***********************************************************************
1089 * FileSaveDlgProc16 (COMMDLG.7)
1091 LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1094 LPOPENFILENAME16 lpofn =(LPOPENFILENAME16)PTR_SEG_TO_LIN(GetPropA(hWnd,OFN_PROP));
1096 if (wMsg!=WM_INITDIALOG)
1097 if (FILEDLG_HookCallChk(lpofn))
1099 LRESULT lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
1101 return lRet; /* else continue message processing */
1105 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
1107 case WM_MEASUREITEM:
1108 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
1111 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, TRUE);
1114 return FILEDLG_WMCommand(hWnd, wParam, lParam);
1119 SetBkColor((HDC16)wParam, 0x00C0C0C0);
1120 switch (HIWORD(lParam))
1123 SetTextColor((HDC16)wParam, 0x00000000);
1125 case CTLCOLOR_STATIC:
1126 SetTextColor((HDC16)wParam, 0x00000000);
1135 static BOOL Commdlg_GetFileNameA( BOOL16 (CALLBACK *dofunction)(SEGPTR x),
1136 LPOPENFILENAMEA ofn )
1139 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));
1141 memset(ofn16,'\0',sizeof(*ofn16));
1142 ofn16->lStructSize = sizeof(*ofn16);
1143 ofn16->hwndOwner = ofn->hwndOwner;
1144 ofn16->hInstance = MapHModuleLS(ofn->hInstance);
1145 if (ofn->lpstrFilter) {
1148 /* filter is a list... title\0ext\0......\0\0 */
1149 s = (LPSTR)ofn->lpstrFilter;
1153 x = (LPSTR)SEGPTR_ALLOC(s-ofn->lpstrFilter);
1154 memcpy(x,ofn->lpstrFilter,s-ofn->lpstrFilter);
1155 ofn16->lpstrFilter = SEGPTR_GET(x);
1157 if (ofn->lpstrCustomFilter) {
1160 /* filter is a list... title\0ext\0......\0\0 */
1161 s = (LPSTR)ofn->lpstrCustomFilter;
1165 x = SEGPTR_ALLOC(s-ofn->lpstrCustomFilter);
1166 memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);
1167 ofn16->lpstrCustomFilter = SEGPTR_GET(x);
1169 ofn16->nMaxCustFilter = ofn->nMaxCustFilter;
1170 ofn16->nFilterIndex = ofn->nFilterIndex;
1172 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));
1173 ofn16->nMaxFile = ofn->nMaxFile;
1174 ofn16->nMaxFileTitle = ofn->nMaxFileTitle;
1175 if (ofn16->nMaxFileTitle)
1176 ofn16->lpstrFileTitle = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFileTitle));
1177 if (ofn->lpstrInitialDir)
1178 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrInitialDir));
1179 if (ofn->lpstrTitle)
1180 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrTitle));
1181 ofn16->Flags = ofn->Flags|OFN_WINE;
1182 ofn16->nFileOffset = ofn->nFileOffset;
1183 ofn16->nFileExtension = ofn->nFileExtension;
1184 if (ofn->lpstrDefExt)
1185 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrDefExt));
1186 ofn16->lCustData = ofn->lCustData;
1187 ofn16->lpfnHook = (LPOFNHOOKPROC16)ofn->lpfnHook;
1189 if (ofn->lpTemplateName)
1190 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpTemplateName));
1192 ret = dofunction(SEGPTR_GET(ofn16));
1194 ofn->nFileOffset = ofn16->nFileOffset;
1195 ofn->nFileExtension = ofn16->nFileExtension;
1196 if (ofn16->lpstrFilter)
1197 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));
1198 if (ofn16->lpTemplateName)
1199 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));
1200 if (ofn16->lpstrDefExt)
1201 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));
1202 if (ofn16->lpstrTitle)
1203 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));
1204 if (ofn16->lpstrInitialDir)
1205 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));
1206 if (ofn16->lpstrCustomFilter)
1207 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));
1209 if (ofn16->lpstrFile)
1211 LPCSTR src = PTR_SEG_TO_LIN(ofn16->lpstrFile);
1212 LPSTR dst = ofn->lpstrFile;
1214 if ((ofn->Flags & OFN_ALLOWMULTISELECT) && (ofn->Flags & OFN_EXPLORER)) {
1215 /* FIXME(EPP): I tried to use:
1216 * memcpy(ofn->lpstrFile, PTR_SEG_TO_LIN(ofn16->lpstrFile, ofn->nMaxFile)
1217 * but it did crash with winamp 2.21, so copy string by string
1222 len = strlen(dst) + 1; /* strlen(dst) == strlen(src) */
1229 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));
1232 if (ofn16->lpstrFileTitle)
1234 if (ofn->lpstrFileTitle)
1235 strcpy(ofn->lpstrFileTitle,
1236 PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
1237 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
1243 static BOOL Commdlg_GetFileNameW( BOOL16 (CALLBACK *dofunction)(SEGPTR x),
1244 LPOPENFILENAMEW ofn )
1247 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));
1249 memset(ofn16,'\0',sizeof(*ofn16));
1250 ofn16->lStructSize = sizeof(*ofn16);
1251 ofn16->hwndOwner = ofn->hwndOwner;
1252 ofn16->hInstance = MapHModuleLS(ofn->hInstance);
1253 if (ofn->lpstrFilter) {
1258 /* filter is a list... title\0ext\0......\0\0 */
1259 s = (LPWSTR)ofn->lpstrFilter;
1261 s = s+lstrlenW(s)+1;
1263 n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */
1264 x = y = (LPSTR)SEGPTR_ALLOC(n);
1265 s = (LPWSTR)ofn->lpstrFilter;
1272 ofn16->lpstrFilter = SEGPTR_GET(y);
1274 if (ofn->lpstrCustomFilter) {
1279 /* filter is a list... title\0ext\0......\0\0 */
1280 s = (LPWSTR)ofn->lpstrCustomFilter;
1282 s = s+lstrlenW(s)+1;
1284 n = s - ofn->lpstrCustomFilter;
1285 x = y = (LPSTR)SEGPTR_ALLOC(n);
1286 s = (LPWSTR)ofn->lpstrCustomFilter;
1293 ofn16->lpstrCustomFilter = SEGPTR_GET(y);
1295 ofn16->nMaxCustFilter = ofn->nMaxCustFilter;
1296 ofn16->nFilterIndex = ofn->nFilterIndex;
1298 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));
1299 ofn16->nMaxFile = ofn->nMaxFile;
1300 ofn16->nMaxFileTitle = ofn->nMaxFileTitle;
1301 if (ofn->nMaxFileTitle)
1302 ofn16->lpstrFileTitle = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFileTitle));
1303 if (ofn->lpstrInitialDir)
1304 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrInitialDir));
1305 if (ofn->lpstrTitle)
1306 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrTitle));
1307 ofn16->Flags = ofn->Flags|OFN_WINE|OFN_UNICODE;
1308 ofn16->nFileOffset = ofn->nFileOffset;
1309 ofn16->nFileExtension = ofn->nFileExtension;
1310 if (ofn->lpstrDefExt)
1311 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrDefExt));
1312 ofn16->lCustData = ofn->lCustData;
1313 ofn16->lpfnHook = (LPOFNHOOKPROC16)ofn->lpfnHook;
1314 if (ofn->lpTemplateName)
1315 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpTemplateName));
1316 ret = dofunction(SEGPTR_GET(ofn16));
1318 ofn->nFileOffset = ofn16->nFileOffset;
1319 ofn->nFileExtension = ofn16->nFileExtension;
1320 if (ofn16->lpstrFilter)
1321 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));
1322 if (ofn16->lpTemplateName)
1323 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));
1324 if (ofn16->lpstrDefExt)
1325 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));
1326 if (ofn16->lpstrTitle)
1327 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));
1328 if (ofn16->lpstrInitialDir)
1329 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));
1330 if (ofn16->lpstrCustomFilter)
1331 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));
1333 if (ofn16->lpstrFile)
1335 LPCSTR src = PTR_SEG_TO_LIN(ofn16->lpstrFile);
1336 LPWSTR dst = ofn->lpstrFile;
1338 if ((ofn->Flags & OFN_ALLOWMULTISELECT) && (ofn->Flags & OFN_EXPLORER)) {
1341 lstrcpyAtoW(dst, src);
1342 dst += lstrlenW(dst) + 1;
1343 src += (len = strlen(src) + 1);
1346 lstrcpyAtoW(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));
1348 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));
1351 if (ofn16->lpstrFileTitle) {
1352 if (ofn->lpstrFileTitle)
1353 lstrcpyAtoW(ofn->lpstrFileTitle,
1354 PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
1355 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
1360 /***********************************************************************
1361 * GetOpenFileNameA (COMDLG32.10)
1363 * Creates a dialog box for the user to select a file to open.
1366 * TRUE on succes: user enters a valid file
1367 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1370 * unknown, calls its 16-bit equivalent.
1372 BOOL WINAPI GetOpenFileNameA(
1373 LPOPENFILENAMEA ofn /* address of init structure */
1376 if(TWEAK_WineLook > WIN31_LOOK)
1378 return GetFileDialog95A(ofn, OPEN_DIALOG);
1382 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
1383 return Commdlg_GetFileNameA(dofunction,ofn);
1387 /***********************************************************************
1388 * GetOpenFileNameW (COMDLG32.11)
1390 * Creates a dialog box for the user to select a file to open.
1393 * TRUE on succes: user enters a valid file
1394 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1397 * unknown, calls its 16-bit equivalent.
1399 BOOL WINAPI GetOpenFileNameW(
1400 LPOPENFILENAMEW ofn /* address of init structure */
1403 if(TWEAK_WineLook > WIN31_LOOK)
1405 return GetFileDialog95W(ofn, OPEN_DIALOG);
1409 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
1410 return Commdlg_GetFileNameW(dofunction,ofn);
1414 /***********************************************************************
1415 * GetSaveFileNameA (COMDLG32.12)
1417 * Creates a dialog box for the user to select a file to save.
1420 * TRUE on succes: user enters a valid file
1421 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1424 * unknown, calls its 16-bit equivalent.
1426 BOOL WINAPI GetSaveFileNameA(
1427 LPOPENFILENAMEA ofn /* address of init structure */
1430 if(TWEAK_WineLook > WIN31_LOOK)
1432 return GetFileDialog95A(ofn, SAVE_DIALOG);
1436 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
1437 return Commdlg_GetFileNameA(dofunction,ofn);
1442 /***********************************************************************
1443 * GetSaveFileNameW (COMDLG32.13)
1445 * Creates a dialog box for the user to select a file to save.
1448 * TRUE on succes: user enters a valid file
1449 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1452 * unknown, calls its 16-bit equivalent.
1454 BOOL WINAPI GetSaveFileNameW(
1455 LPOPENFILENAMEW ofn /* address of init structure */
1458 if(TWEAK_WineLook > WIN31_LOOK)
1460 return GetFileDialog95W(ofn, SAVE_DIALOG);
1464 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
1465 return Commdlg_GetFileNameW(dofunction,ofn);