2 * COMMDLG - File Dialogs
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
12 #include "wine/winbase16.h"
13 #include "wine/winuser16.h"
27 DEFAULT_DEBUG_CHANNEL(commdlg)
31 static HICON16 hFolder = 0;
32 static HICON16 hFolder2 = 0;
33 static HICON16 hFloppy = 0;
34 static HICON16 hHDisk = 0;
35 static HICON16 hCDRom = 0;
36 static HICON16 hNet = 0;
37 static int fldrHeight = 0;
38 static int fldrWidth = 0;
40 static const char defaultfilter[]=" \0\0";
42 /***********************************************************************
43 * FileDlg_Init [internal]
45 static BOOL FileDlg_Init(void)
47 static BOOL initialized = 0;
48 CURSORICONINFO *fldrInfo;
51 if (!hFolder) hFolder = LoadIcon16(0, MAKEINTRESOURCE16(OIC_FOLDER));
52 if (!hFolder2) hFolder2 = LoadIcon16(0, MAKEINTRESOURCE16(OIC_FOLDER2));
53 if (!hFloppy) hFloppy = LoadIcon16(0, MAKEINTRESOURCE16(OIC_FLOPPY));
54 if (!hHDisk) hHDisk = LoadIcon16(0, MAKEINTRESOURCE16(OIC_HDISK));
55 if (!hCDRom) hCDRom = LoadIcon16(0, MAKEINTRESOURCE16(OIC_CDROM));
56 if (!hNet) hNet = LoadIcon16(0, MAKEINTRESOURCE16(OIC_NETWORK));
57 if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
58 hHDisk == 0 || hCDRom == 0 || hNet == 0)
60 ERR(commdlg, "Error loading icons !\n");
63 fldrInfo = (CURSORICONINFO *) GlobalLock16( hFolder2 );
66 ERR(commdlg, "Error measuring icons !\n");
69 fldrHeight = fldrInfo -> nHeight;
70 fldrWidth = fldrInfo -> nWidth;
71 GlobalUnlock16( hFolder2 );
77 /***********************************************************************
78 * GetOpenFileName16 (COMMDLG.1)
80 * Creates a dialog box for the user to select a file to open.
83 * TRUE on succes: user selected a valid file
84 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
87 * unknown, there are some FIXME's left.
89 BOOL16 WINAPI GetOpenFileName16(
90 SEGPTR ofn /* addess of structure with data*/
94 HANDLE hDlgTmpl = 0, hResInfo;
95 BOOL bRet = FALSE, win32Format = FALSE;
97 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
99 char defaultopen[]="Open File";
102 if (!lpofn || !FileDlg_Init()) return FALSE;
104 if (lpofn->Flags & OFN_WINE) {
105 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
107 if (!(template = LockResource( MapHModuleSL(lpofn->hInstance ))))
109 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
113 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
115 if (!(hResInfo = FindResourceA(MapHModuleSL(lpofn->hInstance),
116 PTR_SEG_TO_LIN(lpofn->lpTemplateName), RT_DIALOGA)))
118 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
121 if (!(hDlgTmpl = LoadResource( MapHModuleSL(lpofn->hInstance),
123 !(template = LockResource( hDlgTmpl )))
125 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
129 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "OPEN_FILE", RT_DIALOGA)))
131 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
134 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
135 !(template = LockResource( hDlgTmpl )))
137 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
143 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
145 if (!(template = LockResource16( lpofn->hInstance )))
147 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
151 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
153 if (!(hResInfo = FindResource16(lpofn->hInstance,
154 lpofn->lpTemplateName,
157 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
160 if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
161 !(template = LockResource16( hDlgTmpl )))
163 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
167 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "OPEN_FILE", RT_DIALOGA)))
169 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
172 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
173 !(template = LockResource( hDlgTmpl )))
175 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
182 hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
184 if (!(lpofn->lpstrFilter))
186 str = SEGPTR_ALLOC(sizeof(defaultfilter));
187 TRACE(commdlg,"Alloc %p default for Filetype in GetOpenFileName\n",str);
188 memcpy(str,defaultfilter,sizeof(defaultfilter));
189 lpofn->lpstrFilter=SEGPTR_GET(str);
192 if (!(lpofn->lpstrTitle))
194 str1 = SEGPTR_ALLOC(strlen(defaultopen)+1);
195 TRACE(commdlg,"Alloc %p default for Title in GetOpenFileName\n",str1);
196 strcpy(str1,defaultopen);
197 lpofn->lpstrTitle=SEGPTR_GET(str1);
200 /* FIXME: doesn't handle win32 format correctly yet */
201 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
203 (DLGPROC16)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
205 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
209 TRACE(commdlg,"Freeing %p default for Title in GetOpenFileName\n",str1);
216 TRACE(commdlg,"Freeing %p default for Filetype in GetOpenFileName\n",str);
218 lpofn->lpstrFilter=0;
222 if (lpofn->Flags & OFN_WINE)
223 FreeResource( hDlgTmpl );
225 FreeResource16( hDlgTmpl );
228 TRACE(commdlg,"return lpstrFile='%s' !\n",
229 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
234 /***********************************************************************
235 * GetSaveFileName (COMMDLG.2)
237 * Creates a dialog box for the user to select a file to save.
240 * TRUE on succes: user enters a valid file
241 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
244 * unknown. There are some FIXME's left.
246 BOOL16 WINAPI GetSaveFileName16(
247 SEGPTR ofn /* addess of structure with data*/
252 BOOL bRet = FALSE, win32Format = FALSE;
253 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
256 char defaultsave[]="Save as";
257 char *str =0,*str1=0;
259 if (!lpofn || !FileDlg_Init()) return FALSE;
261 if (lpofn->Flags & OFN_WINE) {
262 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
264 if (!(template = LockResource( MapHModuleSL(lpofn->hInstance ))))
266 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
270 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
273 if (!(hResInfo = FindResourceA(MapHModuleSL(lpofn->hInstance),
274 PTR_SEG_TO_LIN(lpofn->lpTemplateName),
277 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
280 if (!(hDlgTmpl = LoadResource(MapHModuleSL(lpofn->hInstance),
282 !(template = LockResource(hDlgTmpl)))
284 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
290 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "SAVE_FILE", RT_DIALOGA)))
292 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
295 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
296 !(template = LockResource( hDlgTmpl )))
298 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
304 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
306 if (!(template = LockResource16( lpofn->hInstance )))
308 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
312 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
315 if (!(hResInfo = FindResource16(lpofn->hInstance,
316 lpofn->lpTemplateName,
319 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
322 if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
323 !(template = LockResource16( hDlgTmpl )))
325 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
330 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "SAVE_FILE", RT_DIALOGA)))
332 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
335 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
336 !(template = LockResource( hDlgTmpl )))
338 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
345 hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
347 if (!(lpofn->lpstrFilter))
349 str = SEGPTR_ALLOC(sizeof(defaultfilter));
350 TRACE(commdlg,"Alloc default for Filetype in GetSaveFileName\n");
351 memcpy(str,defaultfilter,sizeof(defaultfilter));
352 lpofn->lpstrFilter=SEGPTR_GET(str);
355 if (!(lpofn->lpstrTitle))
357 str1 = SEGPTR_ALLOC(sizeof(defaultsave)+1);
358 TRACE(commdlg,"Alloc default for Title in GetSaveFileName\n");
359 strcpy(str1,defaultsave);
360 lpofn->lpstrTitle=SEGPTR_GET(str1);
363 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
365 (DLGPROC16)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
367 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
371 TRACE(commdlg,"Freeing %p default for Title in GetSaveFileName\n",str1);
378 TRACE(commdlg,"Freeing %p default for Filetype in GetSaveFileName\n",str);
380 lpofn->lpstrFilter=0;
384 if (lpofn->Flags & OFN_WINE)
385 FreeResource( hDlgTmpl );
387 FreeResource16( hDlgTmpl );
390 TRACE(commdlg, "return lpstrFile='%s' !\n",
391 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
395 /***********************************************************************
396 * FILEDLG_StripEditControl [internal]
397 * Strip pathnames off the contents of the edit control.
399 static void FILEDLG_StripEditControl(HWND16 hwnd)
403 GetDlgItemTextA( hwnd, edt1, temp, sizeof(temp) );
404 cp = strrchr(temp, '\\');
408 cp = strrchr(temp, ':');
412 /* FIXME: shouldn't we do something with the result here? ;-) */
415 /***********************************************************************
416 * FILEDLG_ScanDir [internal]
418 static BOOL FILEDLG_ScanDir(HWND16 hWnd, LPSTR newPath)
425 lstrcpynA(buffer, newPath, sizeof(buffer));
427 if (str[0] && (str[1] == ':')) {
428 drive = toupper(str[0]) - 'A';
430 if (!DRIVE_SetCurrentDrive(drive))
433 drive = DRIVE_GetCurrentDrive();
436 if (str[0] && !DRIVE_Chdir(drive, str)) {
440 GetDlgItemTextA(hWnd, edt1, buffer, sizeof(buffer));
441 if ((hlb = GetDlgItem(hWnd, lst1)) != 0) {
442 char* scptr; /* ptr on semi-colon */
443 char* filter = buffer;
445 TRACE(commdlg, "Using filter %s\n", filter);
446 SendMessageA(hlb, LB_RESETCONTENT, 0, 0);
448 scptr = strchr(filter, ';');
449 if (scptr) *scptr = 0;
450 TRACE(commdlg, "Using file spec %s\n", filter);
451 if (SendMessageA(hlb, LB_DIR, 0, (LPARAM)filter) == LB_ERR)
453 if (scptr) *scptr = ';';
454 filter = (scptr) ? (scptr + 1) : 0;
458 strcpy(buffer, "*.*");
459 return DlgDirListA(hWnd, buffer, lst2, stc1, DDL_EXCLUSIVE | DDL_DIRECTORY);
462 /***********************************************************************
463 * FILEDLG_GetFileType [internal]
466 static LPSTR FILEDLG_GetFileType(LPSTR cfptr, LPSTR fptr, WORD index)
471 for ( ;(n = strlen(cfptr)) != 0; i++)
476 cfptr += strlen(cfptr) + 1;
479 for ( ;(n = strlen(fptr)) != 0; i++)
484 fptr += strlen(fptr) + 1;
486 return "*.*"; /* FIXME */
489 /***********************************************************************
490 * FILEDLG_WMDrawItem [internal]
492 static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int savedlg)
494 LPDRAWITEMSTRUCT16 lpdis = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
497 COLORREF oldText = 0, oldBk = 0;
499 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
501 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
502 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
503 (LPARAM)SEGPTR_GET(str));
505 if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
507 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
508 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
511 SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
513 ExtTextOut16(lpdis->hDC, lpdis->rcItem.left + 1,
514 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
515 &(lpdis->rcItem), str, strlen(str), NULL);
517 if (lpdis->itemState & ODS_SELECTED)
518 DrawFocusRect16( lpdis->hDC, &(lpdis->rcItem) );
520 if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
522 SetBkColor( lpdis->hDC, oldBk );
523 SetTextColor( lpdis->hDC, oldText );
529 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
531 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
532 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
533 (LPARAM)SEGPTR_GET(str));
535 if (lpdis->itemState & ODS_SELECTED)
537 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
538 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
540 ExtTextOut16(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
541 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
542 &(lpdis->rcItem), str, strlen(str), NULL);
544 if (lpdis->itemState & ODS_SELECTED)
545 DrawFocusRect16( lpdis->hDC, &(lpdis->rcItem) );
547 if (lpdis->itemState & ODS_SELECTED)
549 SetBkColor( lpdis->hDC, oldBk );
550 SetTextColor( lpdis->hDC, oldText );
552 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);
556 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
558 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
559 SendMessage16(lpdis->hwndItem, CB_GETLBTEXT16, lpdis->itemID,
560 (LPARAM)SEGPTR_GET(str));
561 switch(DRIVE_GetType( str[2] - 'a' ))
563 case TYPE_FLOPPY: hIcon = hFloppy; break;
564 case TYPE_CDROM: hIcon = hCDRom; break;
565 case TYPE_NETWORK: hIcon = hNet; break;
567 default: hIcon = hHDisk; break;
569 if (lpdis->itemState & ODS_SELECTED)
571 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
572 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
574 ExtTextOut16(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
575 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
576 &(lpdis->rcItem), str, strlen(str), NULL);
578 if (lpdis->itemState & ODS_SELECTED)
580 SetBkColor( lpdis->hDC, oldBk );
581 SetTextColor( lpdis->hDC, oldText );
583 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);
590 /***********************************************************************
591 * FILEDLG_WMMeasureItem [internal]
593 static LONG FILEDLG_WMMeasureItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
595 LPMEASUREITEMSTRUCT16 lpmeasure;
597 lpmeasure = (LPMEASUREITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
598 lpmeasure->itemHeight = fldrHeight;
602 /***********************************************************************
603 * FILEDLG_HookCallChk [internal]
605 static int FILEDLG_HookCallChk(LPOPENFILENAME16 lpofn)
608 if (lpofn->Flags & OFN_ENABLEHOOK)
614 /***********************************************************************
615 * FILEDLG_CallWindowProc [internal]
617 * Adapt the structures back for win32 calls so the callee can read lpCustData
619 static BOOL FILEDLG_CallWindowProc(LPOPENFILENAME16 lpofn,HWND hwnd,
620 UINT wMsg,WPARAM wParam,LPARAM lParam
625 WINDOWPROCTYPE ProcType; /* Type of Hook Function to be called. */
627 /* TRUE if lParam points to the OPENFILENAME16 Structure */
628 needstruct = (PTR_SEG_TO_LIN(lParam) == lpofn);
630 ProcType = (lpofn->Flags & OFN_WINE)
631 ? (lpofn->Flags & OFN_UNICODE) /* 32-Bit call to GetOpenFileName */
632 ? WIN_PROC_32W : WIN_PROC_32A
633 : WIN_PROC_16; /* 16-Bit call to GetOpenFileName */
635 if (!(lpofn->Flags & OFN_WINE))
636 /* Call to 16-Bit Hooking function... No Problem at all. */
637 return (BOOL)CallWindowProc16(
638 lpofn->lpfnHook,hwnd,(UINT16)wMsg,(WPARAM16)wParam,lParam
643 /* Parameter lParam points to lpofn... Convert Structure Data... */
644 if (lpofn->Flags & OFN_UNICODE)
648 /* FIXME: probably needs more converted */
649 ofnw.lCustData = lpofn->lCustData;
650 return (BOOL)CallWindowProcW(
651 (WNDPROC)lpofn->lpfnHook,hwnd,wMsg,wParam,(LPARAM)&ofnw
654 else /* ! |OFN_UNICODE */
658 /* FIXME: probably needs more converted */
659 ofna.lCustData = lpofn->lCustData;
660 return (BOOL)CallWindowProcA(
661 (WNDPROC)lpofn->lpfnHook,hwnd,wMsg,wParam,(LPARAM)&ofna
665 else /* ! needstruct */
667 HWINDOWPROC hWindowProc=NULL;
669 if (WINPROC_SetProc(&hWindowProc, lpofn->lpfnHook, ProcType, WIN_PROC_WINDOW))
671 /* Call Window Procedure converting 16-Bit Type Parameters to 32-Bit Type Parameters */
672 result = CallWindowProc16( (WNDPROC16)hWindowProc,
673 hwnd, wMsg, wParam, lParam );
675 result = LOWORD(result);
677 WINPROC_FreeProc( hWindowProc, WIN_PROC_WINDOW );
686 /***********************************************************************
687 * FILEDLG_WMInitDialog [internal]
690 static LONG FILEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
693 LPOPENFILENAME16 lpofn;
695 LPSTR pstr, old_pstr;
696 SetWindowLongA(hWnd, DWL_USER, lParam);
697 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(lParam);
698 if (lpofn->lpstrTitle) SetWindowText16( hWnd, lpofn->lpstrTitle );
699 /* read custom filter information */
700 if (lpofn->lpstrCustomFilter)
702 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter);
704 TRACE(commdlg,"lpstrCustomFilter = %p\n", pstr);
708 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
709 (LPARAM)lpofn->lpstrCustomFilter + n );
710 n += strlen(pstr) + 1;
711 pstr += strlen(pstr) + 1;
712 TRACE(commdlg,"add str='%s' "
713 "associated to '%s'\n", old_pstr, pstr);
714 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
715 n += strlen(pstr) + 1;
716 pstr += strlen(pstr) + 1;
719 /* read filter information */
720 if (lpofn->lpstrFilter) {
721 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFilter);
725 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
726 (LPARAM)lpofn->lpstrFilter + n );
727 n += strlen(pstr) + 1;
728 pstr += strlen(pstr) + 1;
729 TRACE(commdlg,"add str='%s' "
730 "associated to '%s'\n", old_pstr, pstr);
731 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
732 n += strlen(pstr) + 1;
733 pstr += strlen(pstr) + 1;
736 /* set default filter */
737 if (lpofn->nFilterIndex == 0 && lpofn->lpstrCustomFilter == (SEGPTR)NULL)
738 lpofn->nFilterIndex = 1;
739 SendDlgItemMessage16(hWnd, cmb1, CB_SETCURSEL16, lpofn->nFilterIndex - 1, 0);
740 strncpy(tmpstr, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
741 PTR_SEG_TO_LIN(lpofn->lpstrFilter), lpofn->nFilterIndex - 1),511);
743 TRACE(commdlg,"nFilterIndex = %ld, SetText of edt1 to '%s'\n",
744 lpofn->nFilterIndex, tmpstr);
745 SetDlgItemTextA( hWnd, edt1, tmpstr );
748 DlgDirListComboBoxA(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
749 /* read initial directory */
750 if (PTR_SEG_TO_LIN(lpofn->lpstrInitialDir) != NULL)
752 strncpy(tmpstr, PTR_SEG_TO_LIN(lpofn->lpstrInitialDir), 510);
754 if (strlen(tmpstr) > 0 && tmpstr[strlen(tmpstr)-1] != '\\'
755 && tmpstr[strlen(tmpstr)-1] != ':')
760 if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
762 if (!FILEDLG_ScanDir(hWnd, tmpstr))
763 WARN(commdlg, "Couldn't read initial directory %s!\n",tmpstr);
765 /* select current drive in combo 2, omit missing drives */
766 for(i=0, n=-1; i<=DRIVE_GetCurrentDrive(); i++)
767 if (DRIVE_IsValid(i)) n++;
768 SendDlgItemMessage16(hWnd, cmb2, CB_SETCURSEL16, n, 0);
769 if (!(lpofn->Flags & OFN_SHOWHELP))
770 ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
771 if (lpofn->Flags & OFN_HIDEREADONLY)
772 ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
773 if (FILEDLG_HookCallChk(lpofn))
774 return (BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,WM_INITDIALOG,wParam,lParam );
779 /***********************************************************************
780 * FILEDLG_WMCommand [internal]
782 BOOL in_update=FALSE;
784 static LRESULT FILEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
787 LPOPENFILENAME16 lpofn;
789 char tmpstr[512], tmpstr2[512];
791 UINT16 control,notification;
793 /* Notifications are packaged differently in Win32 */
795 notification = HIWORD(lParam);
797 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLongA(hWnd, DWL_USER));
800 case lst1: /* file list */
801 FILEDLG_StripEditControl(hWnd);
802 if (notification == LBN_DBLCLK)
804 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
805 if (lRet == LB_ERR) return TRUE;
806 if ((pstr = SEGPTR_ALLOC(512)))
808 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
809 (LPARAM)SEGPTR_GET(pstr));
810 SetDlgItemTextA( hWnd, edt1, pstr );
813 if (FILEDLG_HookCallChk(lpofn))
814 FILEDLG_CallWindowProc(lpofn,hWnd,
815 RegisterWindowMessageA( LBSELCHSTRING ),
816 control, MAKELONG(lRet,CD_LBSELCHANGE));
817 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
819 case lst2: /* directory list */
820 FILEDLG_StripEditControl(hWnd);
821 if (notification == LBN_DBLCLK)
823 lRet = SendDlgItemMessage16(hWnd, lst2, LB_GETCURSEL16, 0, 0);
824 if (lRet == LB_ERR) return TRUE;
825 pstr = SEGPTR_ALLOC(512);
826 SendDlgItemMessage16(hWnd, lst2, LB_GETTEXT16, lRet,
827 (LPARAM)SEGPTR_GET(pstr));
828 strcpy( tmpstr, pstr );
830 if (tmpstr[0] == '[')
832 tmpstr[strlen(tmpstr) - 1] = 0;
833 strcpy(tmpstr,tmpstr+1);
835 strcat(tmpstr, "\\");
839 case cmb1: /* file type drop list */
840 if (notification == CBN_SELCHANGE)
850 case cmb2: /* disk drop list */
851 FILEDLG_StripEditControl(hWnd);
852 lRet = SendDlgItemMessage16(hWnd, cmb2, CB_GETCURSEL16, 0, 0L);
853 if (lRet == LB_ERR) return 0;
854 pstr = SEGPTR_ALLOC(512);
855 SendDlgItemMessage16(hWnd, cmb2, CB_GETLBTEXT16, lRet,
856 (LPARAM)SEGPTR_GET(pstr));
857 sprintf(tmpstr, "%c:", pstr[2]);
860 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
863 pstr = (LPSTR)SendDlgItemMessage16(hWnd, cmb1, CB_GETITEMDATA16, lRet, 0);
864 TRACE(commdlg,"Selected filter : %s\n", pstr);
865 SetDlgItemTextA( hWnd, edt1, pstr );
866 FILEDLG_ScanDir(hWnd, tmpstr);
870 ofn2=*lpofn; /* for later restoring */
871 GetDlgItemTextA( hWnd, edt1, tmpstr, sizeof(tmpstr) );
872 pstr = strrchr(tmpstr, '\\');
874 pstr = strrchr(tmpstr, ':');
875 if (strchr(tmpstr,'*') != NULL || strchr(tmpstr,'?') != NULL)
877 /* edit control contains wildcards */
880 strncpy(tmpstr2, pstr+1, 511); tmpstr2[511]=0;
885 strcpy(tmpstr2, tmpstr);
888 TRACE(commdlg,"tmpstr=%s, tmpstr2=%s\n", tmpstr, tmpstr2);
889 SetDlgItemTextA( hWnd, edt1, tmpstr2 );
890 FILEDLG_ScanDir(hWnd, tmpstr);
893 /* no wildcards, we might have a directory or a filename */
894 /* try appending a wildcard and reading the directory */
895 pstr2 = tmpstr + strlen(tmpstr);
896 if (pstr == NULL || *(pstr+1) != 0)
897 strcat(tmpstr, "\\");
898 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
899 if (lRet == LB_ERR) return TRUE;
900 lpofn->nFilterIndex = lRet + 1;
901 TRACE(commdlg,"lpofn->nFilterIndex=%ld\n", lpofn->nFilterIndex);
903 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
904 PTR_SEG_TO_LIN(lpofn->lpstrFilter),
905 lRet), sizeof(tmpstr2));
906 SetDlgItemTextA( hWnd, edt1, tmpstr2 );
908 /* if ScanDir succeeds, we have changed the directory */
909 if (FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
910 /* if not, this must be a filename */
914 /* strip off the pathname */
916 SetDlgItemTextA( hWnd, edt1, pstr + 1 );
917 lstrcpynA(tmpstr2, pstr+1, sizeof(tmpstr2) );
918 /* Should we MessageBox() if this fails? */
919 if (!FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
920 strcpy(tmpstr, tmpstr2);
922 else SetDlgItemTextA( hWnd, edt1, tmpstr );
924 ShowWindow16(hWnd, SW_HIDE); /* this should not be necessary ?! (%%%) */
927 int drive = DRIVE_GetCurrentDrive();
928 tmpstr2[0] = 'A'+ drive;
931 strncpy(tmpstr2 + 3, DRIVE_GetDosCwd(drive), 507); tmpstr2[510]=0;
932 if (strlen(tmpstr2) > 3)
933 strcat(tmpstr2, "\\");
934 strncat(tmpstr2, tmpstr, 511-strlen(tmpstr2)); tmpstr2[511]=0;
935 if (lpofn->lpstrFile)
936 lstrcpynA(PTR_SEG_TO_LIN(lpofn->lpstrFile), tmpstr2,lpofn->nMaxFile);
938 lpofn->nFileOffset = strrchr(tmpstr2,'\\') - tmpstr2 +1;
939 lpofn->nFileExtension = 0;
940 while(tmpstr2[lpofn->nFileExtension] != '.' && tmpstr2[lpofn->nFileExtension] != '\0')
941 lpofn->nFileExtension++;
942 if (tmpstr2[lpofn->nFileExtension] == '\0')
943 lpofn->nFileExtension = 0;
945 lpofn->nFileExtension++;
949 if (FILEDLG_HookCallChk(lpofn))
950 FILEDLG_CallWindowProc(lpofn,hWnd,
951 RegisterWindowMessageA( LBSELCHSTRING ),
952 control, MAKELONG(lRet,CD_LBSELCHANGE));
957 if (PTR_SEG_TO_LIN(lpofn->lpstrFileTitle) != NULL)
959 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
960 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
961 lpofn->lpstrFileTitle );
963 if (FILEDLG_HookCallChk(lpofn))
965 lRet= (BOOL16)FILEDLG_CallWindowProc(lpofn,
966 hWnd, RegisterWindowMessageA( FILEOKSTRING ), 0, lParam );
969 *lpofn=ofn2; /* restore old state */
971 ShowWindow16(hWnd, SW_SHOW); /* only if above (%%%) SW_HIDE used */
976 EndDialog(hWnd, TRUE);
979 EndDialog(hWnd, FALSE);
986 /***********************************************************************
987 * FileOpenDlgProc (COMMDLG.6)
989 LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
992 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLongA(hWnd, DWL_USER));
994 if (wMsg!=WM_INITDIALOG)
995 if (FILEDLG_HookCallChk(lpofn))
997 LRESULT lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
999 return lRet; /* else continue message processing */
1004 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
1005 case WM_MEASUREITEM:
1006 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
1008 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, FALSE);
1010 return FILEDLG_WMCommand(hWnd, wParam, lParam);
1013 SetBkColor((HDC16)wParam, 0x00C0C0C0);
1014 switch (HIWORD(lParam))
1017 SetTextColor((HDC16)wParam, 0x00000000);
1019 case CTLCOLOR_STATIC:
1020 SetTextColor((HDC16)wParam, 0x00000000);
1030 /***********************************************************************
1031 * FileSaveDlgProc (COMMDLG.7)
1033 LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1036 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLongA(hWnd, DWL_USER));
1038 if (wMsg!=WM_INITDIALOG)
1039 if (FILEDLG_HookCallChk(lpofn))
1041 LRESULT lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
1043 return lRet; /* else continue message processing */
1047 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
1049 case WM_MEASUREITEM:
1050 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
1053 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, TRUE);
1056 return FILEDLG_WMCommand(hWnd, wParam, lParam);
1061 SetBkColor((HDC16)wParam, 0x00C0C0C0);
1062 switch (HIWORD(lParam))
1065 SetTextColor((HDC16)wParam, 0x00000000);
1067 case CTLCOLOR_STATIC:
1068 SetTextColor((HDC16)wParam, 0x00000000);
1079 static BOOL Commdlg_GetFileNameA( BOOL16 (CALLBACK *dofunction)(SEGPTR x),
1080 LPOPENFILENAMEA ofn )
1083 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));
1085 memset(ofn16,'\0',sizeof(*ofn16));
1086 ofn16->lStructSize = sizeof(*ofn16);
1087 ofn16->hwndOwner = ofn->hwndOwner;
1088 ofn16->hInstance = MapHModuleLS(ofn->hInstance);
1089 if (ofn->lpstrFilter) {
1092 /* filter is a list... title\0ext\0......\0\0 */
1093 s = (LPSTR)ofn->lpstrFilter;
1097 x = (LPSTR)SEGPTR_ALLOC(s-ofn->lpstrFilter);
1098 memcpy(x,ofn->lpstrFilter,s-ofn->lpstrFilter);
1099 ofn16->lpstrFilter = SEGPTR_GET(x);
1101 if (ofn->lpstrCustomFilter) {
1104 /* filter is a list... title\0ext\0......\0\0 */
1105 s = (LPSTR)ofn->lpstrCustomFilter;
1109 x = SEGPTR_ALLOC(s-ofn->lpstrCustomFilter);
1110 memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);
1111 ofn16->lpstrCustomFilter = SEGPTR_GET(x);
1113 ofn16->nMaxCustFilter = ofn->nMaxCustFilter;
1114 ofn16->nFilterIndex = ofn->nFilterIndex;
1116 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));
1117 ofn16->nMaxFile = ofn->nMaxFile;
1118 ofn16->nMaxFileTitle = ofn->nMaxFileTitle;
1119 if (ofn16->nMaxFileTitle)
1120 ofn16->lpstrFileTitle = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFileTitle));
1121 if (ofn->lpstrInitialDir)
1122 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrInitialDir));
1123 if (ofn->lpstrTitle)
1124 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrTitle));
1125 ofn16->Flags = ofn->Flags|OFN_WINE;
1126 ofn16->nFileOffset = ofn->nFileOffset;
1127 ofn16->nFileExtension = ofn->nFileExtension;
1128 if (ofn->lpstrDefExt)
1129 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrDefExt));
1130 ofn16->lCustData = ofn->lCustData;
1131 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook;
1133 if (ofn->lpTemplateName)
1134 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpTemplateName));
1136 ret = dofunction(SEGPTR_GET(ofn16));
1138 ofn->nFileOffset = ofn16->nFileOffset;
1139 ofn->nFileExtension = ofn16->nFileExtension;
1140 if (ofn16->lpstrFilter)
1141 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));
1142 if (ofn16->lpTemplateName)
1143 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));
1144 if (ofn16->lpstrDefExt)
1145 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));
1146 if (ofn16->lpstrTitle)
1147 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));
1148 if (ofn16->lpstrInitialDir)
1149 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));
1150 if (ofn16->lpstrCustomFilter)
1151 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));
1153 if (ofn16->lpstrFile)
1155 strcpy(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));
1156 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));
1159 if (ofn16->lpstrFileTitle)
1161 if (ofn->lpstrFileTitle)
1162 strcpy(ofn->lpstrFileTitle,
1163 PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
1164 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
1170 static BOOL Commdlg_GetFileNameW( BOOL16 (CALLBACK *dofunction)(SEGPTR x),
1171 LPOPENFILENAMEW ofn )
1174 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));
1176 memset(ofn16,'\0',sizeof(*ofn16));
1177 ofn16->lStructSize = sizeof(*ofn16);
1178 ofn16->hwndOwner = ofn->hwndOwner;
1179 ofn16->hInstance = MapHModuleLS(ofn->hInstance);
1180 if (ofn->lpstrFilter) {
1185 /* filter is a list... title\0ext\0......\0\0 */
1186 s = (LPWSTR)ofn->lpstrFilter;
1188 s = s+lstrlenW(s)+1;
1190 n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */
1191 x = y = (LPSTR)SEGPTR_ALLOC(n);
1192 s = (LPWSTR)ofn->lpstrFilter;
1199 ofn16->lpstrFilter = SEGPTR_GET(y);
1201 if (ofn->lpstrCustomFilter) {
1206 /* filter is a list... title\0ext\0......\0\0 */
1207 s = (LPWSTR)ofn->lpstrCustomFilter;
1209 s = s+lstrlenW(s)+1;
1211 n = s - ofn->lpstrCustomFilter;
1212 x = y = (LPSTR)SEGPTR_ALLOC(n);
1213 s = (LPWSTR)ofn->lpstrCustomFilter;
1220 ofn16->lpstrCustomFilter = SEGPTR_GET(y);
1222 ofn16->nMaxCustFilter = ofn->nMaxCustFilter;
1223 ofn16->nFilterIndex = ofn->nFilterIndex;
1225 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));
1226 ofn16->nMaxFile = ofn->nMaxFile;
1227 ofn16->nMaxFileTitle = ofn->nMaxFileTitle;
1228 if (ofn->nMaxFileTitle)
1229 ofn16->lpstrFileTitle = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFileTitle));
1230 if (ofn->lpstrInitialDir)
1231 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrInitialDir));
1232 if (ofn->lpstrTitle)
1233 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrTitle));
1234 ofn16->Flags = ofn->Flags|OFN_WINE|OFN_UNICODE;
1235 ofn16->nFileOffset = ofn->nFileOffset;
1236 ofn16->nFileExtension = ofn->nFileExtension;
1237 if (ofn->lpstrDefExt)
1238 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrDefExt));
1239 ofn16->lCustData = ofn->lCustData;
1240 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook;
1241 if (ofn->lpTemplateName)
1242 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpTemplateName));
1243 ret = dofunction(SEGPTR_GET(ofn16));
1245 ofn->nFileOffset = ofn16->nFileOffset;
1246 ofn->nFileExtension = ofn16->nFileExtension;
1247 if (ofn16->lpstrFilter)
1248 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));
1249 if (ofn16->lpTemplateName)
1250 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));
1251 if (ofn16->lpstrDefExt)
1252 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));
1253 if (ofn16->lpstrTitle)
1254 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));
1255 if (ofn16->lpstrInitialDir)
1256 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));
1257 if (ofn16->lpstrCustomFilter)
1258 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));
1260 if (ofn16->lpstrFile) {
1261 lstrcpyAtoW(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));
1262 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));
1265 if (ofn16->lpstrFileTitle) {
1266 if (ofn->lpstrFileTitle)
1267 lstrcpyAtoW(ofn->lpstrFileTitle,
1268 PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
1269 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
1275 /***********************************************************************
1276 * GetOpenFileNameA (COMDLG32.10)
1278 * Creates a dialog box for the user to select a file to open.
1281 * TRUE on succes: user enters a valid file
1282 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1285 * unknown, calls its 16-bit equivalent.
1287 BOOL WINAPI GetOpenFileNameA(
1288 LPOPENFILENAMEA ofn /* address of init structure */
1291 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
1292 return Commdlg_GetFileNameA(dofunction,ofn);
1295 /***********************************************************************
1296 * GetOpenFileNameW (COMDLG32.11)
1298 * Creates a dialog box for the user to select a file to open.
1301 * TRUE on succes: user enters a valid file
1302 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1305 * unknown, calls its 16-bit equivalent.
1307 BOOL WINAPI GetOpenFileNameW(
1308 LPOPENFILENAMEW ofn /* address of init structure */
1311 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
1312 return Commdlg_GetFileNameW(dofunction,ofn);
1315 /***********************************************************************
1316 * GetSaveFileNameA (COMDLG32.12)
1318 * Creates a dialog box for the user to select a file to save.
1321 * TRUE on succes: user enters a valid file
1322 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1325 * unknown, calls its 16-bit equivalent.
1327 BOOL WINAPI GetSaveFileNameA(
1328 LPOPENFILENAMEA ofn /* address of init structure */
1331 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
1332 return Commdlg_GetFileNameA(dofunction,ofn);
1335 /***********************************************************************
1336 * GetSaveFileNameW (COMDLG32.13)
1338 * Creates a dialog box for the user to select a file to save.
1341 * TRUE on succes: user enters a valid file
1342 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1345 * unknown, calls its 16-bit equivalent.
1347 BOOL WINAPI GetSaveFileNameW(
1348 LPOPENFILENAMEW ofn /* address of init structure */
1351 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
1352 return Commdlg_GetFileNameW(dofunction,ofn);