2 * COMMDLG - File Dialogs
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "wine/winbase16.h"
30 #include "wine/winuser16.h"
31 #include "wine/unicode.h"
33 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
42 static HICON hFolder = 0;
43 static HICON hFolder2 = 0;
44 static HICON hFloppy = 0;
45 static HICON hHDisk = 0;
46 static HICON hCDRom = 0;
47 static HICON hNet = 0;
48 static char defaultopen[]="Open File";
49 static char defaultsave[]="Save as";
51 /***********************************************************************
53 * Windows 3.1 style OpenFileName/SaveFileName dialog
57 BOOL16 CALLBACK FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
59 BOOL16 CALLBACK FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
62 static INT_PTR CALLBACK FileOpenDlgProc(HWND hDlg, UINT msg,
63 WPARAM wParam, LPARAM lParam);
65 /***********************************************************************
66 * FileDlg_Init [internal]
68 BOOL FileDlg_Init(void)
70 static BOOL initialized = 0;
73 HINSTANCE inst = GetModuleHandleA( "comdlg32.dll" );
76 ERR( "cannot get comdlg32.dll instance\n" );
79 hFolder = LoadImageA( inst, "FOLDER", IMAGE_ICON, 16, 16, LR_SHARED );
80 hFolder2 = LoadImageA( inst, "FOLDER2", IMAGE_ICON, 16, 16, LR_SHARED );
81 hFloppy = LoadImageA( inst, "FLOPPY", IMAGE_ICON, 16, 16, LR_SHARED );
82 hHDisk = LoadImageA( inst, "HDISK", IMAGE_ICON, 16, 16, LR_SHARED );
83 hCDRom = LoadImageA( inst, "CDROM", IMAGE_ICON, 16, 16, LR_SHARED );
84 hNet = LoadImageA( inst, "NETWORK", IMAGE_ICON, 16, 16, LR_SHARED );
85 if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
86 hHDisk == 0 || hCDRom == 0 || hNet == 0)
88 ERR("Error loading icons !\n");
97 /***********************************************************************
98 * Get32BitsTemplate [internal]
100 * Get a template (or FALSE if failure) when 16 bits dialogs are used
101 * by a 32 bits application
104 BOOL Get32BitsTemplate(LFSPRIVATE lfs)
106 LPOPENFILENAMEW ofnW = lfs->ofnW;
109 if (ofnW->Flags & OFN_ENABLETEMPLATEHANDLE)
111 if (!(lfs->template = LockResource( ofnW->hInstance )))
113 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
117 else if (ofnW->Flags & OFN_ENABLETEMPLATE)
121 hResInfo = FindResourceA(lfs->ofnA->hInstance,
122 lfs->ofnA->lpTemplateName,
125 hResInfo = FindResourceW(ofnW->hInstance,
126 ofnW->lpTemplateName,
130 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
133 if (!(hDlgTmpl = LoadResource(ofnW->hInstance,
135 !(lfs->template = LockResource(hDlgTmpl)))
137 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
140 } else { /* get it from internal Wine resource */
142 if (!(hResInfo = FindResourceA(COMDLG32_hInstance,
143 lfs->open? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
145 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
148 if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo )) ||
149 !(lfs->template = LockResource( hDlgTmpl )))
151 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
159 /***********************************************************************
160 * Get16BitsTemplate [internal]
162 * Get a template (FALSE if failure) when 16 bits dialogs are used
163 * by a 16 bits application
166 BOOL Get16BitsTemplate(LFSPRIVATE lfs)
168 LPOPENFILENAME16 ofn16 = lfs->ofn16;
170 HGLOBAL16 hGlobal16 = 0;
172 if (ofn16->Flags & OFN_ENABLETEMPLATEHANDLE)
173 lfs->hDlgTmpl16 = ofn16->hInstance;
174 else if (ofn16->Flags & OFN_ENABLETEMPLATE)
177 if (!(hResInfo = FindResource16(ofn16->hInstance,
178 MapSL(ofn16->lpTemplateName),
181 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
184 if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo )))
186 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
189 lfs->hResource16 = lfs->hDlgTmpl16;
192 { /* get resource from (32 bits) own Wine resource; convert it to 16 */
198 if (!(hResInfo = FindResourceA(COMDLG32_hInstance,
199 lfs->open ? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
201 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
204 if (!(hDlgTmpl32 = LoadResource(COMDLG32_hInstance, hResInfo )) ||
205 !(template32 = LockResource( hDlgTmpl32 )))
207 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
210 size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
211 hGlobal16 = GlobalAlloc16(0, size);
214 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
215 ERR("alloc failure for %ld bytes\n", size);
218 template = GlobalLock16(hGlobal16);
221 COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
222 ERR("global lock failure for %x handle\n", hGlobal16);
223 GlobalFree16(hGlobal16);
226 ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
227 lfs->hDlgTmpl16 = hGlobal16;
228 lfs->hGlobal16 = hGlobal16;
233 /***********************************************************************
234 * FILEDLG_StripEditControl [internal]
235 * Strip pathnames off the contents of the edit control.
237 static void FILEDLG_StripEditControl(HWND hwnd)
239 WCHAR temp[BUFFILE], *cp;
241 GetDlgItemTextW( hwnd, edt1, temp, sizeof(temp)/sizeof(WCHAR));
242 cp = strrchrW(temp, '\\');
246 cp = strrchrW(temp, ':');
250 /* FIXME: shouldn't we do something with the result here? ;-) */
255 /***********************************************************************
256 * FILEDLG_CallWindowProc [internal]
258 * Call the appropriate hook
260 static BOOL FILEDLG_CallWindowProc(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
265 return (BOOL) CallWindowProcA(
266 (WNDPROC)lfs->ofnA->lpfnHook, lfs->hwnd,
267 wMsg, wParam, lParam);
272 return (BOOL) CallWindowProcW(
273 (WNDPROC)lfs->ofnW->lpfnHook, lfs->hwnd,
274 wMsg, wParam, lParam);
280 /***********************************************************************
281 * FILEDLG_ScanDir [internal]
283 BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath)
285 WCHAR buffer[BUFFILE];
288 HCURSOR hCursorWait, oldCursor;
290 TRACE("Trying to change to %s\n", debugstr_w(newPath));
291 if ( !SetCurrentDirectoryW( newPath ))
293 lstrcpynW(buffer, newPath, sizeof(buffer)/sizeof(WCHAR));
295 /* get the list of spec files */
296 GetDlgItemTextW(hWnd, edt1, buffer, sizeof(buffer)/sizeof(WCHAR));
298 hCursorWait = LoadCursorA(0, IDC_WAITA);
299 oldCursor = SetCursor(hCursorWait);
302 if ((hdlg = GetDlgItem(hWnd, lst1)) != 0) {
303 WCHAR* scptr; /* ptr on semi-colon */
304 WCHAR* filter = buffer;
306 TRACE("Using filter %s\n", debugstr_w(filter));
307 SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);
309 scptr = strchrW(filter, ';');
310 if (scptr) *scptr = 0;
311 while (*filter == ' ') filter++;
312 TRACE("Using file spec %s\n", debugstr_w(filter));
313 if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR)
315 if (scptr) *scptr = ';';
316 filter = (scptr) ? (scptr + 1) : 0;
320 /* list of directories */
321 strcpyW(buffer, FILE_star);
323 if ((hdlgDir = GetDlgItem(hWnd, lst2)) != 0) {
324 lRet = DlgDirListW(hWnd, buffer, lst2, stc1, DDL_EXCLUSIVE | DDL_DIRECTORY);
326 SetCursor(oldCursor);
331 /***********************************************************************
332 * FILEDLG_GetFileType [internal]
335 LPWSTR FILEDLG_GetFileType(LPWSTR cfptr, LPWSTR fptr, WORD index)
340 for ( ;(n = lstrlenW(cfptr)) != 0; i++)
345 cfptr += lstrlenW(cfptr) + 1;
348 for ( ;(n = lstrlenW(fptr)) != 0; i++)
353 fptr += lstrlenW(fptr) + 1;
355 return (LPWSTR) FILE_star; /* FIXME */
358 /***********************************************************************
359 * FILEDLG_WMDrawItem [internal]
361 LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
362 int savedlg, LPDRAWITEMSTRUCT lpdis)
366 COLORREF oldText = 0, oldBk = 0;
368 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
370 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) return FALSE;
371 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
374 if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
376 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
377 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
380 SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
382 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1,
383 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
384 &(lpdis->rcItem), str, lstrlenW(str), NULL);
386 if (lpdis->itemState & ODS_SELECTED)
387 DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
389 if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
391 SetBkColor( lpdis->hDC, oldBk );
392 SetTextColor( lpdis->hDC, oldText );
394 HeapFree(GetProcessHeap(), 0, str);
398 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
400 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
402 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
405 if (lpdis->itemState & ODS_SELECTED)
407 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
408 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
410 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
411 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
412 &(lpdis->rcItem), str, lstrlenW(str), NULL);
414 if (lpdis->itemState & ODS_SELECTED)
415 DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
417 if (lpdis->itemState & ODS_SELECTED)
419 SetBkColor( lpdis->hDC, oldBk );
420 SetTextColor( lpdis->hDC, oldText );
422 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);
423 HeapFree(GetProcessHeap(), 0, str);
426 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
429 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
431 SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
433 root[0] += str[2] - 'a';
434 switch(GetDriveTypeA(root))
436 case DRIVE_REMOVABLE: hIcon = hFloppy; break;
437 case DRIVE_CDROM: hIcon = hCDRom; break;
438 case DRIVE_REMOTE: hIcon = hNet; break;
440 default: hIcon = hHDisk; break;
442 if (lpdis->itemState & ODS_SELECTED)
444 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
445 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
447 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
448 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
449 &(lpdis->rcItem), str, lstrlenW(str), NULL);
451 if (lpdis->itemState & ODS_SELECTED)
453 SetBkColor( lpdis->hDC, oldBk );
454 SetTextColor( lpdis->hDC, oldText );
456 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);
457 HeapFree(GetProcessHeap(), 0, str);
463 /***********************************************************************
464 * FILEDLG_WMMeasureItem [internal]
466 static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
468 LPMEASUREITEMSTRUCT lpmeasure;
470 lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
471 lpmeasure->itemHeight = fldrHeight;
475 /***********************************************************************
476 * FILEDLG_WMInitDialog [internal]
479 static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
482 WCHAR tmpstr[BUFFILE];
483 LPWSTR pstr, old_pstr;
485 LFSPRIVATE lfs = (LFSPRIVATE) lParam;
487 if (!lfs) return FALSE;
488 SetPropA(hWnd, OFN_PROP, (HANDLE)lfs);
492 TRACE("flags=%lx initialdir=%s\n", ofn->Flags, debugstr_w(ofn->lpstrInitialDir));
494 SetWindowTextW( hWnd, ofn->lpstrTitle );
495 /* read custom filter information */
496 if (ofn->lpstrCustomFilter)
498 pstr = ofn->lpstrCustomFilter;
500 TRACE("lpstrCustomFilter = %p\n", pstr);
504 i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
505 (LPARAM)(ofn->lpstrCustomFilter) + n );
506 n += lstrlenW(pstr) + 1;
507 pstr += lstrlenW(pstr) + 1;
508 TRACE("add str=%s associated to %s\n",
509 debugstr_w(old_pstr), debugstr_w(pstr));
510 SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
511 n += lstrlenW(pstr) + 1;
512 pstr += lstrlenW(pstr) + 1;
515 /* read filter information */
516 if (ofn->lpstrFilter) {
517 pstr = (LPWSTR) ofn->lpstrFilter;
521 i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
522 (LPARAM)(ofn->lpstrFilter + n) );
523 n += lstrlenW(pstr) + 1;
524 pstr += lstrlenW(pstr) + 1;
525 TRACE("add str=%s associated to %s\n",
526 debugstr_w(old_pstr), debugstr_w(pstr));
527 SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
528 n += lstrlenW(pstr) + 1;
529 pstr += lstrlenW(pstr) + 1;
532 /* set default filter */
533 if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL)
534 ofn->nFilterIndex = 1;
535 SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);
536 lstrcpynW(tmpstr, FILEDLG_GetFileType(ofn->lpstrCustomFilter,
537 (LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
538 TRACE("nFilterIndex = %ld, SetText of edt1 to %s\n",
539 ofn->nFilterIndex, debugstr_w(tmpstr));
540 SetDlgItemTextW( hWnd, edt1, tmpstr );
543 DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
544 /* read initial directory */
545 /* FIXME: Note that this is now very version-specific (See MSDN description of
546 * the OPENFILENAME structure). For example under 2000/XP any path in the
547 * lpstrFile overrides the lpstrInitialDir, but not under 95/98/ME
549 if (ofn->lpstrInitialDir != NULL)
552 lstrcpynW(tmpstr, ofn->lpstrInitialDir, 511);
553 len = lstrlenW(tmpstr);
554 if (len > 0 && tmpstr[len-1] != '\\' && tmpstr[len-1] != ':') {
561 if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
563 if (!FILEDLG_ScanDir(hWnd, tmpstr))
564 WARN("Couldn't read initial directory %s!\n", debugstr_w(tmpstr));
566 /* select current drive in combo 2, omit missing drives */
569 char str[4] = "a:\\";
570 GetCurrentDirectoryA( sizeof(dir), dir );
571 for(i = 0, n = -1; i < 26; i++)
574 if (GetDriveTypeA(str) > DRIVE_NO_ROOT_DIR) n++;
575 if (toupper(str[0]) == toupper(dir[0])) break;
578 SendDlgItemMessageW(hWnd, cmb2, CB_SETCURSEL, n, 0);
579 if (!(ofn->Flags & OFN_SHOWHELP))
580 ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
581 if (ofn->Flags & OFN_HIDEREADONLY)
582 ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
584 return (BOOL) FILEDLG_CallWindowProc(lfs, WM_INITDIALOG, wParam, lfs->lParam);
588 /***********************************************************************
589 * FILEDLG_UpdateResult [internal]
590 * update the displayed file name (with path)
592 void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr)
595 LPOPENFILENAMEW ofnW = lfs->ofnW;
596 WCHAR tmpstr2[BUFFILE];
599 TRACE("%s\n", debugstr_w(tmpstr));
600 if(ofnW->Flags & OFN_NOVALIDATE)
603 GetCurrentDirectoryW(BUFFILE, tmpstr2);
604 lenstr2 = strlenW(tmpstr2);
606 tmpstr2[lenstr2++]='\\';
607 lstrcpynW(tmpstr2+lenstr2, tmpstr, BUFFILE-lenstr2);
609 lstrcpynW(ofnW->lpstrFile, tmpstr2, ofnW->nMaxFile);
610 if((bs = strrchrW(tmpstr2, '\\')) != NULL)
611 ofnW->nFileOffset = bs - tmpstr2 +1;
613 ofnW->nFileOffset = 0;
614 ofnW->nFileExtension = 0;
615 while(tmpstr2[ofnW->nFileExtension] != '.' && tmpstr2[ofnW->nFileExtension] != '\0')
616 ofnW->nFileExtension++;
617 if (tmpstr2[ofnW->nFileExtension] == '\0')
618 ofnW->nFileExtension = 0;
620 ofnW->nFileExtension++;
621 /* update the real client structures if any */
623 { /* we have to convert to short (8.3) path */
624 char tmp[1024]; /* MAX_PATHNAME_LEN */
625 LPOPENFILENAME16 ofn16 = lfs->ofn16;
626 char *dest = MapSL(ofn16->lpstrFile);
628 if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
629 tmp, sizeof(tmp), NULL, NULL ))
630 tmp[sizeof(tmp)-1] = 0;
631 GetShortPathNameA(tmp, dest, ofn16->nMaxFile);
633 /* the same procedure as every year... */
634 if((bs16 = strrchr(dest, '\\')) != NULL)
635 ofn16->nFileOffset = bs16 - dest +1;
637 ofn16->nFileOffset = 0;
638 ofn16->nFileExtension = 0;
639 while(dest[ofn16->nFileExtension] != '.' && dest[ofn16->nFileExtension] != '\0')
640 ofn16->nFileExtension++;
641 if (dest[ofn16->nFileExtension] == '\0')
642 ofn16->nFileExtension = 0;
644 ofn16->nFileExtension++;
648 if (ofnW->nMaxFile &&
649 !WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
650 lfs->ofnA->lpstrFile, ofnW->nMaxFile, NULL, NULL ))
651 lfs->ofnA->lpstrFile[ofnW->nMaxFile-1] = 0;
652 lfs->ofnA->nFileOffset = ofnW->nFileOffset;
653 lfs->ofnA->nFileExtension = ofnW->nFileExtension;
658 /***********************************************************************
659 * FILEDLG_UpdateFileTitle [internal]
660 * update the displayed file name (without path)
662 void FILEDLG_UpdateFileTitle(LFSPRIVATE lfs)
665 LPOPENFILENAMEW ofnW = lfs->ofnW;
666 if (ofnW->lpstrFileTitle != NULL)
668 lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0);
669 SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETTEXT, lRet,
670 (LPARAM)ofnW->lpstrFileTitle );
673 char *dest = MapSL(lfs->ofn16->lpstrFileTitle);
674 if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFileTitle, -1,
675 dest, ofnW->nMaxFileTitle, NULL, NULL ))
676 dest[ofnW->nMaxFileTitle-1] = 0;
680 if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFileTitle, -1,
681 lfs->ofnA->lpstrFileTitle, ofnW->nMaxFileTitle, NULL, NULL ))
682 lfs->ofnA->lpstrFileTitle[ofnW->nMaxFileTitle-1] = 0;
689 /***********************************************************************
690 * FILEDLG_DirListDblClick [internal]
692 static LRESULT FILEDLG_DirListDblClick( LFSPRIVATE lfs )
695 HWND hWnd = lfs->hwnd;
697 WCHAR tmpstr[BUFFILE];
699 /* get the raw string (with brackets) */
700 lRet = SendDlgItemMessageW(hWnd, lst2, LB_GETCURSEL, 0, 0);
701 if (lRet == LB_ERR) return TRUE;
702 pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC);
703 SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet,
705 strcpyW( tmpstr, pstr );
706 HeapFree(GetProcessHeap(), 0, pstr);
707 /* get the selected directory in tmpstr */
708 if (tmpstr[0] == '[')
710 tmpstr[lstrlenW(tmpstr) - 1] = 0;
711 strcpyW(tmpstr,tmpstr+1);
713 strcatW(tmpstr, FILE_bslash);
715 FILEDLG_ScanDir(hWnd, tmpstr);
719 if (FILEDLG_CallWindowProc(lfs, lfs->lbselchstring, lst2,
720 MAKELONG(lRet,CD_LBSELCHANGE)))
727 /***********************************************************************
728 * FILEDLG_FileListSelect [internal]
729 * called when a new item is picked in the file list
731 static LRESULT FILEDLG_FileListSelect( LFSPRIVATE lfs )
734 HWND hWnd = lfs->hwnd;
737 lRet = SendDlgItemMessageW(hWnd, lst1, LB_GETCURSEL16, 0, 0);
741 /* set the edit control to the choosen file */
742 if ((pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
744 SendDlgItemMessageW(hWnd, lst1, LB_GETTEXT, lRet,
746 SetDlgItemTextW( hWnd, edt1, pstr );
747 HeapFree(GetProcessHeap(), 0, pstr);
751 FILEDLG_CallWindowProc(lfs, lfs->lbselchstring, lst1,
752 MAKELONG(lRet,CD_LBSELCHANGE));
754 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD,
759 /***********************************************************************
760 * FILEDLG_TestPath [internal]
761 * before accepting the file name, test if it includes wild cards
762 * tries to scan the directory and returns TRUE if no error.
764 static LRESULT FILEDLG_TestPath( LFSPRIVATE lfs, LPWSTR path )
766 HWND hWnd = lfs->hwnd;
767 LPWSTR pBeginFileName, pstr2;
768 WCHAR tmpstr2[BUFFILE];
770 pBeginFileName = strrchrW(path, '\\');
771 if (pBeginFileName == NULL)
772 pBeginFileName = strrchrW(path, ':');
774 if (strchrW(path,'*') != NULL || strchrW(path,'?') != NULL)
776 /* edit control contains wildcards */
777 if (pBeginFileName != NULL)
779 lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE);
780 *(pBeginFileName + 1) = 0;
784 strcpyW(tmpstr2, path);
785 if(!(lfs->ofnW->Flags & OFN_NOVALIDATE))
789 TRACE("path=%s, tmpstr2=%s\n", debugstr_w(path), debugstr_w(tmpstr2));
790 SetDlgItemTextW( hWnd, edt1, tmpstr2 );
791 FILEDLG_ScanDir(hWnd, path);
792 return (lfs->ofnW->Flags & OFN_NOVALIDATE) ? TRUE : FALSE;
795 /* no wildcards, we might have a directory or a filename */
796 /* try appending a wildcard and reading the directory */
798 pstr2 = path + lstrlenW(path);
799 if (pBeginFileName == NULL || *(pBeginFileName + 1) != 0)
800 strcatW(path, FILE_bslash);
802 /* if ScanDir succeeds, we have changed the directory */
803 if (FILEDLG_ScanDir(hWnd, path))
806 /* if not, this must be a filename */
808 *pstr2 = 0; /* remove the wildcard added before */
810 if (pBeginFileName != NULL)
812 /* strip off the pathname */
814 SetDlgItemTextW( hWnd, edt1, pBeginFileName + 1 );
816 lstrcpynW(tmpstr2, pBeginFileName + 1, sizeof(tmpstr2)/sizeof(WCHAR) );
817 /* Should we MessageBox() if this fails? */
818 if (!FILEDLG_ScanDir(hWnd, path))
822 strcpyW(path, tmpstr2);
825 SetDlgItemTextW( hWnd, edt1, path );
829 /***********************************************************************
830 * FILEDLG_Validate [internal]
831 * called on: click Ok button, Enter in edit, DoubleClick in file list
833 static LRESULT FILEDLG_Validate( LFSPRIVATE lfs, LPWSTR path, UINT control, INT itemIndex,
837 HWND hWnd = lfs->hwnd;
838 OPENFILENAMEW ofnsav;
839 LPOPENFILENAMEW ofnW = lfs->ofnW;
840 WCHAR filename[BUFFILE];
842 ofnsav = *ofnW; /* for later restoring */
844 /* get current file name */
846 lstrcpynW(filename, path, sizeof(filename)/sizeof(WCHAR));
848 GetDlgItemTextW( hWnd, edt1, filename, sizeof(filename)/sizeof(WCHAR));
850 TRACE("got filename = %s\n", debugstr_w(filename));
851 /* if we did not click in file list to get there */
854 if (!FILEDLG_TestPath( lfs, filename) )
857 FILEDLG_UpdateResult(lfs, filename);
860 { /* called internally after a change in a combo */
863 FILEDLG_CallWindowProc(lfs, lfs->lbselchstring, control,
864 MAKELONG(itemIndex,CD_LBSELCHANGE));
869 FILEDLG_UpdateFileTitle(lfs);
872 lRet = (BOOL)FILEDLG_CallWindowProc(lfs, lfs->fileokstring,
876 *ofnW = ofnsav; /* restore old state */
880 if ((ofnW->Flags & OFN_ALLOWMULTISELECT) && (ofnW->Flags & OFN_EXPLORER))
884 LPWSTR str = (LPWSTR)ofnW->lpstrFile;
885 LPWSTR ptr = strrchrW(str, '\\');
886 str[lstrlenW(str) + 1] = '\0';
893 /***********************************************************************
894 * FILEDLG_DiskChange [internal]
895 * called when a new item is picked in the disk selection combo
897 static LRESULT FILEDLG_DiskChange( LFSPRIVATE lfs )
900 HWND hWnd = lfs->hwnd;
902 WCHAR diskname[BUFFILE];
904 FILEDLG_StripEditControl(hWnd);
905 lRet = SendDlgItemMessageW(hWnd, cmb2, CB_GETCURSEL, 0, 0L);
908 pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC);
909 SendDlgItemMessageW(hWnd, cmb2, CB_GETLBTEXT, lRet,
911 wsprintfW(diskname, FILE_specc, pstr[2]);
912 HeapFree(GetProcessHeap(), 0, pstr);
914 return FILEDLG_Validate( lfs, diskname, cmb2, lRet, TRUE );
918 /***********************************************************************
919 * FILEDLG_FileTypeChange [internal]
920 * called when a new item is picked in the file type combo
922 static LRESULT FILEDLG_FileTypeChange( LFSPRIVATE lfs )
925 WCHAR diskname[BUFFILE];
930 lRet = SendDlgItemMessageW(lfs->hwnd, cmb1, CB_GETCURSEL, 0, 0);
933 pstr = (LPWSTR)SendDlgItemMessageW(lfs->hwnd, cmb1, CB_GETITEMDATA, lRet, 0);
934 TRACE("Selected filter : %s\n", debugstr_w(pstr));
935 SetDlgItemTextW( lfs->hwnd, edt1, pstr );
937 return FILEDLG_Validate( lfs, NULL, cmb1, lRet, TRUE );
940 /***********************************************************************
941 * FILEDLG_WMCommand [internal]
943 LRESULT FILEDLG_WMCommand(HWND hWnd, LPARAM lParam, UINT notification,
944 UINT control, LFSPRIVATE lfs )
948 case lst1: /* file list */
949 FILEDLG_StripEditControl(hWnd);
950 if (notification == LBN_DBLCLK)
952 if (FILEDLG_Validate( lfs, NULL, control, 0, FALSE ))
953 EndDialog(hWnd, TRUE);
956 else if (notification == LBN_SELCHANGE)
957 return FILEDLG_FileListSelect( lfs );
960 case lst2: /* directory list */
961 FILEDLG_StripEditControl(hWnd);
962 if (notification == LBN_DBLCLK)
963 return FILEDLG_DirListDblClick( lfs );
966 case cmb1: /* file type drop list */
967 if (notification == CBN_SELCHANGE)
968 return FILEDLG_FileTypeChange( lfs );
977 case cmb2: /* disk dropdown combo */
978 if (notification == CBN_SELCHANGE)
979 return FILEDLG_DiskChange( lfs );
983 TRACE("OK pressed\n");
984 if (FILEDLG_Validate( lfs, NULL, control, 0, FALSE ))
985 EndDialog(hWnd, TRUE);
989 EndDialog(hWnd, FALSE);
992 case IDABORT: /* can be sent by the hook procedure */
993 EndDialog(hWnd, TRUE);
999 /***********************************************************************
1000 * FILEDLG_MapDrawItemStruct [internal]
1001 * map a 16 bits drawitem struct to 32
1003 void FILEDLG_MapDrawItemStruct(LPDRAWITEMSTRUCT16 lpdis16, LPDRAWITEMSTRUCT lpdis)
1005 lpdis->CtlType = lpdis16->CtlType;
1006 lpdis->CtlID = lpdis16->CtlID;
1007 lpdis->itemID = lpdis16->itemID;
1008 lpdis->itemAction = lpdis16->itemAction;
1009 lpdis->itemState = lpdis16->itemState;
1010 lpdis->hwndItem = HWND_32(lpdis16->hwndItem);
1011 lpdis->hDC = HDC_32(lpdis16->hDC);
1012 lpdis->rcItem.right = lpdis16->rcItem.right;
1013 lpdis->rcItem.left = lpdis16->rcItem.left;
1014 lpdis->rcItem.top = lpdis16->rcItem.top;
1015 lpdis->rcItem.bottom = lpdis16->rcItem.bottom;
1016 lpdis->itemData = lpdis16->itemData;
1019 /************************************************************************
1020 * FILEDLG_MapStringPairsToW [internal]
1021 * map string pairs to Unicode
1023 static LPWSTR FILEDLG_MapStringPairsToW(LPCSTR strA, UINT size)
1033 n = s + 1 - strA; /* Don't forget the other \0 */
1034 if (n < size) n = size;
1036 len = MultiByteToWideChar( CP_ACP, 0, strA, n, NULL, 0 );
1037 x = HeapAlloc(GetProcessHeap(),0, len * sizeof(WCHAR));
1038 MultiByteToWideChar( CP_ACP, 0, strA, n, x, len );
1043 /************************************************************************
1044 * FILEDLG_DupToW [internal]
1045 * duplicates an Ansi string to unicode, with a buffer size
1047 LPWSTR FILEDLG_DupToW(LPCSTR str, DWORD size)
1050 if (str && (size > 0))
1052 strW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
1053 if (strW) MultiByteToWideChar( CP_ACP, 0, str, -1, strW, size );
1059 /************************************************************************
1060 * FILEDLG_MapOfnStructA [internal]
1061 * map a 32 bits Ansi structure to an Unicode one
1063 void FILEDLG_MapOfnStructA(LPOPENFILENAMEA ofnA, LPOPENFILENAMEW ofnW, BOOL open)
1066 UNICODE_STRING usBuffer;
1068 ofnW->lStructSize = sizeof(OPENFILENAMEW);
1069 ofnW->hwndOwner = ofnA->hwndOwner;
1070 ofnW->hInstance = ofnA->hInstance;
1071 if (ofnA->lpstrFilter)
1072 ofnW->lpstrFilter = FILEDLG_MapStringPairsToW(ofnA->lpstrFilter, 0);
1074 if ((ofnA->lpstrCustomFilter) && (*(ofnA->lpstrCustomFilter)))
1075 ofnW->lpstrCustomFilter = FILEDLG_MapStringPairsToW(ofnA->lpstrCustomFilter, ofnA->nMaxCustFilter);
1076 ofnW->nMaxCustFilter = ofnA->nMaxCustFilter;
1077 ofnW->nFilterIndex = ofnA->nFilterIndex;
1078 ofnW->nMaxFile = ofnA->nMaxFile;
1079 ofnW->lpstrFile = FILEDLG_DupToW(ofnA->lpstrFile, ofnW->nMaxFile);
1080 ofnW->nMaxFileTitle = ofnA->nMaxFileTitle;
1081 ofnW->lpstrFileTitle = FILEDLG_DupToW(ofnA->lpstrFileTitle, ofnW->nMaxFileTitle);
1082 if (ofnA->lpstrInitialDir)
1084 RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpstrInitialDir);
1085 ofnW->lpstrInitialDir = usBuffer.Buffer;
1087 if (ofnA->lpstrTitle)
1088 str = ofnA->lpstrTitle;
1090 /* Allocates default title (FIXME : get it from resource) */
1091 str = open ? defaultopen:defaultsave;
1092 RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpstrTitle);
1093 ofnW->lpstrTitle = usBuffer.Buffer;
1094 ofnW->Flags = ofnA->Flags;
1095 ofnW->nFileOffset = ofnA->nFileOffset;
1096 ofnW->nFileExtension = ofnA->nFileExtension;
1097 ofnW->lpstrDefExt = FILEDLG_DupToW(ofnA->lpstrDefExt, 3);
1098 if ((ofnA->Flags & OFN_ENABLETEMPLATE) && (ofnA->lpTemplateName))
1100 if (HIWORD(ofnA->lpTemplateName))
1102 RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpTemplateName);
1103 ofnW->lpTemplateName = usBuffer.Buffer;
1105 else /* numbered resource */
1106 ofnW->lpTemplateName = (LPWSTR) ofnA->lpTemplateName;
1111 /************************************************************************
1112 * FILEDLG_MapOfnStruct16 [internal]
1113 * map a 16 bits structure to an Unicode one
1115 void FILEDLG_MapOfnStruct16(LPOPENFILENAME16 ofn16, LPOPENFILENAMEW ofnW, BOOL open)
1118 /* first convert to linear pointers */
1119 memset(&ofnA, 0, sizeof(OPENFILENAMEA));
1120 ofnA.lStructSize = sizeof(OPENFILENAMEA);
1121 ofnA.hwndOwner = HWND_32(ofn16->hwndOwner);
1122 ofnA.hInstance = HINSTANCE_32(ofn16->hInstance);
1123 if (ofn16->lpstrFilter)
1124 ofnA.lpstrFilter = MapSL(ofn16->lpstrFilter);
1125 if (ofn16->lpstrCustomFilter)
1126 ofnA.lpstrCustomFilter = MapSL(ofn16->lpstrCustomFilter);
1127 ofnA.nMaxCustFilter = ofn16->nMaxCustFilter;
1128 ofnA.nFilterIndex = ofn16->nFilterIndex;
1129 ofnA.lpstrFile = MapSL(ofn16->lpstrFile);
1130 ofnA.nMaxFile = ofn16->nMaxFile;
1131 ofnA.lpstrFileTitle = MapSL(ofn16->lpstrFileTitle);
1132 ofnA.nMaxFileTitle = ofn16->nMaxFileTitle;
1133 ofnA.lpstrInitialDir = MapSL(ofn16->lpstrInitialDir);
1134 ofnA.lpstrTitle = MapSL(ofn16->lpstrTitle);
1135 ofnA.Flags = ofn16->Flags;
1136 ofnA.nFileOffset = ofn16->nFileOffset;
1137 ofnA.nFileExtension = ofn16->nFileExtension;
1138 ofnA.lpstrDefExt = MapSL(ofn16->lpstrDefExt);
1139 if (HIWORD(ofn16->lpTemplateName))
1140 ofnA.lpTemplateName = MapSL(ofn16->lpTemplateName);
1142 ofnA.lpTemplateName = (LPSTR) ofn16->lpTemplateName; /* ressource number */
1143 /* now calls the 32 bits Ansi to Unicode version to complete the job */
1144 FILEDLG_MapOfnStructA(&ofnA, ofnW, open);
1148 /************************************************************************
1149 * FILEDLG_DestroyPrivate [internal]
1150 * destroys the private object
1152 void FILEDLG_DestroyPrivate(LFSPRIVATE lfs)
1157 /* free resources for a 16 bits dialog */
1158 if (lfs->hResource16) FreeResource16(lfs->hResource16);
1161 GlobalUnlock16(lfs->hGlobal16);
1162 GlobalFree16(lfs->hGlobal16);
1164 /* if ofnW has been allocated, have to free everything in it */
1165 if (lfs->ofn16 || lfs->ofnA)
1167 LPOPENFILENAMEW ofnW = lfs->ofnW;
1168 if (ofnW->lpstrFilter) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrFilter);
1169 if (ofnW->lpstrCustomFilter) HeapFree(GetProcessHeap(), 0, ofnW->lpstrCustomFilter);
1170 if (ofnW->lpstrFile) HeapFree(GetProcessHeap(), 0, ofnW->lpstrFile);
1171 if (ofnW->lpstrFileTitle) HeapFree(GetProcessHeap(), 0, ofnW->lpstrFileTitle);
1172 if (ofnW->lpstrInitialDir) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrInitialDir);
1173 if (ofnW->lpstrTitle) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrTitle);
1174 if ((ofnW->lpTemplateName) && (HIWORD(ofnW->lpTemplateName)))
1175 HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpTemplateName);
1176 HeapFree(GetProcessHeap(), 0, ofnW);
1178 TRACE("destroying private allocation %p\n", lfs);
1179 HeapFree(GetProcessHeap(), 0, lfs);
1180 RemovePropA(hwnd, OFN_PROP);
1183 /************************************************************************
1184 * FILEDLG_AllocPrivate [internal]
1185 * allocate a private object to hold 32 bits Unicode
1186 * structure that will be used throughtout the calls, while
1187 * keeping available the original structures and a few variables
1188 * On entry : type = dialog procedure type (16,32A,32W)
1189 * dlgType = dialog type (open or save)
1191 LFSPRIVATE FILEDLG_AllocPrivate(LPARAM lParam, int type, UINT dlgType)
1193 LFSPRIVATE lfs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct FSPRIVATE));
1195 TRACE("alloc private buf %p\n", lfs);
1196 if (!lfs) return NULL;
1198 lfs->lParam = lParam;
1199 if (dlgType == OPEN_DIALOG)
1203 lfs->lbselchstring = RegisterWindowMessageA(LBSELCHSTRINGA);
1204 lfs->fileokstring = RegisterWindowMessageA(FILEOKSTRINGA);
1208 lfs->ofn16 = MapSL(lParam);
1209 if (lfs->ofn16->Flags & OFN_ENABLEHOOK)
1210 if (lfs->ofn16->lpfnHook)
1216 lfs->ofnA = (LPOPENFILENAMEA) lParam;
1217 if (lfs->ofnA->Flags & OFN_ENABLEHOOK)
1218 if (lfs->ofnA->lpfnHook)
1223 lfs->ofnW = (LPOPENFILENAMEW) lParam;
1224 if (lfs->ofnW->Flags & OFN_ENABLEHOOK)
1225 if (lfs->ofnW->lpfnHook)
1231 { /* this structure is needed internally, so create it */
1232 lfs->ofnW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OPENFILENAMEW));
1236 FILEDLG_MapOfnStruct16(lfs->ofn16, lfs->ofnW, lfs->open);
1238 FILEDLG_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
1245 if (!Get16BitsTemplate(lfs)) ret = NULL;
1248 if (!Get32BitsTemplate(lfs)) ret = NULL;
1249 if (!ret) FILEDLG_DestroyPrivate(lfs);
1254 /***********************************************************************
1255 * GetFileName31A [internal]
1257 * Creates a win31 style dialog box for the user to select a file to open/save.
1259 BOOL WINAPI GetFileName31A(
1260 LPOPENFILENAMEA lpofn, /* addess of structure with data*/
1261 UINT dlgType /* type dialogue : open/save */
1268 if (!lpofn || !FileDlg_Init()) return FALSE;
1270 TRACE("ofn flags %08lx\n", lpofn->Flags);
1271 lfs = FILEDLG_AllocPrivate((LPARAM) lpofn, LFS32A, dlgType);
1274 hInst = (HINSTANCE)GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
1275 bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner,
1276 FileOpenDlgProc, (LPARAM)lfs);
1277 FILEDLG_DestroyPrivate(lfs);
1280 TRACE("return lpstrFile='%s' !\n", lpofn->lpstrFile);
1284 /***********************************************************************
1285 * GetFileName31W [internal]
1287 * Creates a win31 style dialog box for the user to select a file to open/save
1289 BOOL WINAPI GetFileName31W(
1290 LPOPENFILENAMEW lpofn, /* addess of structure with data*/
1291 UINT dlgType /* type dialogue : open/save */
1298 if (!lpofn || !FileDlg_Init()) return FALSE;
1300 lfs = FILEDLG_AllocPrivate((LPARAM) lpofn, LFS32W, dlgType);
1303 hInst = (HINSTANCE)GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
1304 bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner,
1305 FileOpenDlgProc, (LPARAM)lfs);
1306 FILEDLG_DestroyPrivate(lfs);
1309 TRACE("return lpstrFile=%s !\n", debugstr_w(lpofn->lpstrFile));
1313 /***********************************************************************
1314 * FileOpenDlgProc [internal]
1315 * Used for open and save, in fact.
1317 static INT_PTR CALLBACK FileOpenDlgProc(HWND hWnd, UINT wMsg,
1318 WPARAM wParam, LPARAM lParam)
1320 LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP);
1322 TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
1323 if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
1326 lRet = (INT_PTR)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
1328 return lRet; /* else continue message processing */
1333 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
1335 case WM_MEASUREITEM:
1336 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
1339 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, !lfs->open, (DRAWITEMSTRUCT *)lParam);
1342 return FILEDLG_WMCommand(hWnd, lParam, HIWORD(wParam), LOWORD(wParam), lfs);
1345 SetBkColor((HDC16)wParam, 0x00C0C0C0);
1346 switch (HIWORD(lParam))
1349 SetTextColor((HDC16)wParam, 0x00000000);
1351 case CTLCOLOR_STATIC:
1352 SetTextColor((HDC16)wParam, 0x00000000);
1361 /* ------------------ APIs ---------------------- */
1363 /***********************************************************************
1364 * GetOpenFileNameA (COMDLG32.@)
1366 * Creates a dialog box for the user to select a file to open.
1369 * TRUE on success: user enters a valid file
1370 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1373 BOOL WINAPI GetOpenFileNameA(
1374 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
1376 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
1377 COMDLG32_SetCommDlgExtendedError(0);
1378 /* some flags don't allow to match the TWEAK_WineLook */
1379 if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
1381 newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
1386 return GetFileDialog95A(ofn, OPEN_DIALOG);
1390 return GetFileName31A(ofn, OPEN_DIALOG);
1394 /***********************************************************************
1395 * GetOpenFileNameW (COMDLG32.@)
1397 * Creates a dialog box for the user to select a file to open.
1400 * TRUE on success: user enters a valid file
1401 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1404 BOOL WINAPI GetOpenFileNameW(
1405 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
1407 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
1408 COMDLG32_SetCommDlgExtendedError(0);
1409 /* some flags don't allow to match the TWEAK_WineLook */
1410 if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
1412 newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
1417 return GetFileDialog95W(ofn, OPEN_DIALOG);
1421 return GetFileName31W(ofn, OPEN_DIALOG);
1425 /***********************************************************************
1426 * GetSaveFileNameA (COMDLG32.@)
1428 * Creates a dialog box for the user to select a file to save.
1431 * TRUE on success: user enters a valid file
1432 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1435 BOOL WINAPI GetSaveFileNameA(
1436 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
1438 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
1439 COMDLG32_SetCommDlgExtendedError(0);
1440 /* some flags don't allow to match the TWEAK_WineLook */
1441 if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
1443 newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
1448 return GetFileDialog95A(ofn, SAVE_DIALOG);
1452 return GetFileName31A(ofn, SAVE_DIALOG);
1456 /***********************************************************************
1457 * GetSaveFileNameW (COMDLG32.@)
1459 * Creates a dialog box for the user to select a file to save.
1462 * TRUE on success: user enters a valid file
1463 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1466 BOOL WINAPI GetSaveFileNameW(
1467 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
1469 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
1470 COMDLG32_SetCommDlgExtendedError(0);
1471 /* some flags don't allow to match the TWEAK_WineLook */
1472 if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
1474 newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
1479 return GetFileDialog95W(ofn, SAVE_DIALOG);
1483 return GetFileName31W(ofn, SAVE_DIALOG);