Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/dlls/comdlg32/filedlg31.c
8852 views
1
/*
2
* Win 3.1 Style File Dialogs
3
*
4
* Copyright 1994 Martin Ayotte
5
* Copyright 1996 Albrecht Kleine
6
*
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.
11
*
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.
16
*
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20
*/
21
#include <ctype.h>
22
#include <stdlib.h>
23
#include <stdarg.h>
24
#include <stdio.h>
25
#include <string.h>
26
#include "windef.h"
27
#include "winbase.h"
28
#include "winnls.h"
29
#include "wingdi.h"
30
#include "winuser.h"
31
#include "wine/debug.h"
32
#include "winreg.h"
33
#include "winternl.h"
34
#include "commdlg.h"
35
#include "shlwapi.h"
36
#include "cderr.h"
37
38
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
39
40
#include "cdlg.h"
41
42
#define BUFFILE 512
43
#define BUFFILEALLOC 512 * sizeof(WCHAR)
44
45
static const int fldrHeight = 16;
46
static const int fldrWidth = 20;
47
48
static HICON hFolder = 0;
49
static HICON hFolder2 = 0;
50
static HICON hFloppy = 0;
51
static HICON hHDisk = 0;
52
static HICON hCDRom = 0;
53
static HICON hNet = 0;
54
55
#define FD31_OFN_PROP "FILEDLG_OFN"
56
57
typedef struct tagFD31_DATA
58
{
59
HWND hwnd; /* file dialog window handle */
60
BOOL hook; /* TRUE if the dialog is hooked */
61
UINT lbselchstring; /* registered message id */
62
UINT fileokstring; /* registered message id */
63
LPARAM lParam; /* save original lparam */
64
LPCVOID template; /* template for 32 bits resource */
65
BOOL open; /* TRUE if open dialog, FALSE if save dialog */
66
LPOPENFILENAMEW ofnW; /* pointer either to the original structure or
67
a W copy for A/16 API */
68
LPOPENFILENAMEA ofnA; /* original structure if 32bits ansi dialog */
69
} FD31_DATA, *PFD31_DATA;
70
71
/***********************************************************************
72
* FD31_Init [internal]
73
*/
74
static BOOL FD31_Init(void)
75
{
76
static BOOL initialized = FALSE;
77
78
if (!initialized) {
79
hFolder = LoadImageA( COMDLG32_hInstance, "FOLDER", IMAGE_ICON, 16, 16, LR_SHARED );
80
hFolder2 = LoadImageA( COMDLG32_hInstance, "FOLDER2", IMAGE_ICON, 16, 16, LR_SHARED );
81
hFloppy = LoadImageA( COMDLG32_hInstance, "FLOPPY", IMAGE_ICON, 16, 16, LR_SHARED );
82
hHDisk = LoadImageA( COMDLG32_hInstance, "HDISK", IMAGE_ICON, 16, 16, LR_SHARED );
83
hCDRom = LoadImageA( COMDLG32_hInstance, "CDROM", IMAGE_ICON, 16, 16, LR_SHARED );
84
hNet = LoadImageA( COMDLG32_hInstance, "NETWORK", IMAGE_ICON, 16, 16, LR_SHARED );
85
if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
86
hHDisk == 0 || hCDRom == 0 || hNet == 0)
87
{
88
ERR("Error loading icons!\n");
89
return FALSE;
90
}
91
initialized = TRUE;
92
}
93
return TRUE;
94
}
95
96
/***********************************************************************
97
* FD31_StripEditControl [internal]
98
* Strip pathnames off the contents of the edit control.
99
*/
100
static void FD31_StripEditControl(HWND hwnd)
101
{
102
WCHAR temp[BUFFILE], *cp;
103
104
GetDlgItemTextW( hwnd, edt1, temp, ARRAY_SIZE(temp));
105
cp = wcsrchr(temp, '\\');
106
if (cp != NULL) {
107
lstrcpyW(temp, cp+1);
108
}
109
cp = wcsrchr(temp, ':');
110
if (cp != NULL) {
111
lstrcpyW(temp, cp+1);
112
}
113
/* FIXME: shouldn't we do something with the result here? ;-) */
114
}
115
116
/***********************************************************************
117
* FD31_CallWindowProc [internal]
118
*
119
* Call the appropriate hook
120
*/
121
static BOOL FD31_CallWindowProc(const FD31_DATA *lfs, UINT wMsg, WPARAM wParam, LPARAM lParam)
122
{
123
BOOL ret;
124
125
if (lfs->ofnA)
126
{
127
TRACE("Call hookA %p (%p, %04x, %08Ix, %08Ix)\n",
128
lfs->ofnA->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
129
ret = lfs->ofnA->lpfnHook(lfs->hwnd, wMsg, wParam, lParam);
130
TRACE("ret hookA %p (%p, %04x, %08Ix, %08Ix)\n",
131
lfs->ofnA->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
132
return ret;
133
}
134
135
TRACE("Call hookW %p (%p, %04x, %08Ix, %08Ix)\n",
136
lfs->ofnW->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
137
ret = lfs->ofnW->lpfnHook(lfs->hwnd, wMsg, wParam, lParam);
138
TRACE("Ret hookW %p (%p, %04x, %08Ix, %08Ix)\n",
139
lfs->ofnW->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
140
return ret;
141
}
142
143
/***********************************************************************
144
* FD31_GetFileType [internal]
145
*/
146
static LPCWSTR FD31_GetFileType(LPCWSTR cfptr, LPCWSTR fptr, const WORD index)
147
{
148
int n, i;
149
i = 0;
150
if (cfptr)
151
for ( ;(n = lstrlenW(cfptr)) != 0; i++)
152
{
153
cfptr += n + 1;
154
if (i == index)
155
return cfptr;
156
cfptr += lstrlenW(cfptr) + 1;
157
}
158
if (fptr)
159
for ( ;(n = lstrlenW(fptr)) != 0; i++)
160
{
161
fptr += n + 1;
162
if (i == index)
163
return fptr;
164
fptr += lstrlenW(fptr) + 1;
165
}
166
return L"*.*"; /* FIXME */
167
}
168
169
/***********************************************************************
170
* FD31_ScanDir [internal]
171
*/
172
static BOOL FD31_ScanDir(const OPENFILENAMEW *ofn, HWND hWnd, LPCWSTR newPath)
173
{
174
WCHAR buffer[BUFFILE];
175
HWND hdlg;
176
LRESULT lRet = TRUE;
177
HCURSOR hCursorWait, oldCursor;
178
179
TRACE("Trying to change to %s\n", debugstr_w(newPath));
180
if ( newPath[0] && !SetCurrentDirectoryW( newPath ))
181
return FALSE;
182
183
/* get the list of spec files */
184
lstrcpynW(buffer, FD31_GetFileType(ofn->lpstrCustomFilter,
185
ofn->lpstrFilter, ofn->nFilterIndex - 1), BUFFILE);
186
187
hCursorWait = LoadCursorA(0, (LPSTR)IDC_WAIT);
188
oldCursor = SetCursor(hCursorWait);
189
190
/* list of files */
191
if ((hdlg = GetDlgItem(hWnd, lst1)) != 0) {
192
WCHAR* scptr; /* ptr on semi-colon */
193
WCHAR* filter = buffer;
194
195
TRACE("Using filter %s\n", debugstr_w(filter));
196
SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);
197
while (filter) {
198
scptr = wcschr(filter, ';');
199
if (scptr) *scptr = 0;
200
while (*filter == ' ') filter++;
201
TRACE("Using file spec %s\n", debugstr_w(filter));
202
SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter);
203
if (scptr) *scptr = ';';
204
filter = (scptr) ? (scptr + 1) : 0;
205
}
206
}
207
208
/* list of directories */
209
lstrcpyW(buffer, L"*.*");
210
211
if (GetDlgItem(hWnd, lst2) != 0) {
212
lRet = DlgDirListW(hWnd, buffer, lst2, stc1, DDL_EXCLUSIVE | DDL_DIRECTORY);
213
}
214
SetCursor(oldCursor);
215
return lRet;
216
}
217
218
/***********************************************************************
219
* FD31_WMDrawItem [internal]
220
*/
221
static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
222
int savedlg, const DRAWITEMSTRUCT *lpdis)
223
{
224
WCHAR *str;
225
HICON hIcon;
226
COLORREF oldText = 0, oldBk = 0;
227
228
if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
229
{
230
if (!(str = malloc(BUFFILEALLOC))) return FALSE;
231
SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
232
(LPARAM)str);
233
234
if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
235
{
236
oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
237
oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
238
}
239
if (savedlg)
240
SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
241
242
ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1,
243
lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
244
&(lpdis->rcItem), str, lstrlenW(str), NULL);
245
246
if (lpdis->itemState & ODS_SELECTED)
247
DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
248
249
if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
250
{
251
SetBkColor( lpdis->hDC, oldBk );
252
SetTextColor( lpdis->hDC, oldText );
253
}
254
free(str);
255
return TRUE;
256
}
257
258
if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
259
{
260
if (!(str = malloc(BUFFILEALLOC)))
261
return FALSE;
262
SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
263
(LPARAM)str);
264
265
if (lpdis->itemState & ODS_SELECTED)
266
{
267
oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
268
oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
269
}
270
ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
271
lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
272
&(lpdis->rcItem), str, lstrlenW(str), NULL);
273
274
if (lpdis->itemState & ODS_SELECTED)
275
DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
276
277
if (lpdis->itemState & ODS_SELECTED)
278
{
279
SetBkColor( lpdis->hDC, oldBk );
280
SetTextColor( lpdis->hDC, oldText );
281
}
282
DrawIconEx( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder, 16, 16, 0, 0, DI_NORMAL );
283
free(str);
284
return TRUE;
285
}
286
if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
287
{
288
char root[] = "a:";
289
if (!(str = malloc(BUFFILEALLOC)))
290
return FALSE;
291
SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
292
(LPARAM)str);
293
root[0] += str[2] - 'a';
294
switch(GetDriveTypeA(root))
295
{
296
case DRIVE_REMOVABLE: hIcon = hFloppy; break;
297
case DRIVE_CDROM: hIcon = hCDRom; break;
298
case DRIVE_REMOTE: hIcon = hNet; break;
299
case DRIVE_FIXED:
300
default: hIcon = hHDisk; break;
301
}
302
if (lpdis->itemState & ODS_SELECTED)
303
{
304
oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
305
oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
306
}
307
ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
308
lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
309
&(lpdis->rcItem), str, lstrlenW(str), NULL);
310
311
if (lpdis->itemState & ODS_SELECTED)
312
{
313
SetBkColor( lpdis->hDC, oldBk );
314
SetTextColor( lpdis->hDC, oldText );
315
}
316
DrawIconEx( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon, 16, 16, 0, 0, DI_NORMAL );
317
free(str);
318
return TRUE;
319
}
320
return FALSE;
321
}
322
323
/***********************************************************************
324
* FD31_UpdateResult [internal]
325
* update the displayed file name (with path)
326
*/
327
static void FD31_UpdateResult(const FD31_DATA *lfs, const WCHAR *tmpstr)
328
{
329
int lenstr2;
330
LPOPENFILENAMEW ofnW = lfs->ofnW;
331
LPOPENFILENAMEA ofnA = lfs->ofnA;
332
WCHAR tmpstr2[BUFFILE];
333
WCHAR *p;
334
335
TRACE("%s\n", debugstr_w(tmpstr));
336
if(ofnW->Flags & OFN_NOVALIDATE)
337
tmpstr2[0] = '\0';
338
else
339
GetCurrentDirectoryW(BUFFILE, tmpstr2);
340
lenstr2 = lstrlenW(tmpstr2);
341
if (lenstr2 > 3)
342
tmpstr2[lenstr2++]='\\';
343
lstrcpynW(tmpstr2+lenstr2, tmpstr, BUFFILE-lenstr2);
344
if (!ofnW->lpstrFile)
345
return;
346
347
lstrcpynW(ofnW->lpstrFile, tmpstr2, ofnW->nMaxFile);
348
349
/* set filename offset */
350
p = PathFindFileNameW(ofnW->lpstrFile);
351
ofnW->nFileOffset = (p - ofnW->lpstrFile);
352
353
/* set extension offset */
354
p = PathFindExtensionW(ofnW->lpstrFile);
355
ofnW->nFileExtension = (*p) ? (p - ofnW->lpstrFile) + 1 : 0;
356
357
TRACE("file %s, file offset %d, ext offset %d\n",
358
debugstr_w(ofnW->lpstrFile), ofnW->nFileOffset, ofnW->nFileExtension);
359
360
/* update the real client structures if any */
361
if (ofnA)
362
{
363
LPSTR lpszTemp;
364
if (ofnW->nMaxFile &&
365
!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
366
ofnA->lpstrFile, ofnA->nMaxFile, NULL, NULL ))
367
ofnA->lpstrFile[ofnA->nMaxFile-1] = 0;
368
369
/* offsets are not guaranteed to be the same in WCHAR to MULTIBYTE conversion */
370
/* set filename offset */
371
lpszTemp = PathFindFileNameA(ofnA->lpstrFile);
372
ofnA->nFileOffset = (lpszTemp - ofnA->lpstrFile);
373
374
/* set extension offset */
375
lpszTemp = PathFindExtensionA(ofnA->lpstrFile);
376
ofnA->nFileExtension = (*lpszTemp) ? (lpszTemp - ofnA->lpstrFile) + 1 : 0;
377
}
378
}
379
380
/***********************************************************************
381
* FD31_UpdateFileTitle [internal]
382
* update the displayed file name (without path)
383
*/
384
static void FD31_UpdateFileTitle(const FD31_DATA *lfs)
385
{
386
LONG lRet;
387
LPOPENFILENAMEW ofnW = lfs->ofnW;
388
LPOPENFILENAMEA ofnA = lfs->ofnA;
389
390
if (ofnW->lpstrFileTitle != NULL)
391
{
392
lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0);
393
SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETTEXT, lRet,
394
(LPARAM)ofnW->lpstrFileTitle );
395
if (ofnA)
396
{
397
if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFileTitle, -1,
398
ofnA->lpstrFileTitle, ofnA->nMaxFileTitle, NULL, NULL ))
399
ofnA->lpstrFileTitle[ofnA->nMaxFileTitle-1] = 0;
400
}
401
}
402
}
403
404
/***********************************************************************
405
* FD31_DirListDblClick [internal]
406
*/
407
static LRESULT FD31_DirListDblClick( const FD31_DATA *lfs )
408
{
409
LONG lRet;
410
HWND hWnd = lfs->hwnd;
411
LPWSTR pstr;
412
WCHAR tmpstr[BUFFILE];
413
414
/* get the raw string (with brackets) */
415
lRet = SendDlgItemMessageW(hWnd, lst2, LB_GETCURSEL, 0, 0);
416
if (lRet == LB_ERR) return TRUE;
417
pstr = malloc(BUFFILEALLOC);
418
SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet,
419
(LPARAM)pstr);
420
lstrcpyW( tmpstr, pstr );
421
free(pstr);
422
/* get the selected directory in tmpstr */
423
if (tmpstr[0] == '[')
424
{
425
tmpstr[lstrlenW(tmpstr) - 1] = 0;
426
lstrcpyW(tmpstr,tmpstr+1);
427
}
428
lstrcatW(tmpstr, L"\\");
429
430
FD31_ScanDir(lfs->ofnW, hWnd, tmpstr);
431
/* notify the app */
432
if (lfs->hook)
433
{
434
if (FD31_CallWindowProc(lfs, lfs->lbselchstring, lst2,
435
MAKELONG(lRet,CD_LBSELCHANGE)))
436
return TRUE;
437
}
438
return TRUE;
439
}
440
441
/***********************************************************************
442
* FD31_FileListSelect [internal]
443
* called when a new item is picked in the file list
444
*/
445
static LRESULT FD31_FileListSelect( const FD31_DATA *lfs )
446
{
447
LONG lRet;
448
HWND hWnd = lfs->hwnd;
449
LPWSTR pstr;
450
451
lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0);
452
if (lRet == LB_ERR)
453
return TRUE;
454
455
/* set the edit control to the chosen file */
456
if ((pstr = malloc(BUFFILEALLOC)))
457
{
458
SendDlgItemMessageW(hWnd, lst1, LB_GETTEXT, lRet,
459
(LPARAM)pstr);
460
SetDlgItemTextW( hWnd, edt1, pstr );
461
free(pstr);
462
}
463
if (lfs->hook)
464
{
465
FD31_CallWindowProc(lfs, lfs->lbselchstring, lst1,
466
MAKELONG(lRet,CD_LBSELCHANGE));
467
}
468
/* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD,
469
CD_LBSELNOITEMS */
470
return TRUE;
471
}
472
473
/***********************************************************************
474
* FD31_TestPath [internal]
475
* before accepting the file name, test if it includes wild cards
476
* tries to scan the directory and returns TRUE if no error.
477
*/
478
static LRESULT FD31_TestPath( const FD31_DATA *lfs, LPWSTR path )
479
{
480
HWND hWnd = lfs->hwnd;
481
LPWSTR pBeginFileName, pstr2;
482
WCHAR tmpstr2[BUFFILE];
483
484
pBeginFileName = wcsrchr(path, '\\');
485
if (pBeginFileName == NULL)
486
pBeginFileName = wcsrchr(path, ':');
487
488
if (wcschr(path,'*') != NULL || wcschr(path,'?') != NULL)
489
{
490
/* edit control contains wildcards */
491
if (pBeginFileName != NULL)
492
{
493
lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE);
494
*(pBeginFileName + 1) = 0;
495
}
496
else
497
{
498
lstrcpyW(tmpstr2, path);
499
if(!(lfs->ofnW->Flags & OFN_NOVALIDATE))
500
*path = 0;
501
}
502
503
TRACE("path=%s, tmpstr2=%s\n", debugstr_w(path), debugstr_w(tmpstr2));
504
SetDlgItemTextW( hWnd, edt1, tmpstr2 );
505
FD31_ScanDir(lfs->ofnW, hWnd, path);
506
return (lfs->ofnW->Flags & OFN_NOVALIDATE) != 0;
507
}
508
509
/* no wildcards, we might have a directory or a filename */
510
/* try appending a wildcard and reading the directory */
511
512
pstr2 = path + lstrlenW(path);
513
if (pBeginFileName == NULL || *(pBeginFileName + 1) != 0)
514
lstrcatW(path, L"\\");
515
516
/* if ScanDir succeeds, we have changed the directory */
517
if (FD31_ScanDir(lfs->ofnW, hWnd, path))
518
return FALSE; /* and path is not a valid file name */
519
520
/* if not, this must be a filename */
521
522
*pstr2 = 0; /* remove the wildcard added before */
523
524
if (pBeginFileName != NULL)
525
{
526
/* strip off the pathname */
527
*pBeginFileName = 0;
528
SetDlgItemTextW( hWnd, edt1, pBeginFileName + 1 );
529
530
lstrcpynW(tmpstr2, pBeginFileName + 1, ARRAY_SIZE(tmpstr2));
531
/* Should we MessageBox() if this fails? */
532
if (!FD31_ScanDir(lfs->ofnW, hWnd, path))
533
{
534
return FALSE;
535
}
536
lstrcpyW(path, tmpstr2);
537
}
538
else
539
SetDlgItemTextW( hWnd, edt1, path );
540
return TRUE;
541
}
542
543
/***********************************************************************
544
* FD31_Validate [internal]
545
* called on: click Ok button, Enter in edit, DoubleClick in file list
546
*/
547
static LRESULT FD31_Validate( const FD31_DATA *lfs, LPCWSTR path, UINT control, INT itemIndex,
548
BOOL internalUse )
549
{
550
LONG lRet;
551
HWND hWnd = lfs->hwnd;
552
OPENFILENAMEW ofnsav;
553
LPOPENFILENAMEW ofnW = lfs->ofnW;
554
WCHAR filename[BUFFILE];
555
int copied_size = min( ofnW->lStructSize, sizeof(ofnsav) );
556
557
memcpy( &ofnsav, ofnW, copied_size ); /* for later restoring */
558
559
/* get current file name */
560
if (path)
561
lstrcpynW(filename, path, ARRAY_SIZE(filename));
562
else
563
GetDlgItemTextW( hWnd, edt1, filename, ARRAY_SIZE(filename));
564
565
TRACE("got filename = %s\n", debugstr_w(filename));
566
/* if we did not click in file list to get there */
567
if (control != lst1)
568
{
569
if (!FD31_TestPath( lfs, filename) )
570
return FALSE;
571
}
572
FD31_UpdateResult(lfs, filename);
573
574
if (internalUse)
575
{ /* called internally after a change in a combo */
576
if (lfs->hook)
577
{
578
FD31_CallWindowProc(lfs, lfs->lbselchstring, control,
579
MAKELONG(itemIndex,CD_LBSELCHANGE));
580
}
581
return TRUE;
582
}
583
584
FD31_UpdateFileTitle(lfs);
585
if (lfs->hook)
586
{
587
lRet = FD31_CallWindowProc(lfs, lfs->fileokstring,
588
0, lfs->lParam );
589
if (lRet)
590
{
591
memcpy( ofnW, &ofnsav, copied_size ); /* restore old state */
592
return FALSE;
593
}
594
}
595
if ((ofnW->Flags & OFN_ALLOWMULTISELECT) && (ofnW->Flags & OFN_EXPLORER))
596
{
597
if (ofnW->lpstrFile)
598
{
599
LPWSTR str = ofnW->lpstrFile;
600
LPWSTR ptr = wcsrchr(str, '\\');
601
str[lstrlenW(str) + 1] = '\0';
602
*ptr = 0;
603
}
604
}
605
return TRUE;
606
}
607
608
/***********************************************************************
609
* FD31_DiskChange [internal]
610
* called when a new item is picked in the disk selection combo
611
*/
612
static LRESULT FD31_DiskChange( const FD31_DATA *lfs )
613
{
614
LONG lRet;
615
HWND hWnd = lfs->hwnd;
616
LPWSTR pstr;
617
WCHAR diskname[BUFFILE];
618
619
FD31_StripEditControl(hWnd);
620
lRet = SendDlgItemMessageW(hWnd, cmb2, CB_GETCURSEL, 0, 0L);
621
if (lRet == LB_ERR)
622
return 0;
623
pstr = malloc(BUFFILEALLOC);
624
SendDlgItemMessageW(hWnd, cmb2, CB_GETLBTEXT, lRet,
625
(LPARAM)pstr);
626
wsprintfW(diskname, L"%c:", pstr[2]);
627
free(pstr);
628
629
return FD31_Validate( lfs, diskname, cmb2, lRet, TRUE );
630
}
631
632
/***********************************************************************
633
* FD31_FileTypeChange [internal]
634
* called when a new item is picked in the file type combo
635
*/
636
static LRESULT FD31_FileTypeChange( const FD31_DATA *lfs )
637
{
638
LONG lRet;
639
LPWSTR pstr;
640
641
lRet = SendDlgItemMessageW(lfs->hwnd, cmb1, CB_GETCURSEL, 0, 0);
642
if (lRet == LB_ERR)
643
return TRUE;
644
lfs->ofnW->nFilterIndex = lRet + 1;
645
if (lfs->ofnA)
646
lfs->ofnA->nFilterIndex = lRet + 1;
647
pstr = (LPWSTR)SendDlgItemMessageW(lfs->hwnd, cmb1, CB_GETITEMDATA, lRet, 0);
648
TRACE("Selected filter : %s\n", debugstr_w(pstr));
649
650
return FD31_Validate( lfs, pstr, cmb1, lRet, TRUE );
651
}
652
653
/***********************************************************************
654
* FD31_WMCommand [internal]
655
*/
656
static LRESULT FD31_WMCommand( HWND hWnd, LPARAM lParam, UINT notification,
657
UINT control, const FD31_DATA *lfs )
658
{
659
switch (control)
660
{
661
case lst1: /* file list */
662
FD31_StripEditControl(hWnd);
663
if (notification == LBN_DBLCLK)
664
{
665
return SendMessageW(hWnd, WM_COMMAND, IDOK, 0);
666
}
667
else if (notification == LBN_SELCHANGE)
668
return FD31_FileListSelect( lfs );
669
break;
670
671
case lst2: /* directory list */
672
FD31_StripEditControl(hWnd);
673
if (notification == LBN_DBLCLK)
674
return FD31_DirListDblClick( lfs );
675
break;
676
677
case cmb1: /* file type drop list */
678
if (notification == CBN_SELCHANGE)
679
return FD31_FileTypeChange( lfs );
680
break;
681
682
case chx1:
683
break;
684
685
case pshHelp:
686
break;
687
688
case cmb2: /* disk dropdown combo */
689
if (notification == CBN_SELCHANGE)
690
return FD31_DiskChange( lfs );
691
break;
692
693
case IDOK:
694
TRACE("OK pressed\n");
695
if (FD31_Validate( lfs, NULL, control, 0, FALSE ))
696
EndDialog(hWnd, TRUE);
697
return TRUE;
698
699
case IDCANCEL:
700
EndDialog(hWnd, FALSE);
701
return TRUE;
702
703
case IDABORT: /* can be sent by the hook procedure */
704
EndDialog(hWnd, TRUE);
705
return TRUE;
706
}
707
return FALSE;
708
}
709
710
/************************************************************************
711
* FD31_MapStringPairsToW [internal]
712
* map string pairs to Unicode
713
*/
714
static LPWSTR FD31_MapStringPairsToW(LPCSTR strA, UINT size)
715
{
716
LPCSTR s;
717
LPWSTR x;
718
unsigned int n, len;
719
720
s = strA;
721
while (*s)
722
s = s+strlen(s)+1;
723
s++;
724
n = s + 1 - strA; /* Don't forget the other \0 */
725
if (n < size) n = size;
726
727
len = MultiByteToWideChar( CP_ACP, 0, strA, n, NULL, 0 );
728
x = malloc(len * sizeof(WCHAR));
729
MultiByteToWideChar( CP_ACP, 0, strA, n, x, len );
730
return x;
731
}
732
733
734
/************************************************************************
735
* FD31_DupToW [internal]
736
* duplicates an Ansi string to unicode, with a buffer size
737
*/
738
static LPWSTR FD31_DupToW(LPCSTR str, DWORD size)
739
{
740
LPWSTR strW = NULL;
741
if (str && (size > 0))
742
{
743
strW = malloc(size * sizeof(WCHAR));
744
if (strW) MultiByteToWideChar( CP_ACP, 0, str, -1, strW, size );
745
}
746
return strW;
747
}
748
749
/************************************************************************
750
* FD31_MapOfnStructA [internal]
751
* map a 32 bits Ansi structure to a Unicode one
752
*/
753
static void FD31_MapOfnStructA(const OPENFILENAMEA *ofnA, LPOPENFILENAMEW ofnW, BOOL open)
754
{
755
UNICODE_STRING usBuffer;
756
757
ofnW->hwndOwner = ofnA->hwndOwner;
758
ofnW->hInstance = ofnA->hInstance;
759
if (ofnA->lpstrFilter)
760
ofnW->lpstrFilter = FD31_MapStringPairsToW(ofnA->lpstrFilter, 0);
761
762
if ((ofnA->lpstrCustomFilter) && (*(ofnA->lpstrCustomFilter)))
763
ofnW->lpstrCustomFilter = FD31_MapStringPairsToW(ofnA->lpstrCustomFilter, ofnA->nMaxCustFilter);
764
ofnW->nMaxCustFilter = ofnA->nMaxCustFilter;
765
ofnW->nFilterIndex = ofnA->nFilterIndex;
766
ofnW->nMaxFile = ofnA->nMaxFile;
767
ofnW->lpstrFile = FD31_DupToW(ofnA->lpstrFile, ofnW->nMaxFile);
768
ofnW->nMaxFileTitle = ofnA->nMaxFileTitle;
769
ofnW->lpstrFileTitle = FD31_DupToW(ofnA->lpstrFileTitle, ofnW->nMaxFileTitle);
770
if (ofnA->lpstrInitialDir)
771
{
772
RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpstrInitialDir);
773
ofnW->lpstrInitialDir = usBuffer.Buffer;
774
}
775
if (ofnA->lpstrTitle) {
776
RtlCreateUnicodeStringFromAsciiz (&usBuffer, ofnA->lpstrTitle);
777
ofnW->lpstrTitle = usBuffer.Buffer;
778
} else {
779
WCHAR buf[16];
780
LPWSTR title_tmp;
781
int len;
782
LoadStringW(COMDLG32_hInstance, open ? IDS_OPEN_FILE : IDS_SAVE_AS, buf, ARRAY_SIZE(buf));
783
len = lstrlenW(buf)+1;
784
title_tmp = malloc(len * sizeof(WCHAR));
785
memcpy(title_tmp, buf, len * sizeof(WCHAR));
786
ofnW->lpstrTitle = title_tmp;
787
}
788
ofnW->Flags = ofnA->Flags;
789
ofnW->nFileOffset = ofnA->nFileOffset;
790
ofnW->nFileExtension = ofnA->nFileExtension;
791
ofnW->lpstrDefExt = FD31_DupToW(ofnA->lpstrDefExt, 3);
792
if ((ofnA->Flags & OFN_ENABLETEMPLATE) && (ofnA->lpTemplateName))
793
{
794
if (!IS_INTRESOURCE(ofnA->lpTemplateName))
795
{
796
RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpTemplateName);
797
ofnW->lpTemplateName = usBuffer.Buffer;
798
}
799
else /* numbered resource */
800
ofnW->lpTemplateName = (LPCWSTR) ofnA->lpTemplateName;
801
}
802
if (ofnW->lStructSize > OPENFILENAME_SIZE_VERSION_400W)
803
{
804
ofnW->pvReserved = ofnA->pvReserved;
805
ofnW->dwReserved = ofnA->dwReserved;
806
ofnW->FlagsEx = ofnA->FlagsEx;
807
}
808
}
809
810
811
/************************************************************************
812
* FD31_FreeOfnW [internal]
813
* Undo all allocations done by FD31_MapOfnStructA
814
*/
815
static void FD31_FreeOfnW(OPENFILENAMEW *ofnW)
816
{
817
free((void *)ofnW->lpstrFilter);
818
free(ofnW->lpstrCustomFilter);
819
free(ofnW->lpstrFile);
820
free(ofnW->lpstrFileTitle);
821
free((void *)ofnW->lpstrInitialDir);
822
free((void *)ofnW->lpstrTitle);
823
if (!IS_INTRESOURCE(ofnW->lpTemplateName))
824
free((void *)ofnW->lpTemplateName);
825
}
826
827
/************************************************************************
828
* FD31_DestroyPrivate [internal]
829
* destroys the private object
830
*/
831
static void FD31_DestroyPrivate(PFD31_DATA lfs)
832
{
833
HWND hwnd;
834
if (!lfs) return;
835
hwnd = lfs->hwnd;
836
TRACE("destroying private allocation %p\n", lfs);
837
838
/* if ofnW has been allocated, have to free everything in it */
839
if (lfs->ofnA)
840
{
841
FD31_FreeOfnW(lfs->ofnW);
842
free(lfs->ofnW);
843
}
844
free(lfs);
845
RemovePropA(hwnd, FD31_OFN_PROP);
846
}
847
848
/***********************************************************************
849
* FD31_GetTemplate [internal]
850
*
851
* Get a template (or FALSE if failure) when 16 bits dialogs are used
852
* by a 32 bits application
853
*
854
*/
855
static BOOL FD31_GetTemplate(PFD31_DATA lfs)
856
{
857
LPOPENFILENAMEW ofnW = lfs->ofnW;
858
LPOPENFILENAMEA ofnA = lfs->ofnA;
859
HANDLE hDlgTmpl;
860
861
if (ofnW->Flags & OFN_ENABLETEMPLATEHANDLE)
862
{
863
if (!(lfs->template = LockResource( ofnW->hInstance )))
864
{
865
COMDLG32_SetCommDlgExtendedError( CDERR_LOADRESFAILURE );
866
return FALSE;
867
}
868
}
869
else if (ofnW->Flags & OFN_ENABLETEMPLATE)
870
{
871
HRSRC hResInfo;
872
if (ofnA)
873
hResInfo = FindResourceA( ofnA->hInstance, ofnA->lpTemplateName, (LPSTR)RT_DIALOG );
874
else
875
hResInfo = FindResourceW( ofnW->hInstance, ofnW->lpTemplateName, (LPWSTR)RT_DIALOG );
876
if (!hResInfo)
877
{
878
COMDLG32_SetCommDlgExtendedError( CDERR_FINDRESFAILURE );
879
return FALSE;
880
}
881
if (!(hDlgTmpl = LoadResource( ofnW->hInstance, hResInfo )) ||
882
!(lfs->template = LockResource( hDlgTmpl )))
883
{
884
COMDLG32_SetCommDlgExtendedError( CDERR_LOADRESFAILURE );
885
return FALSE;
886
}
887
}
888
else /* get it from internal Wine resource */
889
{
890
HRSRC hResInfo;
891
if (!(hResInfo = FindResourceA( COMDLG32_hInstance, lfs->open ? "OPEN_FILE" : "SAVE_FILE", (LPSTR)RT_DIALOG )))
892
{
893
COMDLG32_SetCommDlgExtendedError( CDERR_FINDRESFAILURE );
894
return FALSE;
895
}
896
if (!(hDlgTmpl = LoadResource( COMDLG32_hInstance, hResInfo )) ||
897
!(lfs->template = LockResource( hDlgTmpl )))
898
{
899
COMDLG32_SetCommDlgExtendedError( CDERR_LOADRESFAILURE );
900
return FALSE;
901
}
902
}
903
return TRUE;
904
}
905
906
/************************************************************************
907
* FD31_AllocPrivate [internal]
908
* allocate a private object to hold 32 bits Unicode
909
* structure that will be used throughout the calls, while
910
* keeping available the original structures and a few variables
911
* On entry : type = dialog procedure type (16,32A,32W)
912
* dlgType = dialog type (open or save)
913
*/
914
static PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode)
915
{
916
FD31_DATA *lfs = calloc(1, sizeof(*lfs));
917
918
TRACE("alloc private buf %p\n", lfs);
919
if (!lfs) return NULL;
920
lfs->hook = FALSE;
921
lfs->lParam = lParam;
922
lfs->open = (dlgType == OPEN_DIALOG);
923
924
if (IsUnicode)
925
{
926
lfs->ofnA = NULL;
927
lfs->ofnW = (LPOPENFILENAMEW) lParam;
928
if (lfs->ofnW->Flags & OFN_ENABLEHOOK)
929
if (lfs->ofnW->lpfnHook)
930
lfs->hook = TRUE;
931
}
932
else
933
{
934
lfs->ofnA = (LPOPENFILENAMEA) lParam;
935
if (lfs->ofnA->Flags & OFN_ENABLEHOOK)
936
if (lfs->ofnA->lpfnHook)
937
lfs->hook = TRUE;
938
lfs->ofnW = calloc(1, lfs->ofnA->lStructSize);
939
lfs->ofnW->lStructSize = lfs->ofnA->lStructSize;
940
FD31_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
941
}
942
943
if (! FD31_GetTemplate(lfs))
944
{
945
FD31_DestroyPrivate(lfs);
946
return NULL;
947
}
948
lfs->lbselchstring = RegisterWindowMessageA(LBSELCHSTRINGA);
949
lfs->fileokstring = RegisterWindowMessageA(FILEOKSTRINGA);
950
951
return lfs;
952
}
953
954
/***********************************************************************
955
* FD31_WMInitDialog [internal]
956
*/
957
static LONG FD31_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
958
{
959
int i, n;
960
WCHAR tmpstr[BUFFILE];
961
LPWSTR pstr, old_pstr;
962
LPOPENFILENAMEW ofn;
963
PFD31_DATA lfs = (PFD31_DATA) lParam;
964
965
if (!lfs) return FALSE;
966
SetPropA(hWnd, FD31_OFN_PROP, lfs);
967
lfs->hwnd = hWnd;
968
ofn = lfs->ofnW;
969
970
TRACE("flags=%lx initialdir=%s\n", ofn->Flags, debugstr_w(ofn->lpstrInitialDir));
971
972
SetWindowTextW( hWnd, ofn->lpstrTitle );
973
/* read custom filter information */
974
if (ofn->lpstrCustomFilter)
975
{
976
pstr = ofn->lpstrCustomFilter;
977
n = 0;
978
TRACE("lpstrCustomFilter = %p\n", pstr);
979
while(*pstr)
980
{
981
old_pstr = pstr;
982
i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
983
(LPARAM)(ofn->lpstrCustomFilter) + n );
984
n += lstrlenW(pstr) + 1;
985
pstr += lstrlenW(pstr) + 1;
986
TRACE("add str=%s associated to %s\n",
987
debugstr_w(old_pstr), debugstr_w(pstr));
988
SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
989
n += lstrlenW(pstr) + 1;
990
pstr += lstrlenW(pstr) + 1;
991
}
992
}
993
/* read filter information */
994
if (ofn->lpstrFilter) {
995
pstr = (LPWSTR) ofn->lpstrFilter;
996
n = 0;
997
while(*pstr) {
998
old_pstr = pstr;
999
i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
1000
(LPARAM)(ofn->lpstrFilter + n) );
1001
n += lstrlenW(pstr) + 1;
1002
pstr += lstrlenW(pstr) + 1;
1003
TRACE("add str=%s associated to %s\n",
1004
debugstr_w(old_pstr), debugstr_w(pstr));
1005
SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
1006
n += lstrlenW(pstr) + 1;
1007
pstr += lstrlenW(pstr) + 1;
1008
}
1009
}
1010
/* set default filter */
1011
if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL)
1012
ofn->nFilterIndex = 1;
1013
SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);
1014
if (ofn->lpstrFile && ofn->lpstrFile[0])
1015
{
1016
TRACE( "SetText of edt1 to %s\n", debugstr_w(ofn->lpstrFile) );
1017
SetDlgItemTextW( hWnd, edt1, ofn->lpstrFile );
1018
}
1019
else
1020
{
1021
lstrcpynW(tmpstr, FD31_GetFileType(ofn->lpstrCustomFilter,
1022
ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
1023
TRACE("nFilterIndex = %ld, SetText of edt1 to %s\n",
1024
ofn->nFilterIndex, debugstr_w(tmpstr));
1025
SetDlgItemTextW( hWnd, edt1, tmpstr );
1026
}
1027
/* get drive list */
1028
*tmpstr = 0;
1029
DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
1030
/* read initial directory */
1031
/* FIXME: Note that this is now very version-specific (See MSDN description of
1032
* the OPENFILENAME structure). For example under 2000/XP any path in the
1033
* lpstrFile overrides the lpstrInitialDir, but not under 95/98/ME
1034
*/
1035
if (ofn->lpstrInitialDir != NULL)
1036
{
1037
int len;
1038
lstrcpynW(tmpstr, ofn->lpstrInitialDir, 511);
1039
len = lstrlenW(tmpstr);
1040
if (len > 0 && tmpstr[len-1] != '\\' && tmpstr[len-1] != ':') {
1041
tmpstr[len]='\\';
1042
tmpstr[len+1]='\0';
1043
}
1044
}
1045
else
1046
*tmpstr = 0;
1047
if (!FD31_ScanDir(ofn, hWnd, tmpstr)) {
1048
*tmpstr = 0;
1049
if (!FD31_ScanDir(ofn, hWnd, tmpstr))
1050
WARN("Couldn't read initial directory %s!\n", debugstr_w(tmpstr));
1051
}
1052
/* select current drive in combo 2, omit missing drives */
1053
{
1054
char dir[MAX_PATH];
1055
char str[4] = "a:\\";
1056
GetCurrentDirectoryA( sizeof(dir), dir );
1057
for(i = 0, n = -1; i < 26; i++)
1058
{
1059
str[0] = 'a' + i;
1060
if (GetDriveTypeA(str) > DRIVE_NO_ROOT_DIR) n++;
1061
if (toupper(str[0]) == toupper(dir[0])) break;
1062
}
1063
}
1064
SendDlgItemMessageW(hWnd, cmb2, CB_SETCURSEL, n, 0);
1065
if (!(ofn->Flags & OFN_SHOWHELP))
1066
ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
1067
if (ofn->Flags & OFN_HIDEREADONLY)
1068
ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
1069
if (lfs->hook)
1070
return FD31_CallWindowProc(lfs, WM_INITDIALOG, wParam, lfs->lParam);
1071
return TRUE;
1072
}
1073
1074
static int FD31_GetFldrHeight(void)
1075
{
1076
return fldrHeight;
1077
}
1078
1079
/***********************************************************************
1080
* FD31_WMMeasureItem [internal]
1081
*/
1082
static LONG FD31_WMMeasureItem(LPARAM lParam)
1083
{
1084
LPMEASUREITEMSTRUCT lpmeasure;
1085
1086
lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
1087
lpmeasure->itemHeight = FD31_GetFldrHeight();
1088
return TRUE;
1089
}
1090
1091
1092
/***********************************************************************
1093
* FileOpenDlgProc [internal]
1094
* Used for open and save, in fact.
1095
*/
1096
static INT_PTR CALLBACK FD31_FileOpenDlgProc(HWND hWnd, UINT wMsg,
1097
WPARAM wParam, LPARAM lParam)
1098
{
1099
PFD31_DATA lfs = (PFD31_DATA)GetPropA( hWnd, FD31_OFN_PROP );
1100
1101
TRACE("msg=%x wparam=%Ix lParam=%Ix\n", wMsg, wParam, lParam);
1102
if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
1103
{
1104
INT_PTR lRet;
1105
lRet = (INT_PTR)FD31_CallWindowProc( lfs, wMsg, wParam, lParam );
1106
if (lRet) return lRet; /* else continue message processing */
1107
}
1108
switch (wMsg)
1109
{
1110
case WM_INITDIALOG:
1111
return FD31_WMInitDialog( hWnd, wParam, lParam );
1112
1113
case WM_MEASUREITEM:
1114
return FD31_WMMeasureItem( lParam );
1115
1116
case WM_DRAWITEM:
1117
return FD31_WMDrawItem( hWnd, wParam, lParam, !lfs->open, (DRAWITEMSTRUCT *)lParam );
1118
1119
case WM_COMMAND:
1120
return FD31_WMCommand( hWnd, lParam, HIWORD(wParam), LOWORD(wParam), lfs );
1121
#if 0
1122
case WM_CTLCOLOR:
1123
SetBkColor( (HDC16)wParam, 0x00C0C0C0 );
1124
switch (HIWORD(lParam))
1125
{
1126
case CTLCOLOR_BTN:
1127
SetTextColor( (HDC16)wParam, 0x00000000 );
1128
return hGRAYBrush;
1129
case CTLCOLOR_STATIC:
1130
SetTextColor( (HDC16)wParam, 0x00000000 );
1131
return hGRAYBrush;
1132
}
1133
break;
1134
#endif
1135
}
1136
return FALSE;
1137
}
1138
1139
/***********************************************************************
1140
* GetFileName31A [internal]
1141
*
1142
* Creates a win31 style dialog box for the user to select a file to open/save.
1143
*/
1144
BOOL GetFileName31A( OPENFILENAMEA *lpofn, UINT dlgType )
1145
{
1146
BOOL bRet = FALSE;
1147
PFD31_DATA lfs;
1148
1149
if (!lpofn || !FD31_Init()) return FALSE;
1150
1151
TRACE("ofn flags %08lx\n", lpofn->Flags);
1152
lfs = FD31_AllocPrivate((LPARAM) lpofn, dlgType, FALSE);
1153
if (lfs)
1154
{
1155
bRet = DialogBoxIndirectParamA( COMDLG32_hInstance, lfs->template, lpofn->hwndOwner,
1156
FD31_FileOpenDlgProc, (LPARAM)lfs);
1157
FD31_DestroyPrivate(lfs);
1158
}
1159
1160
TRACE("return lpstrFile='%s' !\n", lpofn->lpstrFile);
1161
return bRet;
1162
}
1163
1164
/***********************************************************************
1165
* GetFileName31W [internal]
1166
*
1167
* Creates a win31 style dialog box for the user to select a file to open/save
1168
*/
1169
BOOL GetFileName31W( OPENFILENAMEW *lpofn, UINT dlgType )
1170
{
1171
BOOL bRet = FALSE;
1172
PFD31_DATA lfs;
1173
1174
if (!lpofn || !FD31_Init()) return FALSE;
1175
1176
lfs = FD31_AllocPrivate((LPARAM) lpofn, dlgType, TRUE);
1177
if (lfs)
1178
{
1179
bRet = DialogBoxIndirectParamW( COMDLG32_hInstance, lfs->template, lpofn->hwndOwner,
1180
FD31_FileOpenDlgProc, (LPARAM)lfs);
1181
FD31_DestroyPrivate(lfs);
1182
}
1183
1184
TRACE("file %s, file offset %d, ext offset %d\n",
1185
debugstr_w(lpofn->lpstrFile), lpofn->nFileOffset, lpofn->nFileExtension);
1186
return bRet;
1187
}
1188
1189