source: trunk/src/comdlg32/filedlg.c@ 4932

Last change on this file since 4932 was 4932, checked in by sandervl, 25 years ago

Added Wine code for Windows 3.1 style common dialogs

File size: 53.3 KB
Line 
1/*
2 * COMMDLG - File Dialogs
3 *
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
6 */
7#include <ctype.h>
8#include <stdlib.h>
9#include <stdio.h>
10#include <string.h>
11#include "windef.h"
12#include "winnls.h"
13#include "winbase.h"
14#include "wingdi.h"
15#include "wine/winbase16.h"
16#include "wine/winuser16.h"
17#include "wine/unicode.h"
18#include "heap.h"
19#include "commdlg.h"
20#include "debugtools.h"
21#include "cderr.h"
22
23#ifdef __WIN32OS2__
24#include <win\cursoricon.h>
25
26#define GlobalFree16 GlobalFree
27#define GlobalLock16 GlobalLock
28#define GlobalUnlock16 GlobalUnlock
29#define GlobalAlloc16 GlobalAlloc
30#define FreeResource16 FreeResource
31#define LoadResource16 LoadResourceA
32#define FindResource16 FindResourceA
33#define MapSL(a) a
34#define CallWindowProc16 CallWindowProcA
35
36#endif
37
38DEFAULT_DEBUG_CHANNEL(commdlg);
39
40#include "cdlg.h"
41
42#define BUFFILE 512
43#define BUFFILEALLOC 512 * sizeof(WCHAR)
44
45struct FSPRIVATE
46{
47 HWND hwnd; /* file dialog window handle */
48 BOOL hook; /* TRUE if the dialog is hooked */
49 UINT lbselchstring; /* registered message id */
50 UINT fileokstring; /* registered message id */
51 LPARAM lParam; /* save original lparam */
52#ifdef __WIN32OS2__
53 HANDLE hDlgTmpl16; /* handle for resource 16 */
54 HANDLE hResource16; /* handle for allocated resource 16 */
55 HANDLE hGlobal16; /* 16 bits mem block (resources) */
56#else
57 HANDLE16 hDlgTmpl16; /* handle for resource 16 */
58 HANDLE16 hResource16; /* handle for allocated resource 16 */
59 HANDLE16 hGlobal16; /* 16 bits mem block (resources) */
60#endif
61 LPCVOID template; /* template for 32 bits resource */
62 BOOL open; /* TRUE if open dialog, FALSE if save dialog */
63 OPENFILENAMEW *ofnW; /* original structure or work struct */
64 OPENFILENAMEA *ofnA; /* original structure if 32bits ansi dialog */
65#ifndef __WIN32OS2__
66 OPENFILENAME16 *ofn16; /* original structure if 16 bits dialog */
67#endif
68};
69
70
71#define LFSPRIVATE struct FSPRIVATE *
72
73#define LFS16 1
74#define LFS32A 2
75#define LFS32W 3
76
77static const WCHAR FILE_star[] = {'*','.','*', 0};
78static const WCHAR FILE_bslash[] = {'\\', 0};
79static const WCHAR FILE_specc[] = {'%','c',':', 0};
80
81#ifdef __WIN32OS2__
82static HICON hFolder = 0;
83static HICON hFolder2 = 0;
84static HICON hFloppy = 0;
85static HICON hHDisk = 0;
86static HICON hCDRom = 0;
87static HICON hNet = 0;
88#else
89static HICON16 hFolder = 0;
90static HICON16 hFolder2 = 0;
91static HICON16 hFloppy = 0;
92static HICON16 hHDisk = 0;
93static HICON16 hCDRom = 0;
94static HICON16 hNet = 0;
95#endif
96static int fldrHeight = 0;
97static int fldrWidth = 0;
98
99#define OFN_PROP "FILEDLG_OFN"
100
101static const char defaultfilter[]=" \0\0";
102static char defaultopen[]="Open File";
103static char defaultsave[]="Save as";
104
105/***********************************************************************
106 *
107 * Windows 3.1 style OpenFileName/SaveFileName dialog
108 *
109 */
110
111LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
112 LPARAM lParam);
113LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
114 LPARAM lParam);
115
116static LRESULT WINAPI FileOpenDlgProc(HWND hDlg, UINT msg,
117 WPARAM wParam, LPARAM lParam);
118
119/***********************************************************************
120 * FileDlg_Init [internal]
121 */
122static BOOL FileDlg_Init(void)
123{
124 static BOOL initialized = 0;
125 CURSORICONINFO *fldrInfo;
126
127 if (!initialized) {
128 if (!hFolder) hFolder = LoadIconA(0, MAKEINTRESOURCEA(OIC_FOLDER));
129 if (!hFolder2) hFolder2 = LoadIconA(0, MAKEINTRESOURCEA(OIC_FOLDER2));
130 if (!hFloppy) hFloppy = LoadIconA(0, MAKEINTRESOURCEA(OIC_FLOPPY));
131 if (!hHDisk) hHDisk = LoadIconA(0, MAKEINTRESOURCEA(OIC_HDISK));
132 if (!hCDRom) hCDRom = LoadIconA(0, MAKEINTRESOURCEA(OIC_CDROM));
133 if (!hNet) hNet = LoadIconA(0, MAKEINTRESOURCEA(OIC_NETWORK));
134 if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
135 hHDisk == 0 || hCDRom == 0 || hNet == 0)
136 {
137 ERR("Error loading icons !\n");
138 return FALSE;
139 }
140 fldrInfo = (CURSORICONINFO *) GlobalLock16( hFolder2 );
141 if (!fldrInfo)
142 {
143 ERR("Error measuring icons !\n");
144 return FALSE;
145 }
146 fldrHeight = fldrInfo -> nHeight;
147 fldrWidth = fldrInfo -> nWidth;
148 GlobalUnlock16( hFolder2 );
149 initialized = TRUE;
150 }
151 return TRUE;
152}
153
154
155/***********************************************************************
156 * Get32BitsTemplate [internal]
157 *
158 * Get a template (or FALSE if failure) when 16 bits dialogs are used
159 * by a 32 bits application
160 *
161 */
162BOOL Get32BitsTemplate(LFSPRIVATE lfs)
163{
164 LPOPENFILENAMEW ofnW = lfs->ofnW;
165 HANDLE hDlgTmpl;
166
167 if (ofnW->Flags & OFN_ENABLETEMPLATEHANDLE)
168 {
169 if (!(lfs->template = LockResource( ofnW->hInstance )))
170 {
171 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
172 return FALSE;
173 }
174 }
175 else if (ofnW->Flags & OFN_ENABLETEMPLATE)
176 {
177 HANDLE hResInfo;
178 if (lfs->ofnA)
179 hResInfo = FindResourceA(lfs->ofnA->hInstance,
180 lfs->ofnA->lpTemplateName,
181 RT_DIALOGA);
182 else
183 hResInfo = FindResourceW(ofnW->hInstance,
184 ofnW->lpTemplateName,
185 RT_DIALOGW);
186 if (!hResInfo)
187 {
188 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
189 return FALSE;
190 }
191 if (!(hDlgTmpl = LoadResource(ofnW->hInstance,
192 hResInfo)) ||
193 !(lfs->template = LockResource(hDlgTmpl)))
194 {
195 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
196 return FALSE;
197 }
198 } else { /* get it from internal Wine resource */
199 HANDLE hResInfo;
200 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
201 lfs->open? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
202 {
203 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
204 return FALSE;
205 }
206 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
207 !(lfs->template = LockResource( hDlgTmpl )))
208 {
209 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
210 return FALSE;
211 }
212 }
213 return TRUE;
214}
215
216#ifndef __WIN32OS2__
217/***********************************************************************
218 * Get16BitsTemplate [internal]
219 *
220 * Get a template (FALSE if failure) when 16 bits dialogs are used
221 * by a 16 bits application
222 *
223 */
224BOOL Get16BitsTemplate(LFSPRIVATE lfs)
225{
226 LPOPENFILENAME16 ofn16 = lfs->ofn16;
227 LPCVOID template;
228 HGLOBAL16 hGlobal16 = 0;
229
230 if (ofn16->Flags & OFN_ENABLETEMPLATEHANDLE)
231 lfs->hDlgTmpl16 = ofn16->hInstance;
232 else if (ofn16->Flags & OFN_ENABLETEMPLATE)
233 {
234 HANDLE16 hResInfo;
235 if (!(hResInfo = FindResource16(ofn16->hInstance,
236 MapSL(ofn16->lpTemplateName),
237 RT_DIALOGA)))
238 {
239 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
240 return FALSE;
241 }
242 if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo )))
243 {
244 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
245 return FALSE;
246 }
247 lfs->hResource16 = lfs->hDlgTmpl16;
248 }
249 else
250 { /* get resource from (32 bits) own Wine resource; convert it to 16 */
251 HANDLE hResInfo, hDlgTmpl32;
252 LPCVOID template32;
253 DWORD size;
254
255 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
256 lfs->open ? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
257 {
258 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
259 return FALSE;
260 }
261 if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
262 !(template32 = LockResource( hDlgTmpl32 )))
263 {
264 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
265 return FALSE;
266 }
267 size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
268 hGlobal16 = GlobalAlloc16(0, size);
269 if (!hGlobal16)
270 {
271 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
272 ERR("alloc failure for %ld bytes\n", size);
273 return FALSE;
274 }
275 template = GlobalLock16(hGlobal16);
276 if (!template)
277 {
278 COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
279 ERR("global lock failure for %x handle\n", hGlobal16);
280 GlobalFree16(hGlobal16);
281 return FALSE;
282 }
283 ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
284 lfs->hDlgTmpl16 = hGlobal16;
285 lfs->hGlobal16 = hGlobal16;
286 }
287 return TRUE;
288}
289#endif
290
291/***********************************************************************
292 * FILEDLG_StripEditControl [internal]
293 * Strip pathnames off the contents of the edit control.
294 */
295static void FILEDLG_StripEditControl(HWND hwnd)
296{
297 WCHAR temp[BUFFILE], *cp;
298
299 GetDlgItemTextW( hwnd, edt1, temp, sizeof(temp)/sizeof(WCHAR));
300 cp = strrchrW(temp, '\\');
301 if (cp != NULL) {
302 strcpyW(temp, cp+1);
303 }
304 cp = strrchrW(temp, ':');
305 if (cp != NULL) {
306 strcpyW(temp, cp+1);
307 }
308 /* FIXME: shouldn't we do something with the result here? ;-) */
309}
310
311
312
313/***********************************************************************
314 * FILEDLG_CallWindowProc [internal]
315 *
316 * Call the appropriate hook
317 */
318static BOOL FILEDLG_CallWindowProc(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
319 LPARAM lParam)
320{
321#ifndef __WIN32OS2__
322 if (lfs->ofn16)
323 {
324 return (BOOL16) CallWindowProc16(
325 (WNDPROC16)lfs->ofn16->lpfnHook, lfs->hwnd,
326 (UINT16)wMsg, (WPARAM16)wParam, lParam);
327 }
328#endif
329 if (lfs->ofnA)
330 {
331 return (BOOL) CallWindowProcA(
332 (WNDPROC)lfs->ofnA->lpfnHook, lfs->hwnd,
333 wMsg, wParam, lParam);
334 }
335
336 if (lfs->ofnW)
337 {
338 return (BOOL) CallWindowProcW(
339 (WNDPROC)lfs->ofnW->lpfnHook, lfs->hwnd,
340 wMsg, wParam, lParam);
341 }
342 return FALSE;
343}
344
345
346/***********************************************************************
347 * FILEDLG_ScanDir [internal]
348 */
349static BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath)
350{
351 WCHAR buffer[BUFFILE];
352 HWND hdlg, hdlgDir;
353 LRESULT lRet = TRUE;
354 HCURSOR hCursorWait, oldCursor;
355
356 if ( !SetCurrentDirectoryW( newPath ))
357 return FALSE;
358 lstrcpynW(buffer, newPath, sizeof(buffer)/sizeof(WCHAR));
359
360 /* get the list of spec files */
361 GetDlgItemTextW(hWnd, edt1, buffer, sizeof(buffer)/sizeof(WCHAR));
362
363 hCursorWait = LoadCursorA(0, IDC_WAITA);
364 oldCursor = SetCursor(hCursorWait);
365
366 /* list of files */
367 if ((hdlg = GetDlgItem(hWnd, lst1)) != 0) {
368 WCHAR* scptr; /* ptr on semi-colon */
369 WCHAR* filter = buffer;
370
371 TRACE("Using filter %s\n", debugstr_w(filter));
372 SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);
373 while (filter) {
374 scptr = strchrW(filter, ';');
375 if (scptr) *scptr = 0;
376 while (*filter == ' ') filter++;
377 TRACE("Using file spec %s\n", debugstr_w(filter));
378 if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR)
379 return FALSE;
380 if (scptr) *scptr = ';';
381 filter = (scptr) ? (scptr + 1) : 0;
382 }
383 }
384
385 /* list of directories */
386 strcpyW(buffer, FILE_star);
387
388 if ((hdlgDir = GetDlgItem(hWnd, lst2)) != 0) {
389 lRet = DlgDirListW(hWnd, buffer, lst2, stc1, DDL_EXCLUSIVE | DDL_DIRECTORY);
390 }
391 SetCursor(oldCursor);
392 return lRet;
393}
394
395
396/***********************************************************************
397 * FILEDLG_GetFileType [internal]
398 */
399
400static LPWSTR FILEDLG_GetFileType(LPWSTR cfptr, LPWSTR fptr, WORD index)
401{
402 int n, i;
403 i = 0;
404 if (cfptr)
405 for ( ;(n = lstrlenW(cfptr)) != 0; i++)
406 {
407 cfptr += n + 1;
408 if (i == index)
409 return cfptr;
410 cfptr += lstrlenW(cfptr) + 1;
411 }
412 if (fptr)
413 for ( ;(n = lstrlenW(fptr)) != 0; i++)
414 {
415 fptr += n + 1;
416 if (i == index)
417 return fptr;
418 fptr += lstrlenW(fptr) + 1;
419 }
420 return (LPWSTR) FILE_star; /* FIXME */
421}
422
423/***********************************************************************
424 * FILEDLG_WMDrawItem [internal]
425 */
426static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
427 int savedlg, LPDRAWITEMSTRUCT lpdis)
428{
429 WCHAR *str;
430 HICON hIcon;
431 COLORREF oldText = 0, oldBk = 0;
432
433 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
434 {
435 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) return FALSE;
436 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
437 (LPARAM)str);
438
439 if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
440 {
441 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
442 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
443 }
444 if (savedlg)
445 SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
446
447 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1,
448 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
449 &(lpdis->rcItem), str, lstrlenW(str), NULL);
450
451 if (lpdis->itemState & ODS_SELECTED)
452 DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
453
454 if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
455 {
456 SetBkColor( lpdis->hDC, oldBk );
457 SetTextColor( lpdis->hDC, oldText );
458 }
459 HeapFree(GetProcessHeap(), 0, str);
460 return TRUE;
461 }
462
463 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
464 {
465 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
466 return FALSE;
467 SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
468 (LPARAM)str);
469
470 if (lpdis->itemState & ODS_SELECTED)
471 {
472 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
473 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
474 }
475 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
476 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
477 &(lpdis->rcItem), str, lstrlenW(str), NULL);
478
479 if (lpdis->itemState & ODS_SELECTED)
480 DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
481
482 if (lpdis->itemState & ODS_SELECTED)
483 {
484 SetBkColor( lpdis->hDC, oldBk );
485 SetTextColor( lpdis->hDC, oldText );
486 }
487 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);
488 HeapFree(GetProcessHeap(), 0, str);
489 return TRUE;
490 }
491 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
492 {
493 char root[] = "a:";
494 if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
495 return FALSE;
496 SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
497 (LPARAM)str);
498 root[0] += str[2] - 'a';
499 switch(GetDriveTypeA(root))
500 {
501 case DRIVE_REMOVABLE: hIcon = hFloppy; break;
502 case DRIVE_CDROM: hIcon = hCDRom; break;
503 case DRIVE_REMOTE: hIcon = hNet; break;
504 case DRIVE_FIXED:
505 default: hIcon = hHDisk; break;
506 }
507 if (lpdis->itemState & ODS_SELECTED)
508 {
509 oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
510 oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
511 }
512 ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
513 lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
514 &(lpdis->rcItem), str, lstrlenW(str), NULL);
515
516 if (lpdis->itemState & ODS_SELECTED)
517 {
518 SetBkColor( lpdis->hDC, oldBk );
519 SetTextColor( lpdis->hDC, oldText );
520 }
521 DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);
522 HeapFree(GetProcessHeap(), 0, str);
523 return TRUE;
524 }
525 return FALSE;
526}
527
528/***********************************************************************
529 * FILEDLG_WMMeasureItem [internal]
530 */
531static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
532{
533 LPMEASUREITEMSTRUCT lpmeasure;
534
535 lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
536 lpmeasure->itemHeight = fldrHeight;
537 return TRUE;
538}
539/***********************************************************************
540 * FILEDLG_WMMeasureItem16 [internal]
541 */
542#ifdef __WIN32OS2__
543static LONG FILEDLG_WMMeasureItem16(HWND hWnd, WPARAM wParam, LPARAM lParam)
544{
545 LPMEASUREITEMSTRUCT lpmeasure;
546
547 lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
548 lpmeasure->itemHeight = fldrHeight;
549 return TRUE;
550}
551#else
552static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
553{
554 LPMEASUREITEMSTRUCT16 lpmeasure;
555
556 lpmeasure = MapSL(lParam);
557 lpmeasure->itemHeight = fldrHeight;
558 return TRUE;
559}
560#endif
561
562/***********************************************************************
563 * FILEDLG_WMInitDialog [internal]
564 */
565
566static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
567{
568 int i, n;
569 WCHAR tmpstr[BUFFILE];
570 LPWSTR pstr, old_pstr;
571 LPOPENFILENAMEW ofn;
572 LFSPRIVATE lfs = (LFSPRIVATE) lParam;
573
574 if (!lfs) return FALSE;
575 SetPropA(hWnd, OFN_PROP, (HANDLE)lfs);
576 lfs->hwnd = hWnd;
577 ofn = lfs->ofnW;
578
579 TRACE("flags=%lx initialdir=%s\n", ofn->Flags, debugstr_w(ofn->lpstrInitialDir));
580
581 SetWindowTextW( hWnd, ofn->lpstrTitle );
582 /* read custom filter information */
583 if (ofn->lpstrCustomFilter)
584 {
585 pstr = ofn->lpstrCustomFilter;
586 n = 0;
587 TRACE("lpstrCustomFilter = %p\n", pstr);
588 while(*pstr)
589 {
590 old_pstr = pstr;
591 i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
592 (LPARAM)(ofn->lpstrCustomFilter) + n );
593 n += lstrlenW(pstr) + 1;
594 pstr += lstrlenW(pstr) + 1;
595 TRACE("add str='%s' "
596 "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));
597 SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
598 n += lstrlenW(pstr) + 1;
599 pstr += lstrlenW(pstr) + 1;
600 }
601 }
602 /* read filter information */
603 if (ofn->lpstrFilter) {
604 pstr = (LPWSTR) ofn->lpstrFilter;
605 n = 0;
606 while(*pstr) {
607 old_pstr = pstr;
608 i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
609 (LPARAM)(ofn->lpstrFilter + n) );
610 n += lstrlenW(pstr) + 1;
611 pstr += lstrlenW(pstr) + 1;
612 TRACE("add str='%s' "
613 "associated to '%s'\n", debugstr_w(old_pstr), debugstr_w(pstr));
614 SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
615 n += lstrlenW(pstr) + 1;
616 pstr += lstrlenW(pstr) + 1;
617 }
618 }
619 /* set default filter */
620 if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL)
621 ofn->nFilterIndex = 1;
622 SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);
623 lstrcpynW(tmpstr, FILEDLG_GetFileType(ofn->lpstrCustomFilter,
624 (LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
625 TRACE("nFilterIndex = %ld, SetText of edt1 to '%s'\n",
626 ofn->nFilterIndex, debugstr_w(tmpstr));
627 SetDlgItemTextW( hWnd, edt1, tmpstr );
628 /* get drive list */
629 *tmpstr = 0;
630 DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
631 /* read initial directory */
632 if (ofn->lpstrInitialDir != NULL)
633 {
634 int len;
635 lstrcpynW(tmpstr, ofn->lpstrInitialDir, 511);
636 len = lstrlenW(tmpstr);
637 if (len > 0 && tmpstr[len-1] != '\\' && tmpstr[len-1] != ':') {
638 tmpstr[len]='\\';
639 tmpstr[len+1]='\0';
640 }
641 }
642 else
643 *tmpstr = 0;
644 if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
645 *tmpstr = 0;
646 if (!FILEDLG_ScanDir(hWnd, tmpstr))
647 WARN("Couldn't read initial directory %s!\n", debugstr_w(tmpstr));
648 }
649 /* select current drive in combo 2, omit missing drives */
650 {
651 char dir[MAX_PATH];
652 char str[4] = "a:\\";
653 GetCurrentDirectoryA( sizeof(dir), dir );
654 for(i = 0, n = -1; i < 26; i++)
655 {
656 str[0] = 'a' + i;
657 if (GetDriveTypeA(str) <= DRIVE_NO_ROOT_DIR) n++;
658 if (toupper(str[0]) == toupper(dir[0])) break;
659 }
660 }
661 SendDlgItemMessageW(hWnd, cmb2, CB_SETCURSEL, n, 0);
662 if (!(ofn->Flags & OFN_SHOWHELP))
663 ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
664 if (ofn->Flags & OFN_HIDEREADONLY)
665 ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
666 if (lfs->hook)
667 return (BOOL) FILEDLG_CallWindowProc(lfs, WM_INITDIALOG, wParam, lfs->lParam);
668 return TRUE;
669}
670
671/***********************************************************************
672 * FILEDLG_UpdateResult [internal]
673 * update the displayed file name (with path)
674 */
675void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr)
676{
677 int lenstr2;
678 LPOPENFILENAMEW ofnW = lfs->ofnW;
679 WCHAR tmpstr2[BUFFILE];
680
681 GetCurrentDirectoryW(BUFFILE, tmpstr2);
682 lenstr2 = strlenW(tmpstr2);
683 if (lenstr2 > 3)
684 tmpstr2[lenstr2++]='\\';
685 lstrcpynW(tmpstr2+lenstr2, tmpstr, BUFFILE-lenstr2);
686 if (ofnW->lpstrFile)
687 lstrcpynW(ofnW->lpstrFile, tmpstr2, ofnW->nMaxFile);
688 ofnW->nFileOffset = strrchrW(tmpstr2,'\\') - tmpstr2 +1;
689 ofnW->nFileExtension = 0;
690 while(tmpstr2[ofnW->nFileExtension] != '.' && tmpstr2[ofnW->nFileExtension] != '\0')
691 ofnW->nFileExtension++;
692 if (tmpstr2[ofnW->nFileExtension] == '\0')
693 ofnW->nFileExtension = 0;
694 else
695 ofnW->nFileExtension++;
696 /* update the real client structures if any */
697#ifndef __WIN32OS2__
698 if (lfs->ofn16)
699 { /* we have to convert to short (8.3) path */
700 char tmp[1024]; /* MAX_PATHNAME_LEN */
701 LPOPENFILENAME16 ofn16 = lfs->ofn16;
702 char *dest = MapSL(ofn16->lpstrFile);
703 if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
704 tmp, ofnW->nMaxFile, NULL, NULL ))
705 tmp[ofnW->nMaxFile-1] = 0;
706 GetShortPathNameA(tmp, dest, ofn16->nMaxFile);
707
708 /* the same procedure as every year... */
709 ofn16->nFileOffset = strrchr(dest,'\\') - dest +1;
710 ofn16->nFileExtension = 0;
711 while(dest[ofn16->nFileExtension] != '.' && dest[ofn16->nFileExtension] != '\0')
712 ofn16->nFileExtension++;
713 if (dest[ofn16->nFileExtension] == '\0')
714 ofn16->nFileExtension = 0;
715 else
716 ofn16->nFileExtension++;
717 }
718#endif
719 if (lfs->ofnA)
720 {
721 if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
722 lfs->ofnA->lpstrFile, ofnW->nMaxFile, NULL, NULL ))
723 lfs->ofnA->lpstrFile[ofnW->nMaxFile-1] = 0;
724 lfs->ofnA->nFileOffset = ofnW->nFileOffset;
725 lfs->ofnA->nFileExtension = ofnW->nFileExtension;
726 }
727}
728
729
730/***********************************************************************
731 * FILEDLG_UpdateFileTitle [internal]
732 * update the displayed file name (without path)
733 */
734void FILEDLG_UpdateFileTitle(LFSPRIVATE lfs)
735{
736 LONG lRet;
737 LPOPENFILENAMEW ofnW = lfs->ofnW;
738 if (ofnW->lpstrFileTitle != NULL)
739 {
740 lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0);
741 SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETTEXT, lRet,
742 (LPARAM)ofnW->lpstrFileTitle );
743#ifndef __WIN32OS2__
744 if (lfs->ofn16)
745 {
746 char *dest = MapSL(lfs->ofn16->lpstrFileTitle);
747 if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFileTitle, -1,
748 dest, ofnW->nMaxFileTitle, NULL, NULL ))
749 dest[ofnW->nMaxFileTitle-1] = 0;
750 }
751#endif
752 if (lfs->ofnA)
753 {
754 if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFileTitle, -1,
755 lfs->ofnA->lpstrFileTitle, ofnW->nMaxFileTitle, NULL, NULL ))
756 lfs->ofnA->lpstrFileTitle[ofnW->nMaxFileTitle-1] = 0;
757 }
758 }
759}
760
761
762
763/***********************************************************************
764 * FILEDLG_DirListDblClick [internal]
765 */
766static LRESULT FILEDLG_DirListDblClick( LFSPRIVATE lfs )
767{
768 LONG lRet;
769 HWND hWnd = lfs->hwnd;
770 LPWSTR pstr;
771 WCHAR tmpstr[BUFFILE];
772
773 /* get the raw string (with brackets) */
774 lRet = SendDlgItemMessageW(hWnd, lst2, LB_GETCURSEL, 0, 0);
775 if (lRet == LB_ERR) return TRUE;
776 pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC);
777 SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet,
778 (LPARAM)pstr);
779 strcpyW( tmpstr, pstr );
780 HeapFree(GetProcessHeap(), 0, pstr);
781 /* get the selected directory in tmpstr */
782 if (tmpstr[0] == '[')
783 {
784 tmpstr[lstrlenW(tmpstr) - 1] = 0;
785 strcpyW(tmpstr,tmpstr+1);
786 }
787 strcatW(tmpstr, FILE_bslash);
788
789 FILEDLG_ScanDir(hWnd, tmpstr);
790 /* notify the app */
791 if (lfs->hook)
792 {
793 if (FILEDLG_CallWindowProc(lfs, lfs->lbselchstring, lst2,
794 MAKELONG(lRet,CD_LBSELCHANGE)))
795 return TRUE;
796 }
797 return TRUE;
798}
799
800
801/***********************************************************************
802 * FILEDLG_FileListSelect [internal]
803 * called when a new item is picked in the file list
804 */
805static LRESULT FILEDLG_FileListSelect( LFSPRIVATE lfs )
806{
807 LONG lRet;
808 HWND hWnd = lfs->hwnd;
809 LPWSTR pstr;
810
811#ifdef __WIN32OS2__
812 lRet = SendDlgItemMessageW(hWnd, lst1, LB_GETCURSEL, 0, 0);
813#else
814 lRet = SendDlgItemMessageW(hWnd, lst1, LB_GETCURSEL16, 0, 0);
815#endif
816 if (lRet == LB_ERR)
817 return TRUE;
818
819 /* set the edit control to the choosen file */
820 if ((pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
821 {
822 SendDlgItemMessageW(hWnd, lst1, LB_GETTEXT, lRet,
823 (LPARAM)pstr);
824 SetDlgItemTextW( hWnd, edt1, pstr );
825 HeapFree(GetProcessHeap(), 0, pstr);
826 }
827 if (lfs->hook)
828 {
829 FILEDLG_CallWindowProc(lfs, lfs->lbselchstring, lst1,
830 MAKELONG(lRet,CD_LBSELCHANGE));
831 }
832 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD,
833 CD_LBSELNOITEMS */
834 return TRUE;
835}
836
837/***********************************************************************
838 * FILEDLG_TestPath [internal]
839 * before accepting the file name, test if it includes wild cards
840 * tries to scan the directory and returns TRUE if no error.
841 */
842static LRESULT FILEDLG_TestPath( LFSPRIVATE lfs, LPWSTR path )
843{
844 HWND hWnd = lfs->hwnd;
845 LPWSTR pBeginFileName, pstr2;
846 WCHAR tmpstr2[BUFFILE];
847
848 pBeginFileName = strrchrW(path, '\\');
849 if (pBeginFileName == NULL)
850 pBeginFileName = strrchrW(path, ':');
851
852 if (strchrW(path,'*') != NULL || strchrW(path,'?') != NULL)
853 {
854 /* edit control contains wildcards */
855 if (pBeginFileName != NULL)
856 {
857 lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE);
858 *(pBeginFileName + 1) = 0;
859 }
860 else
861 {
862 strcpyW(tmpstr2, path);
863 *path = 0;
864 }
865
866 TRACE("path=%s, tmpstr2=%s\n", debugstr_w(path), debugstr_w(tmpstr2));
867 SetDlgItemTextW( hWnd, edt1, tmpstr2 );
868 FILEDLG_ScanDir(hWnd, path);
869 return FALSE;
870 }
871
872 /* no wildcards, we might have a directory or a filename */
873 /* try appending a wildcard and reading the directory */
874
875 pstr2 = path + lstrlenW(path);
876 if (pBeginFileName == NULL || *(pBeginFileName + 1) != 0)
877 strcatW(path, FILE_bslash);
878
879 /* if ScanDir succeeds, we have changed the directory */
880 if (FILEDLG_ScanDir(hWnd, path))
881 return TRUE;
882
883 /* if not, this must be a filename */
884
885 *pstr2 = 0; /* remove the wildcard added before */
886
887 if (pBeginFileName != NULL)
888 {
889 /* strip off the pathname */
890 *pBeginFileName = 0;
891 SetDlgItemTextW( hWnd, edt1, pBeginFileName + 1 );
892
893 lstrcpynW(tmpstr2, pBeginFileName + 1, sizeof(tmpstr2)/sizeof(WCHAR) );
894 /* Should we MessageBox() if this fails? */
895 if (!FILEDLG_ScanDir(hWnd, path))
896 {
897 return FALSE;
898 }
899 strcpyW(path, tmpstr2);
900 }
901 else
902 SetDlgItemTextW( hWnd, edt1, path );
903 return TRUE;
904}
905
906/***********************************************************************
907 * FILEDLG_Validate [internal]
908 * called on: click Ok button, Enter in edit, DoubleClick in file list
909 */
910static LRESULT FILEDLG_Validate( LFSPRIVATE lfs, LPWSTR path, UINT control, INT itemIndex,
911 BOOL internalUse )
912{
913 LONG lRet;
914 HWND hWnd = lfs->hwnd;
915 OPENFILENAMEW ofnsav;
916 LPOPENFILENAMEW ofnW = lfs->ofnW;
917 WCHAR filename[BUFFILE];
918
919 ofnsav = *ofnW; /* for later restoring */
920
921 /* get current file name */
922 if (path)
923 lstrcpynW(filename, path, sizeof(filename)/sizeof(WCHAR));
924 else
925 GetDlgItemTextW( hWnd, edt1, filename, sizeof(filename)/sizeof(WCHAR));
926
927 /* if we did not click in file list to get there */
928 if (control != lst1)
929 {
930 if (!FILEDLG_TestPath( lfs, filename) )
931 return FALSE;
932 }
933 FILEDLG_UpdateResult(lfs, filename);
934
935 if (internalUse)
936 { /* called internally after a change in a combo */
937 if (lfs->hook)
938 {
939 FILEDLG_CallWindowProc(lfs, lfs->lbselchstring, control,
940 MAKELONG(itemIndex,CD_LBSELCHANGE));
941 }
942 return TRUE;
943 }
944
945 FILEDLG_UpdateFileTitle(lfs);
946 if (lfs->hook)
947 {
948 lRet = (BOOL)FILEDLG_CallWindowProc(lfs, lfs->fileokstring,
949 0, lfs->lParam );
950 if (lRet)
951 {
952 *ofnW = ofnsav; /* restore old state */
953 return FALSE;
954 }
955 }
956 if ((ofnW->Flags & OFN_ALLOWMULTISELECT) && (ofnW->Flags & OFN_EXPLORER))
957 {
958 if (ofnW->lpstrFile)
959 {
960 LPWSTR str = (LPWSTR)ofnW->lpstrFile;
961 LPWSTR ptr = strrchrW(str, '\\');
962 str[lstrlenW(str) + 1] = '\0';
963 *ptr = 0;
964 }
965 }
966 return TRUE;
967}
968
969/***********************************************************************
970 * FILEDLG_DiskChange [internal]
971 * called when a new item is picked in the disk selection combo
972 */
973static LRESULT FILEDLG_DiskChange( LFSPRIVATE lfs )
974{
975 LONG lRet;
976 HWND hWnd = lfs->hwnd;
977 LPWSTR pstr;
978 WCHAR diskname[BUFFILE];
979
980 FILEDLG_StripEditControl(hWnd);
981 lRet = SendDlgItemMessageW(hWnd, cmb2, CB_GETCURSEL, 0, 0L);
982 if (lRet == LB_ERR)
983 return 0;
984 pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC);
985 SendDlgItemMessageW(hWnd, cmb2, CB_GETLBTEXT, lRet,
986 (LPARAM)pstr);
987 wsprintfW(diskname, FILE_specc, pstr[2]);
988 HeapFree(GetProcessHeap(), 0, pstr);
989
990 return FILEDLG_Validate( lfs, diskname, cmb2, lRet, TRUE );
991}
992
993
994/***********************************************************************
995 * FILEDLG_FileTypeChange [internal]
996 * called when a new item is picked in the file type combo
997 */
998static LRESULT FILEDLG_FileTypeChange( LFSPRIVATE lfs )
999{
1000 LONG lRet;
1001 WCHAR diskname[BUFFILE];
1002 LPWSTR pstr;
1003
1004 diskname[0] = 0;
1005
1006 lRet = SendDlgItemMessageW(lfs->hwnd, cmb1, CB_GETCURSEL, 0, 0);
1007 if (lRet == LB_ERR)
1008 return TRUE;
1009 pstr = (LPWSTR)SendDlgItemMessageW(lfs->hwnd, cmb1, CB_GETITEMDATA, lRet, 0);
1010 TRACE("Selected filter : %s\n", debugstr_w(pstr));
1011 SetDlgItemTextW( lfs->hwnd, edt1, pstr );
1012
1013 return FILEDLG_Validate( lfs, NULL, cmb1, lRet, TRUE );
1014}
1015
1016/***********************************************************************
1017 * FILEDLG_WMCommand [internal]
1018 */
1019static LRESULT FILEDLG_WMCommand(HWND hWnd, LPARAM lParam, UINT notification,
1020 UINT control, LFSPRIVATE lfs )
1021{
1022 switch (control)
1023 {
1024 case lst1: /* file list */
1025 FILEDLG_StripEditControl(hWnd);
1026 if (notification == LBN_DBLCLK)
1027 {
1028 if (FILEDLG_Validate( lfs, NULL, control, 0, FALSE ))
1029 EndDialog(hWnd, TRUE);
1030 return TRUE;
1031 }
1032 else if (notification == LBN_SELCHANGE)
1033 return FILEDLG_FileListSelect( lfs );
1034 break;
1035
1036 case lst2: /* directory list */
1037 FILEDLG_StripEditControl(hWnd);
1038 if (notification == LBN_DBLCLK)
1039 return FILEDLG_DirListDblClick( lfs );
1040 break;
1041
1042 case cmb1: /* file type drop list */
1043 if (notification == CBN_SELCHANGE)
1044 return FILEDLG_FileTypeChange( lfs );
1045 break;
1046
1047 case chx1:
1048 break;
1049
1050 case pshHelp:
1051 break;
1052
1053 case cmb2: /* disk dropdown combo */
1054 if (notification == CBN_SELCHANGE)
1055 return FILEDLG_DiskChange( lfs );
1056 break;
1057
1058 case IDOK:
1059 if (FILEDLG_Validate( lfs, NULL, control, 0, FALSE ))
1060 EndDialog(hWnd, TRUE);
1061 return TRUE;
1062
1063 case IDCANCEL:
1064 EndDialog(hWnd, FALSE);
1065 return TRUE;
1066
1067 case IDABORT: /* can be sent by the hook procedure */
1068 EndDialog(hWnd, TRUE);
1069 return TRUE;
1070 }
1071 return FALSE;
1072}
1073
1074#ifndef __WIN32OS2__
1075/***********************************************************************
1076 * FILEDLG_MapDrawItemStruct [internal]
1077 * map a 16 bits drawitem struct to 32
1078 */
1079void FILEDLG_MapDrawItemStruct(LPDRAWITEMSTRUCT16 lpdis16, LPDRAWITEMSTRUCT lpdis)
1080{
1081 lpdis->CtlType = lpdis16->CtlType;
1082 lpdis->CtlID = lpdis16->CtlID;
1083 lpdis->itemID = lpdis16->itemID;
1084 lpdis->itemAction = lpdis16->itemAction;
1085 lpdis->itemState = lpdis16->itemState;
1086 lpdis->hwndItem = lpdis16->hwndItem;
1087 lpdis->hDC = lpdis16->hDC;
1088 lpdis->rcItem.right = lpdis16->rcItem.right;
1089 lpdis->rcItem.left = lpdis16->rcItem.left;
1090 lpdis->rcItem.top = lpdis16->rcItem.top;
1091 lpdis->rcItem.bottom = lpdis16->rcItem.bottom;
1092 lpdis->itemData = lpdis16->itemData;
1093}
1094#endif
1095
1096/************************************************************************
1097 * FILEDLG_MapStringPairsToW [internal]
1098 * map string pairs to Unicode
1099 */
1100LPWSTR FILEDLG_MapStringPairsToW(LPCSTR strA, UINT size)
1101{
1102 LPCSTR s;
1103 LPWSTR x;
1104 int n, len;
1105
1106 s = strA;
1107 while (*s)
1108 s = s+strlen(s)+1;
1109 s++;
1110 n = s - strA;
1111 if (n < size) n = size;
1112
1113 len = MultiByteToWideChar( CP_ACP, 0, strA, n, NULL, 0 );
1114 x = HeapAlloc(GetProcessHeap(),0, len * sizeof(WCHAR));
1115 MultiByteToWideChar( CP_ACP, 0, strA, n, x, len );
1116 return x;
1117}
1118
1119
1120/************************************************************************
1121 * FILEDLG_DupToW [internal]
1122 * duplicates an Ansi string to unicode, with a buffer size
1123 */
1124LPWSTR FILEDLG_DupToW(LPCSTR str, DWORD size)
1125{
1126 LPWSTR strW = NULL;
1127 if (str && (size > 0))
1128 {
1129 strW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
1130 if (strW) MultiByteToWideChar( CP_ACP, 0, str, -1, strW, size );
1131 }
1132 return strW;
1133}
1134
1135
1136/************************************************************************
1137 * FILEDLG_MapOfnStructA [internal]
1138 * map a 32 bits Ansi structure to an Unicode one
1139 */
1140void FILEDLG_MapOfnStructA(LPOPENFILENAMEA ofnA, LPOPENFILENAMEW ofnW, BOOL open)
1141{
1142 LPCSTR str;
1143
1144 ofnW->lStructSize = sizeof(OPENFILENAMEW);
1145 ofnW->hwndOwner = ofnA->hwndOwner;
1146 ofnW->hInstance = ofnA->hInstance;
1147 if (ofnA->lpstrFilter)
1148 ofnW->lpstrFilter = FILEDLG_MapStringPairsToW(ofnA->lpstrFilter, 0);
1149 else
1150 ofnW->lpstrFilter = FILEDLG_MapStringPairsToW(defaultfilter, 0);
1151
1152 if ((ofnA->lpstrCustomFilter) && (*(ofnA->lpstrCustomFilter)))
1153 ofnW->lpstrCustomFilter = FILEDLG_MapStringPairsToW(ofnA->lpstrCustomFilter, ofnA->nMaxCustFilter);
1154 ofnW->nMaxCustFilter = ofnA->nMaxCustFilter;
1155 ofnW->nFilterIndex = ofnA->nFilterIndex;
1156 ofnW->nMaxFile = ofnA->nMaxFile;
1157 ofnW->lpstrFile = FILEDLG_DupToW(ofnA->lpstrFile, ofnW->nMaxFile);
1158 ofnW->nMaxFileTitle = ofnA->nMaxFileTitle;
1159 ofnW->lpstrFileTitle = FILEDLG_DupToW(ofnA->lpstrFileTitle, ofnW->nMaxFileTitle);
1160 if (ofnA->lpstrInitialDir)
1161 ofnW->lpstrInitialDir = HEAP_strdupAtoW(GetProcessHeap(),0,ofnA->lpstrInitialDir);
1162 if (ofnA->lpstrTitle)
1163 str = ofnA->lpstrTitle;
1164 else
1165 /* Allocates default title (FIXME : get it from resource) */
1166 str = open ? defaultopen:defaultsave;
1167 ofnW->lpstrTitle = HEAP_strdupAtoW(GetProcessHeap(),0, str);
1168 ofnW->Flags = ofnA->Flags;
1169 ofnW->nFileOffset = ofnA->nFileOffset;
1170 ofnW->nFileExtension = ofnA->nFileExtension;
1171 ofnW->lpstrDefExt = FILEDLG_DupToW(ofnA->lpstrDefExt, 3);
1172 if ((ofnA->Flags & OFN_ENABLETEMPLATE) && (ofnA->lpTemplateName))
1173 {
1174 if (HIWORD(ofnA->lpTemplateName))
1175 ofnW->lpTemplateName = HEAP_strdupAtoW(GetProcessHeap(), 0, ofnA->lpTemplateName);
1176 else /* numbered resource */
1177 ofnW->lpTemplateName = (LPWSTR) ofnA->lpTemplateName;
1178 }
1179}
1180
1181#ifndef __WIN32OS2__
1182/************************************************************************
1183 * FILEDLG_MapOfnStruct16 [internal]
1184 * map a 16 bits structure to an Unicode one
1185 */
1186void FILEDLG_MapOfnStruct16(LPOPENFILENAME16 ofn16, LPOPENFILENAMEW ofnW, BOOL open)
1187{
1188 OPENFILENAMEA ofnA;
1189 /* first convert to linear pointers */
1190 memset(&ofnA, 0, sizeof(OPENFILENAMEA));
1191 ofnA.lStructSize = sizeof(OPENFILENAMEA);
1192 ofnA.hwndOwner = ofn16->hwndOwner;
1193 ofnA.hInstance = ofn16->hInstance;
1194 if (ofn16->lpstrFilter)
1195 ofnA.lpstrFilter = MapSL(ofn16->lpstrFilter);
1196 if (ofn16->lpstrCustomFilter)
1197 ofnA.lpstrCustomFilter = MapSL(ofn16->lpstrCustomFilter);
1198 ofnA.nMaxCustFilter = ofn16->nMaxCustFilter;
1199 ofnA.nFilterIndex = ofn16->nFilterIndex;
1200 ofnA.lpstrFile = MapSL(ofn16->lpstrFile);
1201 ofnA.nMaxFile = ofn16->nMaxFile;
1202 ofnA.lpstrFileTitle = MapSL(ofn16->lpstrFileTitle);
1203 ofnA.nMaxFileTitle = ofn16->nMaxFileTitle;
1204 ofnA.lpstrInitialDir = MapSL(ofn16->lpstrInitialDir);
1205 ofnA.lpstrTitle = MapSL(ofn16->lpstrTitle);
1206 ofnA.Flags = ofn16->Flags;
1207 ofnA.nFileOffset = ofn16->nFileOffset;
1208 ofnA.nFileExtension = ofn16->nFileExtension;
1209 ofnA.lpstrDefExt = MapSL(ofn16->lpstrDefExt);
1210 if (HIWORD(ofn16->lpTemplateName))
1211 ofnA.lpTemplateName = MapSL(ofn16->lpTemplateName);
1212 else
1213 ofnA.lpTemplateName = (LPSTR) ofn16->lpTemplateName; /* ressource number */
1214 /* now calls the 32 bits Ansi to Unicode version to complete the job */
1215 FILEDLG_MapOfnStructA(&ofnA, ofnW, open);
1216}
1217#endif
1218
1219/************************************************************************
1220 * FILEDLG_DestroyPrivate [internal]
1221 * destroys the private object
1222 */
1223void FILEDLG_DestroyPrivate(LFSPRIVATE lfs)
1224{
1225 HWND hwnd;
1226 if (!lfs) return;
1227 hwnd = lfs->hwnd;
1228 /* free resources for a 16 bits dialog */
1229 if (lfs->hResource16) FreeResource16(lfs->hResource16);
1230 if (lfs->hGlobal16)
1231 {
1232 GlobalUnlock16(lfs->hGlobal16);
1233 GlobalFree16(lfs->hGlobal16);
1234 }
1235 /* if ofnW has been allocated, have to free everything in it */
1236#ifndef __WIN32OS2__
1237 if (lfs->ofn16 || lfs->ofnA)
1238#else
1239 if (lfs->ofnA)
1240#endif
1241 {
1242 LPOPENFILENAMEW ofnW = lfs->ofnW;
1243 if (ofnW->lpstrFilter) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrFilter);
1244 if (ofnW->lpstrCustomFilter) HeapFree(GetProcessHeap(), 0, ofnW->lpstrCustomFilter);
1245 if (ofnW->lpstrFile) HeapFree(GetProcessHeap(), 0, ofnW->lpstrFile);
1246 if (ofnW->lpstrFileTitle) HeapFree(GetProcessHeap(), 0, ofnW->lpstrFileTitle);
1247 if (ofnW->lpstrInitialDir) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrInitialDir);
1248 if (ofnW->lpstrTitle) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrTitle);
1249 if ((ofnW->lpTemplateName) && (HIWORD(ofnW->lpTemplateName)))
1250 HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpTemplateName);
1251 HeapFree(GetProcessHeap(), 0, ofnW);
1252 }
1253 TRACE("destroying private allocation %p\n", lfs);
1254 HeapFree(GetProcessHeap(), 0, lfs);
1255 RemovePropA(hwnd, OFN_PROP);
1256}
1257
1258/************************************************************************
1259 * FILEDLG_AllocPrivate [internal]
1260 * allocate a private object to hold 32 bits Unicode
1261 * structure that will be used throughtout the calls, while
1262 * keeping available the original structures and a few variables
1263 * On entry : type = dialog procedure type (16,32A,32W)
1264 * dlgType = dialog type (open or save)
1265 */
1266LFSPRIVATE FILEDLG_AllocPrivate(LPARAM lParam, int type, UINT dlgType)
1267{
1268 LFSPRIVATE lfs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct FSPRIVATE));
1269 LFSPRIVATE ret;
1270 TRACE("alloc private buf %p\n", lfs);
1271 if (!lfs) return NULL;
1272 lfs->hook = FALSE;
1273 lfs->lParam = lParam;
1274 if (dlgType == OPEN_DIALOG)
1275 lfs->open = TRUE;
1276 else
1277 lfs->open = FALSE;
1278 lfs->lbselchstring = RegisterWindowMessageA(LBSELCHSTRING);
1279 lfs->fileokstring = RegisterWindowMessageA(FILEOKSTRING);
1280 switch(type)
1281 {
1282#ifndef __WIN32OS2__
1283 case LFS16:
1284 lfs->ofn16 = MapSL(lParam);
1285 if (lfs->ofn16->Flags & OFN_ENABLEHOOK)
1286 if (lfs->ofn16->lpfnHook)
1287 lfs->hook = TRUE;
1288
1289 break;
1290#endif
1291 case LFS32A:
1292 lfs->ofnA = (LPOPENFILENAMEA) lParam;
1293 if (lfs->ofnA->Flags & OFN_ENABLEHOOK)
1294 if (lfs->ofnA->lpfnHook)
1295 lfs->hook = TRUE;
1296 break;
1297
1298 case LFS32W:
1299 lfs->ofnW = (LPOPENFILENAMEW) lParam;
1300 if (lfs->ofnW->Flags & OFN_ENABLEHOOK)
1301 if (lfs->ofnW->lpfnHook)
1302 lfs->hook = TRUE;
1303 break;
1304 }
1305 ret = lfs;
1306 if (!lfs->ofnW)
1307 { /* this structure is needed internally, so create it */
1308 lfs->ofnW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OPENFILENAMEW));
1309 if (lfs->ofnW)
1310 {
1311#ifndef __WIN32OS2__
1312 if (lfs->ofn16)
1313 FILEDLG_MapOfnStruct16(lfs->ofn16, lfs->ofnW, lfs->open);
1314#endif
1315 if (lfs->ofnA)
1316 FILEDLG_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
1317 }
1318 else
1319 ret = NULL;
1320 }
1321#ifndef __WIN32OS2__
1322 if (lfs->ofn16)
1323 {
1324 if (!Get16BitsTemplate(lfs)) ret = NULL;
1325 }
1326 else
1327#endif
1328 if (!Get32BitsTemplate(lfs)) ret = NULL;
1329 if (!ret) FILEDLG_DestroyPrivate(lfs);
1330 return ret;
1331}
1332
1333
1334/***********************************************************************
1335 * GetFileName31A [internal]
1336 *
1337 * Creates a win31 style dialog box for the user to select a file to open/save.
1338 */
1339BOOL WINAPI GetFileName31A(
1340 LPOPENFILENAMEA lpofn, /* addess of structure with data*/
1341 UINT dlgType /* type dialogue : open/save */
1342 )
1343{
1344 HINSTANCE hInst;
1345 BOOL bRet = FALSE;
1346 LFSPRIVATE lfs;
1347
1348 if (!lpofn || !FileDlg_Init()) return FALSE;
1349
1350 lfs = FILEDLG_AllocPrivate((LPARAM) lpofn, LFS32A, dlgType);
1351 if (lfs)
1352 {
1353 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
1354 bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner,
1355 (DLGPROC) FileOpenDlgProc, (DWORD) lfs);
1356 FILEDLG_DestroyPrivate(lfs);
1357 }
1358
1359 TRACE("return lpstrFile='%s' !\n", lpofn->lpstrFile);
1360 return bRet;
1361}
1362
1363
1364/***********************************************************************
1365 * GetFileName31W [internal]
1366 *
1367 * Creates a win31 style dialog box for the user to select a file to open/save
1368 */
1369BOOL WINAPI GetFileName31W(
1370 LPOPENFILENAMEW lpofn, /* addess of structure with data*/
1371 UINT dlgType /* type dialogue : open/save */
1372 )
1373{
1374 HINSTANCE hInst;
1375 BOOL bRet = FALSE;
1376 LFSPRIVATE lfs;
1377
1378 if (!lpofn || !FileDlg_Init()) return FALSE;
1379
1380 lfs = FILEDLG_AllocPrivate((LPARAM) lpofn, LFS32W, dlgType);
1381 if (lfs)
1382 {
1383 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
1384 bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner,
1385 (DLGPROC) FileOpenDlgProc, (DWORD) lfs);
1386 FILEDLG_DestroyPrivate(lfs);
1387 }
1388
1389 TRACE("return lpstrFile='%s' !\n", debugstr_w(lpofn->lpstrFile));
1390 return bRet;
1391}
1392
1393
1394/* ------------------ Dialog procedures ---------------------- */
1395
1396#ifndef __WIN32OS2__
1397/***********************************************************************
1398 * FileOpenDlgProc16 (COMMDLG.6)
1399 */
1400LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1401 LPARAM lParam)
1402{
1403 LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP);
1404 DRAWITEMSTRUCT dis;
1405
1406 TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
1407 if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
1408 {
1409 LRESULT lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
1410 if (lRet)
1411 return lRet; /* else continue message processing */
1412 }
1413 switch (wMsg)
1414 {
1415 case WM_INITDIALOG:
1416 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
1417
1418 case WM_MEASUREITEM:
1419 return FILEDLG_WMMeasureItem16(hWnd, wParam, lParam);
1420
1421 case WM_DRAWITEM:
1422 FILEDLG_MapDrawItemStruct(MapSL(lParam), &dis);
1423 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, FALSE, &dis);
1424
1425 case WM_COMMAND:
1426 return FILEDLG_WMCommand(hWnd, lParam, HIWORD(lParam),wParam, lfs);
1427#if 0
1428 case WM_CTLCOLOR:
1429 SetBkColor((HDC16)wParam, 0x00C0C0C0);
1430 switch (HIWORD(lParam))
1431 {
1432 case CTLCOLOR_BTN:
1433 SetTextColor((HDC16)wParam, 0x00000000);
1434 return hGRAYBrush;
1435 case CTLCOLOR_STATIC:
1436 SetTextColor((HDC16)wParam, 0x00000000);
1437 return hGRAYBrush;
1438 }
1439 break;
1440#endif
1441 }
1442 return FALSE;
1443}
1444
1445/***********************************************************************
1446 * FileSaveDlgProc16 (COMMDLG.7)
1447 */
1448LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1449 LPARAM lParam)
1450{
1451 LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP);
1452 DRAWITEMSTRUCT dis;
1453
1454 TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
1455 if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
1456 {
1457 LRESULT lRet;
1458 lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
1459 if (lRet)
1460 return lRet; /* else continue message processing */
1461 }
1462 switch (wMsg) {
1463 case WM_INITDIALOG:
1464 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
1465
1466 case WM_MEASUREITEM:
1467 return FILEDLG_WMMeasureItem16(hWnd, wParam, lParam);
1468
1469 case WM_DRAWITEM:
1470 FILEDLG_MapDrawItemStruct(MapSL(lParam), &dis);
1471 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, TRUE, &dis);
1472
1473 case WM_COMMAND:
1474 return FILEDLG_WMCommand(hWnd, lParam, HIWORD(lParam), wParam, lfs);
1475 }
1476
1477 /*
1478 case WM_CTLCOLOR:
1479 SetBkColor((HDC16)wParam, 0x00C0C0C0);
1480 switch (HIWORD(lParam))
1481 {
1482 case CTLCOLOR_BTN:
1483 SetTextColor((HDC16)wParam, 0x00000000);
1484 return hGRAYBrush;
1485 case CTLCOLOR_STATIC:
1486 SetTextColor((HDC16)wParam, 0x00000000);
1487 return hGRAYBrush;
1488 }
1489 return FALSE;
1490
1491 */
1492 return FALSE;
1493}
1494#endif //__WIN32OS2__
1495
1496/***********************************************************************
1497 * FileOpenDlgProc [internal]
1498 * Used for open and save, in fact.
1499 */
1500static LRESULT WINAPI FileOpenDlgProc(HWND hWnd, UINT wMsg,
1501 WPARAM wParam, LPARAM lParam)
1502{
1503 LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP);
1504
1505 TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
1506 if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
1507 {
1508 LRESULT lRet;
1509 lRet = (BOOL)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
1510 if (lRet)
1511 return lRet; /* else continue message processing */
1512 }
1513 switch (wMsg)
1514 {
1515 case WM_INITDIALOG:
1516 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
1517
1518 case WM_MEASUREITEM:
1519 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
1520
1521 case WM_DRAWITEM:
1522 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, !lfs->open, (DRAWITEMSTRUCT *)lParam);
1523
1524 case WM_COMMAND:
1525 return FILEDLG_WMCommand(hWnd, lParam, HIWORD(wParam), LOWORD(wParam), lfs);
1526#if 0
1527 case WM_CTLCOLOR:
1528 SetBkColor((HDC16)wParam, 0x00C0C0C0);
1529 switch (HIWORD(lParam))
1530 {
1531 case CTLCOLOR_BTN:
1532 SetTextColor((HDC16)wParam, 0x00000000);
1533 return hGRAYBrush;
1534 case CTLCOLOR_STATIC:
1535 SetTextColor((HDC16)wParam, 0x00000000);
1536 return hGRAYBrush;
1537 }
1538 break;
1539#endif
1540 }
1541 return FALSE;
1542}
1543
1544/* ------------------ APIs ---------------------- */
1545#ifndef __WIN32OS2__
1546/***********************************************************************
1547 * GetOpenFileName16 (COMMDLG.1)
1548 *
1549 * Creates a dialog box for the user to select a file to open.
1550 *
1551 * RETURNS
1552 * TRUE on success: user selected a valid file
1553 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1554 *
1555 * BUGS
1556 * unknown, there are some FIXME's left.
1557 */
1558BOOL16 WINAPI GetOpenFileName16(
1559 SEGPTR ofn /* [in/out] address of structure with data*/
1560 )
1561{
1562 HINSTANCE hInst;
1563 BOOL bRet = FALSE;
1564 LPOPENFILENAME16 lpofn = MapSL(ofn);
1565 LFSPRIVATE lfs;
1566 FARPROC16 ptr;
1567
1568 if (!lpofn || !FileDlg_Init()) return FALSE;
1569
1570 lfs = FILEDLG_AllocPrivate((LPARAM) ofn, LFS16, OPEN_DIALOG);
1571 if (lfs)
1572 {
1573 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
1574 ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 6);
1575 bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner,
1576 (DLGPROC16) ptr, (DWORD) lfs);
1577 FILEDLG_DestroyPrivate(lfs);
1578 }
1579
1580 TRACE("return lpstrFile='%s' !\n", (char *)MapSL(lpofn->lpstrFile));
1581 return bRet;
1582}
1583
1584/***********************************************************************
1585 * GetSaveFileName16 (COMMDLG.2)
1586 *
1587 * Creates a dialog box for the user to select a file to save.
1588 *
1589 * RETURNS
1590 * TRUE on success: user enters a valid file
1591 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1592 *
1593 * BUGS
1594 * unknown. There are some FIXME's left.
1595 */
1596BOOL16 WINAPI GetSaveFileName16(
1597 SEGPTR ofn /* [in/out] addess of structure with data*/
1598 )
1599{
1600 HINSTANCE hInst;
1601 BOOL bRet = FALSE;
1602 LPOPENFILENAME16 lpofn = MapSL(ofn);
1603 LFSPRIVATE lfs;
1604 FARPROC16 ptr;
1605
1606 if (!lpofn || !FileDlg_Init()) return FALSE;
1607
1608 lfs = FILEDLG_AllocPrivate((LPARAM) ofn, LFS16, SAVE_DIALOG);
1609 if (lfs)
1610 {
1611 hInst = GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
1612 ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 7);
1613 bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner,
1614 (DLGPROC16) ptr, (DWORD) lfs);
1615 FILEDLG_DestroyPrivate(lfs);
1616 }
1617
1618 TRACE("return lpstrFile='%s' !\n", (char *)MapSL(lpofn->lpstrFile));
1619 return bRet;
1620}
1621#endif //__WIN32OS2__
1622
1623/***********************************************************************
1624 * GetOpenFileNameA (COMDLG32.10)
1625 *
1626 * Creates a dialog box for the user to select a file to open.
1627 *
1628 * RETURNS
1629 * TRUE on success: user enters a valid file
1630 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1631 *
1632 */
1633BOOL WINAPI GetOpenFileNameA(
1634 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
1635{
1636 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
1637
1638#ifdef __WIN32OS2__
1639 dprintf(("GetOpenFileNameA %x", ofn));
1640#endif
1641
1642 /* some flags don't allow to match the TWEAK_WineLook */
1643 if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
1644 {
1645 newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
1646 }
1647
1648 if (newlook)
1649 {
1650 return GetFileDialog95A(ofn, OPEN_DIALOG);
1651 }
1652 else
1653 {
1654 return GetFileName31A(ofn, OPEN_DIALOG);
1655 }
1656}
1657
1658/***********************************************************************
1659 * GetOpenFileNameW (COMDLG32.11)
1660 *
1661 * Creates a dialog box for the user to select a file to open.
1662 *
1663 * RETURNS
1664 * TRUE on success: user enters a valid file
1665 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1666 *
1667 */
1668BOOL WINAPI GetOpenFileNameW(
1669 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
1670{
1671 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
1672
1673#ifdef __WIN32OS2__
1674 dprintf(("GetOpenFileNameW %x", ofn));
1675#endif
1676
1677 /* some flags don't allow to match the TWEAK_WineLook */
1678 if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
1679 {
1680 newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
1681 }
1682
1683 if (newlook)
1684 {
1685 return GetFileDialog95W(ofn, OPEN_DIALOG);
1686 }
1687 else
1688 {
1689 return GetFileName31W(ofn, OPEN_DIALOG);
1690 }
1691}
1692
1693/***********************************************************************
1694 * GetSaveFileNameA (COMDLG32.12)
1695 *
1696 * Creates a dialog box for the user to select a file to save.
1697 *
1698 * RETURNS
1699 * TRUE on success: user enters a valid file
1700 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1701 *
1702 */
1703BOOL WINAPI GetSaveFileNameA(
1704 LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
1705{
1706 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
1707
1708#ifdef __WIN32OS2__
1709 dprintf(("GetSaveFileNameA %x", ofn));
1710#endif
1711
1712 /* some flags don't allow to match the TWEAK_WineLook */
1713 if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
1714 {
1715 newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
1716 }
1717
1718 if (newlook)
1719 {
1720 return GetFileDialog95A(ofn, SAVE_DIALOG);
1721 }
1722 else
1723 {
1724 return GetFileName31A(ofn, SAVE_DIALOG);
1725 }
1726}
1727
1728/***********************************************************************
1729 * GetSaveFileNameW (COMDLG32.13)
1730 *
1731 * Creates a dialog box for the user to select a file to save.
1732 *
1733 * RETURNS
1734 * TRUE on success: user enters a valid file
1735 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
1736 *
1737 */
1738BOOL WINAPI GetSaveFileNameW(
1739 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
1740{
1741 BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
1742
1743#ifdef __WIN32OS2__
1744 dprintf(("GetSaveFileNameW %x", ofn));
1745#endif
1746
1747 /* some flags don't allow to match the TWEAK_WineLook */
1748 if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
1749 {
1750 newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
1751 }
1752
1753 if (newlook)
1754 {
1755 return GetFileDialog95W(ofn, SAVE_DIALOG);
1756 }
1757 else
1758 {
1759 return GetFileName31W(ofn, SAVE_DIALOG);
1760 }
1761}
Note: See TracBrowser for help on using the repository browser.