source: trunk/src/comdlg32/filedlg95.c@ 6502

Last change on this file since 6502 was 6300, checked in by sandervl, 24 years ago

file open/save dialog fix

File size: 84.0 KB
Line 
1/*
2 * COMMDLG - File Open Dialogs Win95 look and feel
3 *
4 * FIXME: The whole concept of handling unicode is badly broken.
5 * many hook-messages expecting a pointer to a
6 * OPENFILENAMEA or W structure. With the current architecture
7 * we would have to convert the beast at every call to a hook.
8 * we have to find a better solution but if would likely cause
9 * a complete rewrite with after we shouldhandle the
10 * OPENFILENAME structure without any converting (jsch).
11 *
12 * FIXME: any hook gets a OPENFILENAMEA structure
13 *
14 * FIXME: CDN_FILEOK is wrong implemented, other CDN_ messages likely too
15 *
16 * FIXME: old style hook messages are not implemented (except FILEOKSTRING)
17 *
18 * FIXME: lpstrCustomFilter not handled
19 *
20 * FIXME: if the size of lpstrFile (nMaxFile) is too small the first
21 * two bytes of lpstrFile should contain the needed size
22 *
23 * FIXME: algorithm for selecting the initial directory is too simple
24 *
25 * FIXME: add to recent docs
26 *
27 * FIXME: flags not implemented: OFN_CREATEPROMPT, OFN_DONTADDTORECENT,
28 * OFN_ENABLEINCLUDENOTIFY, OFN_ENABLESIZING, OFN_EXTENSIONDIFFERENT,
29 * OFN_NODEREFERENCELINKS, OFN_NOREADONLYRETURN,
30 * OFN_NOTESTFILECREATE, OFN_OVERWRITEPROMPT, OFN_USEMONIKERS
31 *
32 * FIXME: lCustData for lpfnHook (WM_INITDIALOG)
33 *
34 *
35 */
36#ifdef __WIN32OS2__
37#include <windef.h>
38#include <winbase.h>
39#include <wingdi.h>
40#include <winuser.h>
41#include <heapstring.h>
42#include <misc.h>
43#include <win\shlwapi.h>
44
45#define MapHModuleSL(a) a
46#define MapHModuleLS(a) a
47#define snprintf wsnprintfA
48#endif
49
50#include <ctype.h>
51#include <stdlib.h>
52#include <stdio.h>
53#include <string.h>
54
55#include "winbase.h"
56#include "ntddk.h"
57#include "winnls.h"
58#include "heap.h"
59#include "commdlg.h"
60#include "dlgs.h"
61#include "cdlg.h"
62#include "debugtools.h"
63#include "cderr.h"
64#include "shellapi.h"
65#include "shlguid.h"
66#include "filedlgbrowser.h"
67#include "shlwapi.h"
68#include "wine/obj_contextmenu.h"
69
70DEFAULT_DEBUG_CHANNEL(commdlg);
71
72#define UNIMPLEMENTED_FLAGS \
73(OFN_CREATEPROMPT | OFN_DONTADDTORECENT |\
74OFN_ENABLEINCLUDENOTIFY | OFN_ENABLESIZING | OFN_EXTENSIONDIFFERENT |\
75OFN_NODEREFERENCELINKS | OFN_NOREADONLYRETURN |\
76OFN_NOTESTFILECREATE | OFN_OVERWRITEPROMPT /*| OFN_USEMONIKERS*/)
77
78#define IsHooked(fodInfos) \
79 ((fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook)
80/***********************************************************************
81 * Data structure and global variables
82 */
83typedef struct SFolder
84{
85 int m_iImageIndex; /* Index of picture in image list */
86 HIMAGELIST hImgList;
87 int m_iIndent; /* Indentation index */
88 LPITEMIDLIST pidlItem; /* absolute pidl of the item */
89
90} SFOLDER,*LPSFOLDER;
91
92typedef struct tagLookInInfo
93{
94 int iMaxIndentation;
95 UINT uSelectedItem;
96} LookInInfos;
97
98
99/***********************************************************************
100 * Defines and global variables
101 */
102
103/* Draw item constant */
104#define ICONWIDTH 18
105#define XTEXTOFFSET 3
106
107/* AddItem flags*/
108#define LISTEND -1
109
110/* SearchItem methods */
111#define SEARCH_PIDL 1
112#define SEARCH_EXP 2
113#define ITEM_NOTFOUND -1
114
115/* Undefined windows message sent by CreateViewObject*/
116#define WM_GETISHELLBROWSER WM_USER+7
117
118/* NOTE
119 * Those macros exist in windowsx.h. However, you can't really use them since
120 * they rely on the UNICODE defines and can't be used inside Wine itself.
121 */
122
123/* Combo box macros */
124#define CBAddString(hwnd,str) \
125 SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)str);
126
127#define CBInsertString(hwnd,str,pos) \
128 SendMessageA(hwnd,CB_INSERTSTRING,(WPARAM)pos,(LPARAM)str);
129
130#define CBDeleteString(hwnd,pos) \
131 SendMessageA(hwnd,CB_DELETESTRING,(WPARAM)pos,0);
132
133#define CBSetItemDataPtr(hwnd,iItemId,dataPtr) \
134 SendMessageA(hwnd,CB_SETITEMDATA,(WPARAM)iItemId,(LPARAM)dataPtr);
135
136#define CBGetItemDataPtr(hwnd,iItemId) \
137 SendMessageA(hwnd,CB_GETITEMDATA,(WPARAM)iItemId,0)
138
139#define CBGetLBText(hwnd,iItemId,str) \
140 SendMessageA(hwnd,CB_GETLBTEXT,(WPARAM)iItemId,(LPARAM)str);
141
142#define CBGetCurSel(hwnd) \
143 SendMessageA(hwnd,CB_GETCURSEL,0,0);
144
145#define CBSetCurSel(hwnd,pos) \
146 SendMessageA(hwnd,CB_SETCURSEL,(WPARAM)pos,0);
147
148#define CBGetCount(hwnd) \
149 SendMessageA(hwnd,CB_GETCOUNT,0,0);
150#define CBShowDropDown(hwnd,show) \
151 SendMessageA(hwnd,CB_SHOWDROPDOWN,(WPARAM)show,0);
152#define CBSetItemHeight(hwnd,index,height) \
153 SendMessageA(hwnd,CB_SETITEMHEIGHT,(WPARAM)index,(LPARAM)height);
154
155
156const char *FileOpenDlgInfosStr = "FileOpenDlgInfos"; /* windows property description string */
157const char *LookInInfosStr = "LookInInfos"; /* LOOKIN combo box property */
158
159static const char defaultFilter[] = "*.*";
160
161/***********************************************************************
162 * Prototypes
163 */
164
165/* Internal functions used by the dialog */
166static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam);
167static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam);
168static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd);
169 BOOL FILEDLG95_OnOpen(HWND hwnd);
170static LRESULT FILEDLG95_InitControls(HWND hwnd);
171static void FILEDLG95_Clean(HWND hwnd);
172
173/* Functions used by the shell navigation */
174static LRESULT FILEDLG95_SHELL_Init(HWND hwnd);
175static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd);
176static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb);
177static void FILEDLG95_SHELL_Clean(HWND hwnd);
178static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd);
179
180/* Functions used by the filetype combo box */
181static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd);
182static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode);
183static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCSTR lpstrExt);
184static void FILEDLG95_FILETYPE_Clean(HWND hwnd);
185
186/* Functions used by the Look In combo box */
187static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo);
188static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct);
189static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode);
190static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId);
191static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMethod);
192static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl);
193static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd);
194 int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
195static void FILEDLG95_LOOKIN_Clean(HWND hwnd);
196
197/* Miscellaneous tool functions */
198HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
199HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
200IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
201LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
202LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
203
204/* Shell memory allocation */
205static void *MemAlloc(UINT size);
206static void MemFree(void *mem);
207
208BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos);
209HRESULT WINAPI FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
210HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
211HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
212BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);
213static BOOL BrowseSelectedFolder(HWND hwnd);
214
215/***********************************************************************
216 * GetFileName95
217 *
218 * Creates an Open common dialog box that lets the user select
219 * the drive, directory, and the name of a file or set of files to open.
220 *
221 * IN : The FileOpenDlgInfos structure associated with the dialog
222 * OUT : TRUE on success
223 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
224 */
225BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos)
226{
227
228 LRESULT lRes;
229 LPCVOID template;
230 HRSRC hRes;
231 HANDLE hDlgTmpl = 0;
232
233 /* test for missing functionality */
234 if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
235 {
236 FIXME("Flags 0x%08lx not yet implemented\n",
237 fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS);
238 }
239
240 /* Create the dialog from a template */
241
242 if(!(hRes = FindResourceA(COMMDLG_hInstance32,MAKEINTRESOURCEA(NEWFILEOPENORD),RT_DIALOGA)))
243 {
244 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
245 return FALSE;
246 }
247 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hRes )) ||
248 !(template = LockResource( hDlgTmpl )))
249 {
250 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
251 return FALSE;
252 }
253
254 /* old style hook messages */
255 if (IsHooked(fodInfos))
256 {
257 fodInfos->HookMsg.fileokstring = RegisterWindowMessageA(FILEOKSTRINGA);
258 fodInfos->HookMsg.lbselchstring = RegisterWindowMessageA(LBSELCHSTRINGA);
259 fodInfos->HookMsg.helpmsgstring = RegisterWindowMessageA(HELPMSGSTRINGA);
260 fodInfos->HookMsg.sharevistring = RegisterWindowMessageA(SHAREVISTRINGA);
261 }
262
263 lRes = DialogBoxIndirectParamA(COMMDLG_hInstance32,
264 (LPDLGTEMPLATEA) template,
265 fodInfos->ofnInfos->hwndOwner,
266 (DLGPROC) FileOpenDlgProc95,
267 (LPARAM) fodInfos);
268
269 /* Unable to create the dialog */
270 if( lRes == -1)
271 return FALSE;
272
273 return lRes;
274}
275
276/***********************************************************************
277 * GetFileDialog95A
278 *
279 * Call GetFileName95 with this structure and clean the memory.
280 *
281 * IN : The OPENFILENAMEA initialisation structure passed to
282 * GetOpenFileNameA win api function (see filedlg.c)
283 */
284BOOL WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType)
285{
286
287 BOOL ret;
288 FileOpenDlgInfos *fodInfos;
289 HINSTANCE hInstance;
290 LPCSTR lpstrInitialDir = (LPCSTR)-1;
291 LPSTR lpstrSavDir = NULL;
292 DWORD dwFlags = 0;
293
294 /* Initialise FileOpenDlgInfos structure*/
295 fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos));
296 ZeroMemory(fodInfos, sizeof(FileOpenDlgInfos));
297
298 /* Pass in the original ofn */
299 fodInfos->ofnInfos = ofn;
300
301 /* Save original hInstance value */
302 hInstance = ofn->hInstance;
303 fodInfos->ofnInfos->hInstance = MapHModuleLS(ofn->hInstance);
304
305 /* save current directory */
306 if (ofn->Flags & OFN_NOCHANGEDIR)
307 {
308 lpstrSavDir = MemAlloc(MAX_PATH);
309 GetCurrentDirectoryA(MAX_PATH, lpstrSavDir);
310 }
311
312 dwFlags = ofn->Flags;
313 ofn->Flags = ofn->Flags|OFN_WINE;
314
315 /* Initialise the dialog property */
316 fodInfos->DlgInfos.dwDlgProp = 0;
317 fodInfos->DlgInfos.hwndCustomDlg = (HWND)NULL;
318
319 switch(iDlgType)
320 {
321 case OPEN_DIALOG :
322 ret = GetFileName95(fodInfos);
323 break;
324 case SAVE_DIALOG :
325 fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
326#ifdef __WIN32OS2__
327 //NT4 seems to ignore this flag (fixes ElstarFormular save dialog)
328 ofn->Flags &= ~OFN_FILEMUSTEXIST;
329#endif
330 ret = GetFileName95(fodInfos);
331 break;
332 default :
333 ret = 0;
334 }
335
336 if (lpstrSavDir)
337 {
338 SetCurrentDirectoryA(lpstrSavDir);
339 MemFree(lpstrSavDir);
340 }
341
342 if (lpstrInitialDir != (LPCSTR)-1)
343 {
344 MemFree((LPVOID)(ofn->lpstrInitialDir));
345 ofn->lpstrInitialDir = lpstrInitialDir;
346 }
347
348 ofn->Flags = dwFlags;
349 ofn->hInstance = hInstance;
350 MemFree((LPVOID)(fodInfos));
351 return ret;
352}
353
354/***********************************************************************
355 * GetFileDialog95W
356 *
357 * Copy the OPENFILENAMEW structure in a FileOpenDlgInfos structure.
358 * Call GetFileName95 with this structure and clean the memory.
359 *
360 * FIXME: lpstrCustomFilter has to converted back
361 *
362 */
363
364/* converting IN arguments */
365#define AllocInArgWtoA(arg, save) \
366 if(arg) \
367 { \
368 DWORD _len = WideCharToMultiByte( CP_ACP, 0, arg, -1, NULL, 0, NULL, NULL ); \
369 save = arg; \
370 arg = MemAlloc(_len); \
371 WideCharToMultiByte( CP_ACP, 0, save, -1, (LPSTR)arg, _len, NULL, NULL ); \
372 }
373
374#define FreeInArg(arg, save) \
375 if(arg) \
376 { \
377 MemFree((LPSTR)arg); \
378 arg = save; \
379 }
380
381/* converting OUT arguments */
382#define AllocOutArgWtoA(arg, save, len) \
383 if(arg) \
384 { \
385 save = arg; \
386 arg = MemAlloc(len); \
387 }
388
389#define FreeOutArg(arg, save, len) \
390 if(arg) \
391 { \
392 MultiByteToWideChar( CP_ACP, 0, (LPCSTR)(arg), -1, (save), (len) ); \
393 MemFree(arg); \
394 arg = save; \
395 }
396
397BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
398{
399 BOOL ret;
400 FileOpenDlgInfos *fodInfos;
401 HINSTANCE hInstance;
402
403 /* out arguments */
404 LPWSTR lpstrFile = NULL;
405 LPWSTR lpstrFileTitle = NULL;
406#ifdef __WIN32OS2__
407 LPSTR lpstrSavDir = NULL;
408#endif
409
410 /* in/out arguments */
411 LPWSTR lpstrCustomFilter = NULL;
412
413 /* input arguments */
414 LPCWSTR lpstrFilter = NULL;
415 LPCWSTR lpstrInitialDir = NULL;
416 LPCWSTR lpstrTitle = NULL;
417 LPCWSTR lpstrDefExt = NULL;
418 LPCWSTR lpTemplateName = NULL;
419 DWORD dwFlags;
420
421 /* Initialise FileOpenDlgInfos structure*/
422 fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos));
423 ZeroMemory(fodInfos, sizeof(FileOpenDlgInfos));
424
425 /* Pass in the original ofn */
426 fodInfos->ofnInfos = (LPOPENFILENAMEA) ofn;
427
428 /* convert lpstrFilter */
429 if (ofn->lpstrFilter)
430 {
431 LPCWSTR s;
432 LPSTR y;
433 int n, len;
434
435 lpstrFilter = ofn->lpstrFilter;
436
437 /* filter is a list... title\0ext\0......\0\0 */
438 s = ofn->lpstrFilter;
439
440 while (*s) s = s+strlenW(s)+1;
441 s++;
442 n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */
443 len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0, NULL, NULL );
444 y = (LPSTR)MemAlloc(len);
445 WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, y, len, NULL, NULL );
446#ifdef __WIN32OS2__
447 ofn->lpstrFilter = (LPWSTR)y;
448#else
449 (LPSTR)ofn->lpstrFilter = y;
450#endif
451 }
452
453 /* convert lpstrCustomFilter */
454 if (ofn->lpstrCustomFilter)
455 {
456 LPWSTR s;
457 LPSTR y;
458 int n, len;
459
460 lpstrCustomFilter = ofn->lpstrCustomFilter;
461 /* filter is a list... title\0ext\0......\0\0 */
462 s = ofn->lpstrCustomFilter;
463 while (*s) s = s+strlenW(s)+1;
464 s++;
465 n = s - ofn->lpstrCustomFilter;
466 len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0, NULL, NULL );
467 y = (LPSTR)MemAlloc(len);
468 WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, y, len, NULL, NULL );
469#ifdef __WIN32OS2__
470 ofn->lpstrCustomFilter = (LPWSTR)y;
471#else
472 (LPSTR)ofn->lpstrCustomFilter = y;
473#endif
474 }
475
476 /* convert string arguments, save others */
477 AllocOutArgWtoA(ofn->lpstrFile, lpstrFile, ofn->nMaxFile);
478 AllocOutArgWtoA(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
479 AllocInArgWtoA(ofn->lpstrInitialDir, lpstrInitialDir);
480 AllocInArgWtoA(ofn->lpstrTitle, lpstrTitle);
481 AllocInArgWtoA(ofn->lpstrDefExt, lpstrDefExt);
482 AllocInArgWtoA(ofn->lpTemplateName, lpTemplateName);
483 dwFlags = ofn->Flags;
484 hInstance = ofn->hInstance;
485
486#ifdef __WIN32OS2__
487 /* save current directory */
488 if (ofn->Flags & OFN_NOCHANGEDIR)
489 {
490 lpstrSavDir = MemAlloc(MAX_PATH);
491 GetCurrentDirectoryA(MAX_PATH, lpstrSavDir);
492 }
493#endif
494
495 ofn->Flags = ofn->Flags|OFN_WINE|OFN_UNICODE;
496 ofn->hInstance = MapHModuleLS(ofn->hInstance);
497
498 switch(iDlgType)
499 {
500 case OPEN_DIALOG :
501 ret = GetFileName95(fodInfos);
502 break;
503 case SAVE_DIALOG :
504 fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
505#ifdef __WIN32OS2__
506 //NT4 seems to ignore this flag (fixes ElstarFormular save dialog)
507 ofn->Flags &= ~OFN_FILEMUSTEXIST;
508#endif
509 ret = GetFileName95(fodInfos);
510 break;
511 default :
512 ret = 0;
513 }
514
515#ifdef __WIN32OS2__
516 if (lpstrSavDir)
517 {
518 SetCurrentDirectoryA(lpstrSavDir);
519 MemFree(lpstrSavDir);
520 }
521#endif
522
523 /* restore saved IN arguments and convert OUT arguments back */
524 ofn->Flags = dwFlags;
525 ofn->hInstance = hInstance;
526 FreeInArg(ofn->lpstrFilter, lpstrFilter);
527 FreeInArg(ofn->lpstrCustomFilter, lpstrCustomFilter);
528 FreeOutArg(ofn->lpstrFile, lpstrFile, ofn->nMaxFile);
529 FreeOutArg(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
530 FreeInArg(ofn->lpstrInitialDir, lpstrInitialDir);
531 FreeInArg(ofn->lpstrTitle, lpstrTitle);
532 FreeInArg(ofn->lpstrDefExt, lpstrDefExt);
533 FreeInArg(ofn->lpTemplateName, lpTemplateName);
534
535 MemFree((LPVOID)(fodInfos));
536 return ret;
537}
538
539void ArrangeCtrlPositions( HWND hwndChildDlg, HWND hwndParentDlg)
540{
541 HWND hwndChild,hwndStc32;
542 RECT rectParent, rectChild, rectCtrl, rectStc32, rectTemp;
543 POINT ptMoveCtl;
544 POINT ptParentClient;
545
546 TRACE("\n");
547
548 ptMoveCtl.x = ptMoveCtl.y = 0;
549 hwndStc32=GetDlgItem(hwndChildDlg,stc32);
550 GetClientRect(hwndParentDlg,&rectParent);
551 GetClientRect(hwndChildDlg,&rectChild);
552
553 if(hwndStc32)
554 {
555 GetWindowRect(hwndStc32,&rectStc32);
556 MapWindowPoints(0, hwndChildDlg,(LPPOINT)&rectStc32,2);
557 CopyRect(&rectTemp,&rectStc32);
558
559 SetRect(&rectStc32,rectStc32.left,rectStc32.top,rectStc32.left + (rectParent.right-rectParent.left),rectStc32.top+(rectParent.bottom-rectParent.top));
560 SetWindowPos(hwndStc32,0,rectStc32.left,rectStc32.top,rectStc32.right-rectStc32.left,rectStc32.bottom-rectStc32.top,SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE);
561
562 if(rectStc32.right < rectTemp.right)
563 {
564 ptParentClient.x = max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
565 ptMoveCtl.x = 0;
566 }
567 else
568 {
569 ptMoveCtl.x = (rectStc32.right - rectTemp.right);
570 ptParentClient.x = max((rectParent.right-rectParent.left),((rectChild.right-rectChild.left)+rectStc32.right-rectTemp.right));
571 }
572
573 if(rectStc32.bottom < rectTemp.bottom)
574 {
575 ptParentClient.y = max((rectParent.bottom-rectParent.top),(rectChild.bottom-rectChild.top));
576 ptMoveCtl.y = 0;
577 }
578 else
579 {
580 ptMoveCtl.y = (rectStc32.bottom - rectTemp.bottom);
581 ptParentClient.y = max((rectParent.bottom-rectParent.top),((rectChild.bottom-rectChild.top)+rectStc32.bottom-rectTemp.bottom));
582 }
583 }
584 else
585 {
586 if( (GetWindow(hwndChildDlg,GW_CHILD)) == (HWND) NULL) return;
587
588 SetRectEmpty(&rectTemp);
589 ptParentClient.x = max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
590 ptParentClient.y = (rectParent.bottom-rectParent.top) + (rectChild.bottom-rectChild.top);
591 ptMoveCtl.y = rectParent.bottom-rectParent.top;
592 ptMoveCtl.x=0;
593 }
594 SetRect(&rectParent,rectParent.left,rectParent.top,rectParent.left+ptParentClient.x,rectParent.top+ptParentClient.y);
595 AdjustWindowRectEx( &rectParent,GetWindowLongA(hwndParentDlg,GWL_STYLE),FALSE,GetWindowLongA(hwndParentDlg,GWL_EXSTYLE));
596
597 SetWindowPos(hwndChildDlg, 0, 0,0, ptParentClient.x,ptParentClient.y, SWP_NOZORDER );
598 SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top, (rectParent.right- rectParent.left),
599 (rectParent.bottom-rectParent.top),SWP_NOMOVE | SWP_NOZORDER);
600
601 hwndChild = GetWindow(hwndChildDlg,GW_CHILD);
602 if(hwndStc32)
603 {
604 GetWindowRect(hwndStc32,&rectStc32);
605 MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
606 }
607 else
608 SetRect(&rectStc32,0,0,0,0);
609
610 if (hwndChild )
611 {
612 do
613 {
614 if(hwndChild != hwndStc32)
615 {
616 if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
617 continue;
618 GetWindowRect(hwndChild,&rectCtrl);
619 MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
620
621 /*
622 Check the initial position of the controls relative to the initial
623 position and size of stc32 (before it is expanded).
624 */
625 if (rectCtrl.left >= rectTemp.right && rectCtrl.top >= rectTemp.bottom)
626 {
627 rectCtrl.left += ptMoveCtl.x;
628 rectCtrl.top += ptMoveCtl.y;
629 }
630 else if (rectCtrl.left >= rectTemp.right)
631 {
632 rectCtrl.left += ptMoveCtl.x;
633 }
634 else if (rectCtrl.top >= rectTemp.bottom)
635 {
636 rectCtrl.top += ptMoveCtl.y;
637 }
638
639 SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top,
640 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
641 SWP_NOSIZE | SWP_NOZORDER );
642 }
643 } while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
644 }
645 hwndChild = GetWindow(hwndParentDlg,GW_CHILD);
646
647 if(hwndStc32)
648 {
649 GetWindowRect(hwndStc32,&rectStc32);
650 MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
651 ptMoveCtl.x = rectStc32.left - 0;
652 ptMoveCtl.y = rectStc32.top - 0;
653 if (hwndChild )
654 {
655 do
656 {
657 if(hwndChild != hwndChildDlg)
658 {
659 if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
660 continue;
661 GetWindowRect(hwndChild,&rectCtrl);
662 MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
663
664 rectCtrl.left += ptMoveCtl.x;
665 rectCtrl.top += ptMoveCtl.y;
666
667 SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top,
668 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
669 SWP_NOSIZE |SWP_NOZORDER );
670 }
671 } while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
672 }
673 }
674}
675
676
677HRESULT WINAPI FileOpenDlgProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
678{
679 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(GetParent(hwnd),FileOpenDlgInfosStr);
680
681#if 0
682 TRACE("0x%04x\n", uMsg);
683#endif
684
685 switch(uMsg)
686 {
687 case WM_INITDIALOG:
688 {
689 fodInfos = (FileOpenDlgInfos *)lParam;
690 lParam = (LPARAM) fodInfos->ofnInfos;
691 ArrangeCtrlPositions(hwnd,GetParent(hwnd));
692
693 if(fodInfos && IsHooked(fodInfos))
694 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam);
695 return 0;
696 }
697 }
698
699 if(fodInfos && IsHooked(fodInfos))
700 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam);
701
702 return DefWindowProcA(hwnd,uMsg,wParam,lParam);
703}
704
705HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd)
706{
707 LPCVOID template;
708 HRSRC hRes;
709 HANDLE hDlgTmpl = 0;
710 HWND hChildDlg = 0;
711
712 TRACE("\n");
713
714 if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATE ||
715 fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
716 {
717 if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
718 {
719 if( !(template = LockResource( fodInfos->ofnInfos->hInstance)))
720 {
721 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
722 return (HWND)NULL;
723 }
724 }
725 else
726 {
727 if (!(hRes = FindResourceA(MapHModuleSL(fodInfos->ofnInfos->hInstance),
728 (fodInfos->ofnInfos->lpTemplateName), RT_DIALOGA)))
729 {
730 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
731 return (HWND)NULL;
732 }
733 if (!(hDlgTmpl = LoadResource( MapHModuleSL(fodInfos->ofnInfos->hInstance),
734 hRes )) || !(template = LockResource( hDlgTmpl )))
735 {
736 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
737 return (HWND)NULL;
738 }
739 }
740
741 hChildDlg= CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,template,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
742 if(hChildDlg)
743 {
744 ShowWindow(hChildDlg,SW_SHOW);
745 return hChildDlg;
746 }
747 }
748 else if( IsHooked(fodInfos))
749 {
750 RECT rectHwnd;
751 DLGTEMPLATE tmplate;
752 GetClientRect(hwnd,&rectHwnd);
753 tmplate.style = WS_CHILD | WS_CLIPSIBLINGS;
754 tmplate.dwExtendedStyle = 0;
755 tmplate.cdit = 0;
756 tmplate.x = 0;
757 tmplate.y = 0;
758 tmplate.cx = rectHwnd.right-rectHwnd.left;
759 tmplate.cy = rectHwnd.bottom-rectHwnd.top;
760
761 return CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
762 }
763 return (HWND)NULL;
764}
765
766/***********************************************************************
767* SendCustomDlgNotificationMessage
768*
769* Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog
770*/
771
772HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
773{
774 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndParentDlg,FileOpenDlgInfosStr);
775
776 TRACE("0x%04x 0x%04x\n",hwndParentDlg, uCode);
777
778 if(!fodInfos) return 0;
779
780 if(fodInfos->ofnInfos->Flags & OFN_UNICODE)
781 FIXME("sending OPENFILENAMEA structure. Hook is expecting OPENFILENAMEW!\n");
782
783 if(fodInfos->DlgInfos.hwndCustomDlg)
784 {
785 OFNOTIFYA ofnNotify;
786 HRESULT ret;
787 ofnNotify.hdr.hwndFrom=hwndParentDlg;
788 ofnNotify.hdr.idFrom=0;
789 ofnNotify.hdr.code = uCode;
790 ofnNotify.lpOFN = fodInfos->ofnInfos;
791 TRACE("CALL NOTIFY for %x\n", uCode);
792 ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
793 TRACE("RET NOTIFY\n");
794 return ret;
795 }
796 return TRUE;
797}
798
799/***********************************************************************
800* FILEDLG95_HandleCustomDialogMessages
801*
802* Handle Custom Dialog Messages (CDM_FIRST -- CDM_LAST) messages
803*/
804HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
805{
806 LPSTR lpstrFileSpec;
807 int reqSize;
808 char lpstrPath[MAX_PATH];
809 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
810 if(!fodInfos) return -1;
811
812 switch(uMsg)
813 {
814 case CDM_GETFILEPATH:
815 GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath));
816 lpstrFileSpec = (LPSTR)PathFindFileNameA(lpstrPath);
817 if (lpstrFileSpec==lpstrPath)
818 {
819 char lpstrCurrentDir[MAX_PATH];
820 /* Prepend the current path */
821 SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir);
822 if ((LPSTR)lParam!=NULL)
823 snprintf((LPSTR)lParam,(int)wParam,"%s\\%s",lpstrCurrentDir,lpstrPath);
824 reqSize=strlen(lpstrCurrentDir)+1+strlen(lpstrPath)+1;
825 }
826 else
827 {
828 lstrcpynA((LPSTR)lParam,(LPSTR)lpstrPath,(int)wParam);
829 reqSize=strlen(lpstrPath);
830 }
831 /* return the required buffer size */
832 return reqSize;
833
834 case CDM_GETFOLDERPATH:
835 SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
836 if ((LPSTR)lParam!=NULL)
837 lstrcpynA((LPSTR)lParam,lpstrPath,(int)wParam);
838 return strlen(lpstrPath);
839
840 case CDM_GETSPEC:
841 reqSize=GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath));
842 lpstrFileSpec = (LPSTR)PathFindFileNameA(lpstrPath);
843 if ((LPSTR)lParam!=NULL)
844 lstrcpynA((LPSTR)lParam, lpstrFileSpec, (int)wParam);
845 return strlen(lpstrFileSpec);
846
847 case CDM_SETCONTROLTEXT:
848 if ( 0 != lParam )
849 SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam );
850 return TRUE;
851
852 case CDM_HIDECONTROL:
853 case CDM_SETDEFEXT:
854 FIXME("CDM_HIDECONTROL,CDM_SETCONTROLTEXT,CDM_SETDEFEXT not implemented\n");
855 return -1;
856 }
857 return TRUE;
858}
859
860/***********************************************************************
861 * FileOpenDlgProc95
862 *
863 * File open dialog procedure
864 */
865HRESULT WINAPI FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
866{
867#if 0
868 TRACE("0x%04x 0x%04x\n", hwnd, uMsg);
869#endif
870
871 switch(uMsg)
872 {
873 case WM_INITDIALOG:
874 {
875 FileOpenDlgInfos * fodInfos = (FileOpenDlgInfos *)lParam;
876
877 /* Adds the FileOpenDlgInfos in the property list of the dialog
878 so it will be easily accessible through a GetPropA(...) */
879 SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos);
880
881 fodInfos->DlgInfos.hwndCustomDlg =
882 CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);
883
884 FILEDLG95_InitControls(hwnd);
885 SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
886 FILEDLG95_FillControls(hwnd, wParam, lParam);
887 SendCustomDlgNotificationMessage(hwnd,CDN_SELCHANGE);
888 SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
889 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);
890 return 0;
891 }
892 case WM_COMMAND:
893 return FILEDLG95_OnWMCommand(hwnd, wParam, lParam);
894 case WM_DRAWITEM:
895 {
896 switch(((LPDRAWITEMSTRUCT)lParam)->CtlID)
897 {
898 case IDC_LOOKIN:
899 FILEDLG95_LOOKIN_DrawItem((LPDRAWITEMSTRUCT) lParam);
900 return TRUE;
901 }
902 }
903 return FALSE;
904
905 case WM_GETISHELLBROWSER:
906 return FILEDLG95_OnWMGetIShellBrowser(hwnd);
907
908 case WM_DESTROY:
909 RemovePropA(hwnd, FileOpenDlgInfosStr);
910 return FALSE;
911
912 case WM_NOTIFY:
913 {
914 LPNMHDR lpnmh = (LPNMHDR)lParam;
915 UINT stringId = -1;
916
917 /* set up the button tooltips strings */
918 if(TTN_GETDISPINFOA == lpnmh->code )
919 {
920 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
921 switch(lpnmh->idFrom )
922 {
923 /* Up folder button */
924 case FCIDM_TB_UPFOLDER:
925 stringId = IDS_UPFOLDER;
926 break;
927 /* New folder button */
928 case FCIDM_TB_NEWFOLDER:
929 stringId = IDS_NEWFOLDER;
930 break;
931 /* List option button */
932 case FCIDM_TB_SMALLICON:
933 stringId = IDS_LISTVIEW;
934 break;
935 /* Details option button */
936 case FCIDM_TB_REPORTVIEW:
937 stringId = IDS_REPORTVIEW;
938 break;
939 /* Desktop button */
940 case FCIDM_TB_DESKTOP:
941 stringId = IDS_TODESKTOP;
942 break;
943 default:
944 stringId = 0;
945 }
946 lpdi->hinst = COMMDLG_hInstance32;
947 lpdi->lpszText = (LPSTR) stringId;
948 }
949 return FALSE;
950 }
951 default :
952 if(uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
953 return FILEDLG95_HandleCustomDialogMessages(hwnd, uMsg, wParam, lParam);
954 return FALSE;
955 }
956}
957
958/***********************************************************************
959 * FILEDLG95_InitControls
960 *
961 * WM_INITDIALOG message handler (before hook notification)
962 */
963static LRESULT FILEDLG95_InitControls(HWND hwnd)
964{
965 TBBUTTON tbb[] =
966 {
967 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
968 {VIEW_PARENTFOLDER, FCIDM_TB_UPFOLDER, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
969 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
970 {VIEW_NEWFOLDER+1, FCIDM_TB_DESKTOP, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
971 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
972 {VIEW_NEWFOLDER, FCIDM_TB_NEWFOLDER, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
973 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
974 {VIEW_LIST, FCIDM_TB_SMALLICON, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
975 {VIEW_DETAILS, FCIDM_TB_REPORTVIEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
976 };
977 TBADDBITMAP tba[] =
978 {
979 { HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR },
980 { COMDLG32_hInstance, 800 } // desktop icon
981 };
982
983 RECT rectTB;
984
985 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
986
987 TRACE("%p\n", fodInfos);
988
989 /* Get the hwnd of the controls */
990 fodInfos->DlgInfos.hwndFileName = GetDlgItem(hwnd,IDC_FILENAME);
991 fodInfos->DlgInfos.hwndFileTypeCB = GetDlgItem(hwnd,IDC_FILETYPE);
992 fodInfos->DlgInfos.hwndLookInCB = GetDlgItem(hwnd,IDC_LOOKIN);
993
994 /* construct the toolbar */
995 GetWindowRect(GetDlgItem(hwnd,IDC_TOOLBARSTATIC),&rectTB);
996 MapWindowPoints( 0, hwnd,(LPPOINT)&rectTB,2);
997
998 fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, (LPSTR) NULL,
999 WS_CHILD | WS_GROUP | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE,
1000 0, 0, 150, 26, hwnd, (HMENU) IDC_TOOLBAR, COMMDLG_hInstance32, NULL);
1001
1002 SetWindowPos(fodInfos->DlgInfos.hwndTB, 0,
1003 rectTB.left,rectTB.top, rectTB.right-rectTB.left, rectTB.bottom-rectTB.top,
1004 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER );
1005
1006 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
1007
1008/* fixme: use TB_LOADIMAGES when implemented */
1009/* SendMessageA(fodInfos->DlgInfos.hwndTB, TB_LOADIMAGES, (WPARAM) IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);*/
1010 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, (WPARAM) 12, (LPARAM) &tba[0]);
1011 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, (WPARAM) 1, (LPARAM) &tba[1]);
1012
1013 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSA, (WPARAM) 9,(LPARAM) &tbb);
1014 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
1015
1016 /* Set the window text with the text specified in the OPENFILENAME structure */
1017 if(fodInfos->ofnInfos->lpstrTitle)
1018 {
1019 SetWindowTextA(hwnd,fodInfos->ofnInfos->lpstrTitle);
1020 }
1021 else if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
1022 {
1023 SetWindowTextA(hwnd,"Save");
1024 }
1025
1026 /* Initialise the file name edit control */
1027 if(fodInfos->ofnInfos->lpstrFile)
1028 {
1029 LPSTR lpstrFile = PathFindFileNameA(fodInfos->ofnInfos->lpstrFile);
1030 SetDlgItemTextA(hwnd, IDC_FILENAME, lpstrFile);
1031 }
1032
1033 /* Must the open as read only check box be checked ?*/
1034 if(fodInfos->ofnInfos->Flags & OFN_READONLY)
1035 {
1036 SendDlgItemMessageA(hwnd,IDC_OPENREADONLY,BM_SETCHECK,(WPARAM)TRUE,0);
1037 }
1038
1039 /* Must the open as read only check box be hid ?*/
1040 if(fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY)
1041 {
1042 ShowWindow(GetDlgItem(hwnd,IDC_OPENREADONLY),SW_HIDE);
1043 }
1044
1045 /* Must the help button be hid ?*/
1046 if (!(fodInfos->ofnInfos->Flags & OFN_SHOWHELP))
1047 {
1048 ShowWindow(GetDlgItem(hwnd, pshHelp), SW_HIDE);
1049 }
1050
1051 /* Resize the height, if open as read only checkbox ad help button
1052 are hidden and we are not using a custom template */
1053 if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) &&
1054 (!(fodInfos->ofnInfos->Flags &
1055 (OFN_SHOWHELP|OFN_ENABLETEMPLATE|OFN_ENABLETEMPLATEHANDLE))))
1056 {
1057 RECT rectDlg, rectHelp, rectCancel;
1058 GetWindowRect(hwnd, &rectDlg);
1059 GetWindowRect(GetDlgItem(hwnd, pshHelp), &rectHelp);
1060 GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel);
1061 /* subtract the height of the help button plus the space between
1062 the help button and the cancel button to the height of the dialog */
1063 SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left,
1064 (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom),
1065 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
1066 }
1067
1068 /* change Open to Save FIXME: use resources */
1069 if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
1070 {
1071 SetDlgItemTextA(hwnd,IDOK,"&Save");
1072 SetDlgItemTextA(hwnd,IDC_LOOKINSTATIC,"Save &in");
1073 }
1074 return 0;
1075}
1076
1077/***********************************************************************
1078 * FILEDLG95_FillControls
1079 *
1080 * WM_INITDIALOG message handler (after hook notification)
1081 */
1082static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
1083{
1084 LPITEMIDLIST pidlItemId = NULL;
1085
1086 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) lParam;
1087
1088 TRACE("dir=%s file=%s\n",
1089 fodInfos->ofnInfos->lpstrInitialDir, fodInfos->ofnInfos->lpstrFile);
1090
1091 /* Get the initial directory pidl */
1092
1093 if(!(pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder,fodInfos->ofnInfos->lpstrInitialDir)))
1094 {
1095 char path[MAX_PATH];
1096
1097 GetCurrentDirectoryA(MAX_PATH,path);
1098 pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder, path);
1099 }
1100
1101 /* Initialise shell objects */
1102 FILEDLG95_SHELL_Init(hwnd);
1103
1104 /* Initialize the Look In combo box */
1105 FILEDLG95_LOOKIN_Init(fodInfos->DlgInfos.hwndLookInCB);
1106
1107 /* Initialize the filter combo box */
1108 FILEDLG95_FILETYPE_Init(hwnd);
1109
1110 /* Browse to the initial directory */
1111 IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,pidlItemId, SBSP_ABSOLUTE);
1112
1113 /* Free pidlItem memory */
1114 COMDLG32_SHFree(pidlItemId);
1115
1116 return TRUE;
1117}
1118/***********************************************************************
1119 * FILEDLG95_Clean
1120 *
1121 * Regroups all the cleaning functions of the filedlg
1122 */
1123void FILEDLG95_Clean(HWND hwnd)
1124{
1125 FILEDLG95_FILETYPE_Clean(hwnd);
1126 FILEDLG95_LOOKIN_Clean(hwnd);
1127 FILEDLG95_SHELL_Clean(hwnd);
1128}
1129/***********************************************************************
1130 * FILEDLG95_OnWMCommand
1131 *
1132 * WM_COMMAND message handler
1133 */
1134static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
1135{
1136 WORD wNotifyCode = HIWORD(wParam); /* notification code */
1137 WORD wID = LOWORD(wParam); /* item, control, or accelerator identifier */
1138 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1139
1140 switch(wID)
1141 {
1142 /* OK button */
1143 case IDOK:
1144 if(FILEDLG95_OnOpen(hwnd))
1145 SendCustomDlgNotificationMessage(hwnd,CDN_FILEOK);
1146 break;
1147 /* Cancel button */
1148 case IDCANCEL:
1149 FILEDLG95_Clean(hwnd);
1150 EndDialog(hwnd, FALSE);
1151 break;
1152 /* Filetype combo box */
1153 case IDC_FILETYPE:
1154 FILEDLG95_FILETYPE_OnCommand(hwnd,wNotifyCode);
1155 break;
1156 /* LookIn combo box */
1157 case IDC_LOOKIN:
1158 FILEDLG95_LOOKIN_OnCommand(hwnd,wNotifyCode);
1159 break;
1160
1161 /* --- toolbar --- */
1162 /* Up folder button */
1163 case FCIDM_TB_UPFOLDER:
1164 FILEDLG95_SHELL_UpFolder(hwnd);
1165 break;
1166 /* New folder button */
1167 case FCIDM_TB_NEWFOLDER:
1168 FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_NEWFOLDER);
1169 break;
1170 /* List option button */
1171 case FCIDM_TB_SMALLICON:
1172 FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWLIST);
1173 break;
1174 /* Details option button */
1175 case FCIDM_TB_REPORTVIEW:
1176 FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWDETAILS);
1177 break;
1178 /* Details option button */
1179 case FCIDM_TB_DESKTOP:
1180 FILEDLG95_SHELL_BrowseToDesktop(hwnd);
1181 break;
1182
1183 case IDC_FILENAME:
1184 break;
1185
1186 }
1187 /* Do not use the listview selection anymore */
1188 fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
1189 return 0;
1190}
1191
1192/***********************************************************************
1193 * FILEDLG95_OnWMGetIShellBrowser
1194 *
1195 * WM_GETISHELLBROWSER message handler
1196 */
1197static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd)
1198{
1199
1200 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1201
1202 TRACE("\n");
1203
1204 SetWindowLongA(hwnd,DWL_MSGRESULT,(LONG)fodInfos->Shell.FOIShellBrowser);
1205
1206 return TRUE;
1207}
1208
1209
1210/***********************************************************************
1211 * FILEDLG95_OnOpenMultipleFiles
1212 *
1213 * Handles the opening of multiple files.
1214 *
1215 * FIXME
1216 * check destination buffer size
1217 */
1218BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
1219{
1220 CHAR lpstrPathSpec[MAX_PATH] = "";
1221 LPSTR lpstrFile;
1222 UINT nCount, nSizePath;
1223 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1224
1225 TRACE("\n");
1226
1227 lpstrFile = fodInfos->ofnInfos->lpstrFile;
1228 lpstrFile[0] = '\0';
1229
1230 SHGetPathFromIDListA( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
1231
1232 if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
1233 ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST))
1234 {
1235 LPSTR lpstrTemp = lpstrFileList;
1236
1237 for ( nCount = 0; nCount < nFileCount; nCount++ )
1238 {
1239 LPITEMIDLIST pidl;
1240
1241 pidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, lpstrTemp);
1242 if (!pidl)
1243 {
1244 CHAR lpstrNotFound[100];
1245 CHAR lpstrMsg[100];
1246 CHAR tmp[400];
1247
1248 LoadStringA(COMMDLG_hInstance32, IDS_FILENOTFOUND, lpstrNotFound, 100);
1249 LoadStringA(COMMDLG_hInstance32, IDS_VERIFYFILE, lpstrMsg, 100);
1250
1251 strcpy(tmp, lpstrTemp);
1252 strcat(tmp, "\n");
1253 strcat(tmp, lpstrNotFound);
1254 strcat(tmp, "\n");
1255 strcat(tmp, lpstrMsg);
1256
1257 MessageBoxA(hwnd, tmp, fodInfos->ofnInfos->lpstrTitle, MB_OK | MB_ICONEXCLAMATION);
1258 return FALSE;
1259 }
1260
1261 /* move to the next file in the list of files */
1262 lpstrTemp += strlen(lpstrTemp) + 1;
1263 COMDLG32_SHFree(pidl);
1264 }
1265 }
1266
1267 nSizePath = strlen(lpstrPathSpec);
1268 strcpy( lpstrFile, lpstrPathSpec);
1269 memcpy( lpstrFile + nSizePath + 1, lpstrFileList, sizeUsed );
1270
1271 fodInfos->ofnInfos->nFileOffset = nSizePath + 1;
1272 fodInfos->ofnInfos->nFileExtension = 0;
1273
1274 /* clean and exit */
1275 FILEDLG95_Clean(hwnd);
1276 return EndDialog(hwnd,TRUE);
1277}
1278
1279/***********************************************************************
1280 * FILEDLG95_OnOpen
1281 *
1282 * Ok button WM_COMMAND message handler
1283 *
1284 * If the function succeeds, the return value is nonzero.
1285 */
1286#define ONOPEN_BROWSE 1
1287#define ONOPEN_OPEN 2
1288#define ONOPEN_SEARCH 3
1289static void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText)
1290{
1291 char strMsgTitle[MAX_PATH];
1292 char strMsgText [MAX_PATH];
1293 if (idCaption)
1294 LoadStringA(COMDLG32_hInstance, idCaption, strMsgTitle, sizeof(strMsgTitle));
1295 else
1296 strMsgTitle[0] = '\0';
1297 LoadStringA(COMDLG32_hInstance, idText, strMsgText, sizeof(strMsgText));
1298 MessageBoxA(hwnd,strMsgText, strMsgTitle, MB_OK | MB_ICONHAND);
1299}
1300
1301BOOL FILEDLG95_OnOpen(HWND hwnd)
1302{
1303 char * lpstrFileList;
1304 UINT nFileCount = 0;
1305 UINT sizeUsed = 0;
1306 BOOL ret = TRUE;
1307 char lpstrPathAndFile[MAX_PATH];
1308 char lpstrTemp[MAX_PATH];
1309 LPSHELLFOLDER lpsf = NULL;
1310 int nOpenAction;
1311 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1312
1313 TRACE("hwnd=0x%04x\n", hwnd);
1314
1315 /* get the files from the edit control */
1316 nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed);
1317
1318 /* try if the user selected a folder in the shellview */
1319 if(nFileCount == 0)
1320 {
1321 BrowseSelectedFolder(hwnd);
1322 return FALSE;
1323 }
1324
1325 if(nFileCount > 1)
1326 {
1327 ret = FILEDLG95_OnOpenMultipleFiles(hwnd, lpstrFileList, nFileCount, sizeUsed);
1328 goto ret;
1329 }
1330
1331 TRACE("count=%u len=%u file=%s\n", nFileCount, sizeUsed, lpstrFileList);
1332
1333/*
1334 Step 1: Build a complete path name from the current folder and
1335 the filename or path in the edit box.
1336 Special cases:
1337 - the path in the edit box is a root path
1338 (with or without drive letter)
1339 - the edit box contains ".." (or a path with ".." in it)
1340*/
1341
1342 /* Get the current directory name */
1343 if (!SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))
1344 {
1345 /* we are in a special folder, default to desktop */
1346 if(FAILED(COMDLG32_SHGetFolderPathA(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, lpstrPathAndFile)))
1347 {
1348 /* last fallback */
1349 GetCurrentDirectoryA(MAX_PATH, lpstrPathAndFile);
1350 }
1351 }
1352 PathAddBackslashA(lpstrPathAndFile);
1353
1354 TRACE("current directory=%s\n", lpstrPathAndFile);
1355
1356 /* if the user specifyed a fully qualified path use it */
1357 if(PathIsRelativeA(lpstrFileList))
1358 {
1359 strcat(lpstrPathAndFile, lpstrFileList);
1360 }
1361 else
1362 {
1363 /* does the path have a drive letter? */
1364 if (PathGetDriveNumberA(lpstrFileList) == -1)
1365 strcpy(lpstrPathAndFile+2, lpstrFileList);
1366 else
1367 strcpy(lpstrPathAndFile, lpstrFileList);
1368 }
1369
1370 /* resolve "." and ".." */
1371 PathCanonicalizeA(lpstrTemp, lpstrPathAndFile );
1372 strcpy(lpstrPathAndFile, lpstrTemp);
1373 TRACE("canon=%s\n", lpstrPathAndFile);
1374
1375 MemFree(lpstrFileList);
1376
1377/*
1378 Step 2: here we have a cleaned up path
1379
1380 We have to parse the path step by step to see if we have to browse
1381 to a folder if the path points to a directory or the last
1382 valid element is a directory.
1383
1384 valid variables:
1385 lpstrPathAndFile: cleaned up path
1386 */
1387
1388 nOpenAction = ONOPEN_BROWSE;
1389
1390#ifdef __WIN32OS2__
1391 /* @@@AH 2001-06-02 moved out of !OFN_NONVALIDATE block - needs to be set */
1392 if (FAILED (SHGetDesktopFolder(&lpsf))) return FALSE;
1393#endif
1394
1395 /* dont apply any checks with OFN_NOVALIDATE */
1396 if(!(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE))
1397 {
1398 LPSTR lpszTemp, lpszTemp1;
1399 LPITEMIDLIST pidl = NULL;
1400
1401 /* check for invalid chars */
1402 if(strpbrk(lpstrPathAndFile+3, "/:<>|") != NULL)
1403 {
1404 FILEDLG95_OnOpenMessage(hwnd, IDS_INVALID_FILENAME_TITLE, IDS_INVALID_FILENAME);
1405 ret = FALSE;
1406 goto ret;
1407 }
1408#ifndef __WIN32OS2__
1409 if (FAILED (SHGetDesktopFolder(&lpsf))) return FALSE;
1410#endif
1411 lpszTemp1 = lpszTemp = lpstrPathAndFile;
1412 while (lpszTemp1)
1413 {
1414 LPSHELLFOLDER lpsfChild;
1415 WCHAR lpwstrTemp[MAX_PATH];
1416 DWORD dwEaten, dwAttributes;
1417
1418 lpszTemp = PathFindNextComponentA(lpszTemp);
1419
1420 if (!lpszTemp) break; /* end of path */
1421
1422 if(*lpszTemp)
1423 {
1424 DWORD len = MultiByteToWideChar( CP_ACP, 0, lpszTemp1, lpszTemp - lpszTemp1,
1425 lpwstrTemp, MAX_PATH );
1426 lpwstrTemp[len] = 0;
1427 }
1428 else
1429 {
1430 MultiByteToWideChar( CP_ACP, 0, lpszTemp1, -1,
1431 lpwstrTemp, sizeof(lpwstrTemp)/sizeof(WCHAR) );
1432
1433 /* if the last element is a wildcard do a search */
1434 if(strpbrk(lpszTemp1, "*?") != NULL)
1435 {
1436 nOpenAction = ONOPEN_SEARCH;
1437 break;
1438 }
1439 }
1440 lpszTemp1 = lpszTemp;
1441
1442 TRACE("parse now=%s next=%s sf=%p\n",debugstr_w(lpwstrTemp), debugstr_a(lpszTemp), lpsf);
1443
1444 if(lstrlenW(lpwstrTemp)==2) PathAddBackslashW(lpwstrTemp);
1445
1446 dwAttributes = SFGAO_FOLDER;
1447 if(SUCCEEDED(IShellFolder_ParseDisplayName(lpsf, hwnd, NULL, lpwstrTemp, &dwEaten, &pidl, &dwAttributes)))
1448 {
1449 /* the path component is valid, we have a pidl of the next path component */
1450 TRACE("parse OK attr=0x%08lx pidl=%p\n", dwAttributes, pidl);
1451 if(dwAttributes & SFGAO_FOLDER)
1452 {
1453 if(FAILED(IShellFolder_BindToObject(lpsf, pidl, 0, &IID_IShellFolder, (LPVOID*)&lpsfChild)))
1454 {
1455 ERR("bind to failed\n"); /* should not fail */
1456 break;
1457 }
1458 IShellFolder_Release(lpsf);
1459 lpsf = lpsfChild;
1460 lpsfChild = NULL;
1461 }
1462 else
1463 {
1464 TRACE("value\n");
1465
1466 /* end dialog, return value */
1467 nOpenAction = ONOPEN_OPEN;
1468 break;
1469 }
1470 COMDLG32_SHFree(pidl);
1471 pidl = NULL;
1472 }
1473 else
1474 {
1475 if(*lpszTemp) /* points to trailing null for last path element */
1476 {
1477 if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST)
1478 {
1479 FILEDLG95_OnOpenMessage(hwnd, 0, IDS_PATHNOTEXISTING);
1480 break;
1481 }
1482 }
1483 else
1484 {
1485 if(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST)
1486 {
1487 FILEDLG95_OnOpenMessage(hwnd, 0, IDS_FILENOTEXISTING);
1488 break;
1489 }
1490 }
1491 /* change to the current folder */
1492 nOpenAction = ONOPEN_OPEN;
1493 break;
1494 }
1495 }
1496 if(pidl) COMDLG32_SHFree(pidl);
1497 }
1498#ifdef __WIN32OS2__
1499 else
1500 {
1501 // @@@AH 2001-06-02 when we are in OFN_NOVALIDATE mode, the action
1502 // must be to open the specified file when pressing open button
1503 TRACE("OFN_NOVALIDATE mode, set open action to ONOPEN_OPEN\n");
1504 nOpenAction = ONOPEN_OPEN;
1505 }
1506#endif
1507
1508/*
1509 Step 3: here we have a cleaned up and validated path
1510
1511 valid variables:
1512 lpsf: ShellFolder bound to the rightmost valid path component
1513 lpstrPathAndFile: cleaned up path
1514 nOpenAction: action to do
1515*/
1516 TRACE("end validate sf=%p\n", lpsf);
1517
1518 switch(nOpenAction)
1519 {
1520 case ONOPEN_SEARCH: /* set the current filter to the file mask and refresh */
1521 TRACE("ONOPEN_SEARCH %s\n", lpstrPathAndFile);
1522 {
1523 int iPos;
1524 LPSTR lpszTemp = PathFindFileNameA(lpstrPathAndFile);
1525 DWORD len;
1526
1527 /* replace the current filter */
1528 if(fodInfos->ShellInfos.lpstrCurrentFilter)
1529 MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
1530 len = MultiByteToWideChar( CP_ACP, 0, lpszTemp, -1, NULL, 0 );
1531 fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc(len * sizeof(WCHAR));
1532 MultiByteToWideChar( CP_ACP, 0, lpszTemp, -1,
1533 fodInfos->ShellInfos.lpstrCurrentFilter, len );
1534
1535 /* set the filter cb to the extension when possible */
1536 if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))
1537 CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, iPos);
1538 }
1539 /* fall through */
1540 case ONOPEN_BROWSE: /* browse to the highest folder we could bind to */
1541 TRACE("ONOPEN_BROWSE\n");
1542 {
1543 IPersistFolder2 * ppf2;
1544 if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2)))
1545 {
1546 LPITEMIDLIST pidlCurrent;
1547 IPersistFolder2_GetCurFolder(ppf2, &pidlCurrent);
1548 IPersistFolder2_Release(ppf2);
1549 if( ! COMDLG32_PIDL_ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))
1550 {
1551 IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE);
1552 }
1553 else if( nOpenAction == ONOPEN_SEARCH )
1554 {
1555 IShellView_Refresh(fodInfos->Shell.FOIShellView);
1556 }
1557 COMDLG32_SHFree(pidlCurrent);
1558 }
1559 }
1560 ret = FALSE;
1561 break;
1562 case ONOPEN_OPEN: /* fill in the return struct and close the dialog */
1563 TRACE("ONOPEN_OPEN %s\n", lpstrPathAndFile);
1564 {
1565 /* add default extension */
1566 if (fodInfos->ofnInfos->lpstrDefExt)
1567 {
1568 if (! *PathFindExtensionA(lpstrPathAndFile))
1569 {
1570 strcat(lpstrPathAndFile, ".");
1571 strcat(lpstrPathAndFile, fodInfos->ofnInfos->lpstrDefExt);
1572 }
1573 }
1574
1575 /* Check that the size of the file does not exceed buffer size.
1576 (Allow for extra \0 if OFN_MULTISELECT is set.) */
1577 if(strlen(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile -
1578 ((fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT) ? 1 : 0))
1579 {
1580 LPSTR lpszTemp;
1581
1582 /* fill destination buffer */
1583 strcpy(fodInfos->ofnInfos->lpstrFile, lpstrPathAndFile);
1584 if (fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT)
1585 fodInfos->ofnInfos->lpstrFile[strlen(fodInfos->ofnInfos->lpstrFile)
1586 + 1] = '\0';
1587
1588 /* set filename offset */
1589 lpszTemp = PathFindFileNameA(lpstrPathAndFile);
1590 fodInfos->ofnInfos->nFileOffset = lpszTemp - lpstrPathAndFile;
1591
1592 /* set extension offset */
1593 lpszTemp = PathFindExtensionA(lpstrPathAndFile);
1594 fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? lpszTemp - lpstrPathAndFile + 1 : 0;
1595
1596 /* set the lpstrFileTitle */
1597 if(fodInfos->ofnInfos->lpstrFileTitle)
1598 {
1599 LPSTR lpstrFileTitle = PathFindFileNameA(lpstrPathAndFile);
1600 strncpy(fodInfos->ofnInfos->lpstrFileTitle, lpstrFileTitle, fodInfos->ofnInfos->nMaxFileTitle);
1601 }
1602
1603 /* ask the hook if we can close */
1604 if(IsHooked(fodInfos))
1605 {
1606 /* FIXME we are sending ASCII-structures. Does not work with NT */
1607 /* first old style */
1608 TRACE("---\n");
1609 CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,
1610 fodInfos->DlgInfos.hwndCustomDlg,
1611 fodInfos->HookMsg.fileokstring, 0, (LPARAM)fodInfos->ofnInfos);
1612 if (GetWindowLongA(hwnd, DWL_MSGRESULT))
1613 {
1614 TRACE("cancled\n");
1615 ret = FALSE;
1616 goto ret;
1617 }
1618 }
1619
1620 TRACE("close\n");
1621 FILEDLG95_Clean(hwnd);
1622 ret = EndDialog(hwnd, TRUE);
1623 }
1624 else
1625 {
1626 /* FIXME set error FNERR_BUFFERTOSMALL */
1627 FILEDLG95_Clean(hwnd);
1628 ret = EndDialog(hwnd, FALSE);
1629 }
1630 goto ret;
1631 }
1632 break;
1633 }
1634
1635ret:
1636 if(lpsf) IShellFolder_Release(lpsf);
1637 return ret;
1638}
1639
1640/***********************************************************************
1641 * FILEDLG95_SHELL_Init
1642 *
1643 * Initialisation of the shell objects
1644 */
1645static HRESULT FILEDLG95_SHELL_Init(HWND hwnd)
1646{
1647 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1648
1649 TRACE("\n");
1650
1651 /*
1652 * Initialisation of the FileOpenDialogInfos structure
1653 */
1654
1655 /* Shell */
1656
1657 /*ShellInfos */
1658 fodInfos->ShellInfos.hwndOwner = hwnd;
1659
1660 /* Disable multi-select if flag not set */
1661 if (!(fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT))
1662 {
1663 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL;
1664 }
1665 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_AUTOARRANGE | FWF_ALIGNLEFT;
1666 fodInfos->ShellInfos.folderSettings.ViewMode = FVM_LIST;
1667
1668 GetWindowRect(GetDlgItem(hwnd,IDC_SHELLSTATIC),&fodInfos->ShellInfos.rectView);
1669 ScreenToClient(hwnd,(LPPOINT)&fodInfos->ShellInfos.rectView.left);
1670 ScreenToClient(hwnd,(LPPOINT)&fodInfos->ShellInfos.rectView.right);
1671
1672 /* Construct the IShellBrowser interface */
1673 fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd);
1674
1675 return NOERROR;
1676}
1677
1678/***********************************************************************
1679 * FILEDLG95_SHELL_ExecuteCommand
1680 *
1681 * Change the folder option and refresh the view
1682 * If the function succeeds, the return value is nonzero.
1683 */
1684static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb)
1685{
1686 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1687
1688 IContextMenu * pcm;
1689 TRACE("(0x%08x,%p)\n", hwnd, lpVerb);
1690
1691 if(SUCCEEDED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView,
1692 SVGIO_BACKGROUND,
1693 &IID_IContextMenu,
1694 (LPVOID*)&pcm)))
1695 {
1696 CMINVOKECOMMANDINFO ci;
1697 ZeroMemory(&ci, sizeof(CMINVOKECOMMANDINFO));
1698 ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
1699 ci.lpVerb = lpVerb;
1700 ci.hwnd = hwnd;
1701
1702 IContextMenu_InvokeCommand(pcm, &ci);
1703 IContextMenu_Release(pcm);
1704 }
1705
1706 return FALSE;
1707}
1708
1709/***********************************************************************
1710 * FILEDLG95_SHELL_UpFolder
1711 *
1712 * Browse to the specified object
1713 * If the function succeeds, the return value is nonzero.
1714 */
1715static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd)
1716{
1717 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1718
1719 TRACE("\n");
1720
1721 if(SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
1722 NULL,
1723 SBSP_PARENT)))
1724 {
1725 return TRUE;
1726 }
1727 return FALSE;
1728}
1729
1730/***********************************************************************
1731 * FILEDLG95_SHELL_BrowseToDesktop
1732 *
1733 * Browse to the Desktop
1734 * If the function succeeds, the return value is nonzero.
1735 */
1736static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd)
1737{
1738 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1739 LPITEMIDLIST pidl;
1740 HRESULT hres;
1741
1742 TRACE("\n");
1743
1744 SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidl);
1745 hres = IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);
1746 COMDLG32_SHFree(pidl);
1747 return SUCCEEDED(hres);
1748}
1749/***********************************************************************
1750 * FILEDLG95_SHELL_Clean
1751 *
1752 * Cleans the memory used by shell objects
1753 */
1754static void FILEDLG95_SHELL_Clean(HWND hwnd)
1755{
1756 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1757
1758 TRACE("\n");
1759
1760 COMDLG32_SHFree(fodInfos->ShellInfos.pidlAbsCurrent);
1761
1762 /* clean Shell interfaces */
1763 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
1764 IShellView_Release(fodInfos->Shell.FOIShellView);
1765 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
1766 IShellBrowser_Release(fodInfos->Shell.FOIShellBrowser);
1767 if (fodInfos->Shell.FOIDataObject)
1768 IDataObject_Release(fodInfos->Shell.FOIDataObject);
1769}
1770
1771/***********************************************************************
1772 * FILEDLG95_FILETYPE_Init
1773 *
1774 * Initialisation of the file type combo box
1775 */
1776static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
1777{
1778 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1779
1780 TRACE("\n");
1781
1782 if(fodInfos->ofnInfos->lpstrFilter)
1783 {
1784 int nFilters = 0; /* number of filters */
1785 LPSTR lpstrFilter;
1786 LPCSTR lpstrPos = fodInfos->ofnInfos->lpstrFilter;
1787
1788 for(;;)
1789 {
1790 /* filter is a list... title\0ext\0......\0\0
1791 * Set the combo item text to the title and the item data
1792 * to the ext
1793 */
1794 LPCSTR lpstrDisplay;
1795 LPSTR lpstrExt;
1796
1797 /* Get the title */
1798 if(! *lpstrPos) break; /* end */
1799 lpstrDisplay = lpstrPos;
1800 lpstrPos += strlen(lpstrPos) + 1;
1801
1802 /* Copy the extensions */
1803 if (! *lpstrPos) return E_FAIL; /* malformed filter */
1804 if (!(lpstrExt = (LPSTR) MemAlloc(strlen(lpstrPos)+1))) return E_FAIL;
1805 strcpy(lpstrExt,lpstrPos);
1806 lpstrPos += strlen(lpstrPos) + 1;
1807
1808 /* Add the item at the end of the combo */
1809 CBAddString(fodInfos->DlgInfos.hwndFileTypeCB, lpstrDisplay);
1810 CBSetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, nFilters, lpstrExt);
1811 nFilters++;
1812 }
1813 /*
1814 * Set the current filter to the one specified
1815 * in the initialisation structure
1816 * FIXME: lpstrCustomFilter not handled at all
1817 */
1818
1819 /* set default filter index */
1820 if(fodInfos->ofnInfos->nFilterIndex == 0 && fodInfos->ofnInfos->lpstrCustomFilter == NULL)
1821 fodInfos->ofnInfos->nFilterIndex = 1;
1822
1823 /* First, check to make sure our index isn't out of bounds. */
1824 if ( fodInfos->ofnInfos->nFilterIndex > nFilters )
1825 fodInfos->ofnInfos->nFilterIndex = nFilters;
1826
1827 /* Set the current index selection. */
1828 CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, fodInfos->ofnInfos->nFilterIndex-1);
1829
1830 /* Get the corresponding text string from the combo box. */
1831 lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
1832 fodInfos->ofnInfos->nFilterIndex-1);
1833
1834 if ((INT)lpstrFilter == CB_ERR) /* control is empty */
1835 lpstrFilter = NULL;
1836
1837 if(lpstrFilter)
1838 {
1839 DWORD len;
1840 _strlwr(lpstrFilter); /* lowercase */
1841 len = MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1, NULL, 0 );
1842 fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
1843 MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1,
1844 fodInfos->ShellInfos.lpstrCurrentFilter, len );
1845 }
1846 }
1847 return NOERROR;
1848}
1849
1850/***********************************************************************
1851 * FILEDLG95_FILETYPE_OnCommand
1852 *
1853 * WM_COMMAND of the file type combo box
1854 * If the function succeeds, the return value is nonzero.
1855 */
1856static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
1857{
1858 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1859
1860 switch(wNotifyCode)
1861 {
1862 case CBN_SELENDOK:
1863 {
1864 LPSTR lpstrFilter;
1865
1866 /* Get the current item of the filetype combo box */
1867 int iItem = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);
1868
1869 /* set the current filter index - indexed from 1 */
1870 fodInfos->ofnInfos->nFilterIndex = iItem + 1;
1871
1872 /* Set the current filter with the current selection */
1873 if(fodInfos->ShellInfos.lpstrCurrentFilter)
1874 MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
1875
1876 lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
1877 iItem);
1878 if((int)lpstrFilter != CB_ERR)
1879 {
1880 DWORD len;
1881 _strlwr(lpstrFilter); /* lowercase */
1882 len = MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1, NULL, 0 );
1883 fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
1884 MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1,
1885 fodInfos->ShellInfos.lpstrCurrentFilter, len );
1886 SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE);
1887 }
1888
1889 /* Refresh the actual view to display the included items*/
1890 IShellView_Refresh(fodInfos->Shell.FOIShellView);
1891 }
1892 }
1893 return FALSE;
1894}
1895/***********************************************************************
1896 * FILEDLG95_FILETYPE_SearchExt
1897 *
1898 * searches for a extension in the filetype box
1899 */
1900static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCSTR lpstrExt)
1901{
1902 int i, iCount = CBGetCount(hwnd);
1903
1904 TRACE("%s\n", lpstrExt);
1905
1906 if(iCount != CB_ERR)
1907 {
1908 for(i=0;i<iCount;i++)
1909 {
1910 if(!strcasecmp(lpstrExt,(LPSTR)CBGetItemDataPtr(hwnd,i)))
1911 return i;
1912 }
1913 }
1914 return -1;
1915}
1916
1917/***********************************************************************
1918 * FILEDLG95_FILETYPE_Clean
1919 *
1920 * Clean the memory used by the filetype combo box
1921 */
1922static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
1923{
1924 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
1925 int iPos;
1926 int iCount = CBGetCount(fodInfos->DlgInfos.hwndFileTypeCB);
1927
1928 TRACE("\n");
1929
1930 /* Delete each string of the combo and their associated data */
1931 if(iCount != CB_ERR)
1932 {
1933 for(iPos = iCount-1;iPos>=0;iPos--)
1934 {
1935 MemFree((LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos));
1936 CBDeleteString(fodInfos->DlgInfos.hwndFileTypeCB,iPos);
1937 }
1938 }
1939 /* Current filter */
1940 if(fodInfos->ShellInfos.lpstrCurrentFilter)
1941 MemFree(fodInfos->ShellInfos.lpstrCurrentFilter);
1942
1943}
1944
1945/***********************************************************************
1946 * FILEDLG95_LOOKIN_Init
1947 *
1948 * Initialisation of the look in combo box
1949 */
1950static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo)
1951{
1952 IShellFolder *psfRoot, *psfDrives;
1953 IEnumIDList *lpeRoot, *lpeDrives;
1954 LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
1955
1956 LookInInfos *liInfos = MemAlloc(sizeof(LookInInfos));
1957
1958 TRACE("\n");
1959
1960 liInfos->iMaxIndentation = 0;
1961
1962 SetPropA(hwndCombo, LookInInfosStr, (HANDLE) liInfos);
1963
1964 /* set item height for both text field and listbox */
1965 CBSetItemHeight(hwndCombo,-1,GetSystemMetrics(SM_CYSMICON));
1966 CBSetItemHeight(hwndCombo,0,GetSystemMetrics(SM_CYSMICON));
1967
1968 /* Initialise data of Desktop folder */
1969 SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidlTmp);
1970 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
1971 COMDLG32_SHFree(pidlTmp);
1972
1973 SHGetSpecialFolderLocation(0,CSIDL_DRIVES,&pidlDrives);
1974
1975 SHGetDesktopFolder(&psfRoot);
1976
1977 if (psfRoot)
1978 {
1979 /* enumerate the contents of the desktop */
1980 if(SUCCEEDED(IShellFolder_EnumObjects(psfRoot, hwndCombo, SHCONTF_FOLDERS, &lpeRoot)))
1981 {
1982 while (S_OK == IEnumIDList_Next(lpeRoot, 1, &pidlTmp, NULL))
1983 {
1984 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
1985
1986 /* special handling for CSIDL_DRIVES */
1987 if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives))
1988 {
1989 if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
1990 {
1991 /* enumerate the drives */
1992 if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives)))
1993 {
1994 while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
1995 {
1996 pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1);
1997 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
1998 COMDLG32_SHFree(pidlAbsTmp);
1999 COMDLG32_SHFree(pidlTmp1);
2000 }
2001 IEnumIDList_Release(lpeDrives);
2002 }
2003 IShellFolder_Release(psfDrives);
2004 }
2005 }
2006 COMDLG32_SHFree(pidlTmp);
2007 }
2008 IEnumIDList_Release(lpeRoot);
2009 }
2010 }
2011
2012 IShellFolder_Release(psfRoot);
2013 COMDLG32_SHFree(pidlDrives);
2014 return NOERROR;
2015}
2016
2017/***********************************************************************
2018 * FILEDLG95_LOOKIN_DrawItem
2019 *
2020 * WM_DRAWITEM message handler
2021 */
2022static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct)
2023{
2024 COLORREF crWin = GetSysColor(COLOR_WINDOW);
2025 COLORREF crHighLight = GetSysColor(COLOR_HIGHLIGHT);
2026 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
2027 RECT rectText;
2028 RECT rectIcon;
2029 SHFILEINFOA sfi;
2030 HIMAGELIST ilItemImage;
2031 int iIndentation;
2032 TEXTMETRICA tm;
2033 LPSFOLDER tmpFolder;
2034
2035
2036 LookInInfos *liInfos = (LookInInfos *)GetPropA(pDIStruct->hwndItem,LookInInfosStr);
2037
2038 TRACE("\n");
2039
2040 if(pDIStruct->itemID == -1)
2041 return 0;
2042
2043 if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(pDIStruct->hwndItem,
2044 pDIStruct->itemID)))
2045 return 0;
2046
2047
2048 if(pDIStruct->itemID == liInfos->uSelectedItem)
2049 {
2050 ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
2051 0,
2052 &sfi,
2053 sizeof (SHFILEINFOA),
2054 SHGFI_PIDL | SHGFI_SMALLICON |
2055 SHGFI_OPENICON | SHGFI_SYSICONINDEX |
2056 SHGFI_DISPLAYNAME );
2057 }
2058 else
2059 {
2060 ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
2061 0,
2062 &sfi,
2063 sizeof (SHFILEINFOA),
2064 SHGFI_PIDL | SHGFI_SMALLICON |
2065 SHGFI_SYSICONINDEX |
2066 SHGFI_DISPLAYNAME);
2067 }
2068
2069 /* Is this item selected ? */
2070 if(pDIStruct->itemState & ODS_SELECTED)
2071 {
2072 SetTextColor(pDIStruct->hDC,(0x00FFFFFF & ~(crText)));
2073 SetBkColor(pDIStruct->hDC,crHighLight);
2074 FillRect(pDIStruct->hDC,&pDIStruct->rcItem,(HBRUSH)crHighLight);
2075 }
2076 else
2077 {
2078 SetTextColor(pDIStruct->hDC,crText);
2079 SetBkColor(pDIStruct->hDC,crWin);
2080 FillRect(pDIStruct->hDC,&pDIStruct->rcItem,(HBRUSH)crWin);
2081 }
2082
2083 /* Do not indent item if drawing in the edit of the combo */
2084 if(pDIStruct->itemState & ODS_COMBOBOXEDIT)
2085 {
2086 iIndentation = 0;
2087 ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
2088 0,
2089 &sfi,
2090 sizeof (SHFILEINFOA),
2091 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON
2092 | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME );
2093
2094 }
2095 else
2096 {
2097 iIndentation = tmpFolder->m_iIndent;
2098 }
2099 /* Draw text and icon */
2100
2101 /* Initialise the icon display area */
2102 rectIcon.left = pDIStruct->rcItem.left + ICONWIDTH/2 * iIndentation;
2103 rectIcon.top = pDIStruct->rcItem.top;
2104 rectIcon.right = rectIcon.left + ICONWIDTH;
2105 rectIcon.bottom = pDIStruct->rcItem.bottom;
2106
2107 /* Initialise the text display area */
2108 GetTextMetricsA(pDIStruct->hDC, &tm);
2109 rectText.left = rectIcon.right;
2110 rectText.top =
2111 (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2;
2112 rectText.right = pDIStruct->rcItem.right + XTEXTOFFSET;
2113 rectText.bottom =
2114 (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + tm.tmHeight) / 2;
2115
2116 /* Draw the icon from the image list */
2117 ImageList_Draw(ilItemImage,
2118 sfi.iIcon,
2119 pDIStruct->hDC,
2120 rectIcon.left,
2121 rectIcon.top,
2122 ILD_TRANSPARENT );
2123
2124 /* Draw the associated text */
2125 if(sfi.szDisplayName)
2126 TextOutA(pDIStruct->hDC,rectText.left,rectText.top,sfi.szDisplayName,strlen(sfi.szDisplayName));
2127
2128
2129 return NOERROR;
2130}
2131
2132/***********************************************************************
2133 * FILEDLG95_LOOKIN_OnCommand
2134 *
2135 * LookIn combo box WM_COMMAND message handler
2136 * If the function succeeds, the return value is nonzero.
2137 */
2138static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode)
2139{
2140 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
2141
2142 TRACE("%p\n", fodInfos);
2143
2144 switch(wNotifyCode)
2145 {
2146 case CBN_SELENDOK:
2147 {
2148 LPSFOLDER tmpFolder;
2149 int iItem;
2150
2151 iItem = CBGetCurSel(fodInfos->DlgInfos.hwndLookInCB);
2152
2153 if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,
2154 iItem)))
2155 return FALSE;
2156
2157
2158 if(SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
2159 tmpFolder->pidlItem,
2160 SBSP_ABSOLUTE)))
2161 {
2162 return TRUE;
2163 }
2164 break;
2165 }
2166
2167 }
2168 return FALSE;
2169}
2170
2171/***********************************************************************
2172 * FILEDLG95_LOOKIN_AddItem
2173 *
2174 * Adds an absolute pidl item to the lookin combo box
2175 * returns the index of the inserted item
2176 */
2177static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId)
2178{
2179 LPITEMIDLIST pidlNext;
2180 SHFILEINFOA sfi;
2181 SFOLDER *tmpFolder;
2182 LookInInfos *liInfos;
2183
2184 TRACE("%08x\n", iInsertId);
2185
2186 if(!pidl)
2187 return -1;
2188
2189 if(!(liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr)))
2190 return -1;
2191
2192 tmpFolder = MemAlloc(sizeof(SFOLDER));
2193 tmpFolder->m_iIndent = 0;
2194
2195 /* Calculate the indentation of the item in the lookin*/
2196 pidlNext = pidl;
2197 while( (pidlNext=COMDLG32_PIDL_ILGetNext(pidlNext)) )
2198 {
2199 tmpFolder->m_iIndent++;
2200 }
2201
2202 tmpFolder->pidlItem = COMDLG32_PIDL_ILClone(pidl); /* FIXME: memory leak*/
2203
2204 if(tmpFolder->m_iIndent > liInfos->iMaxIndentation)
2205 liInfos->iMaxIndentation = tmpFolder->m_iIndent;
2206
2207 sfi.dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
2208 SHGetFileInfoA((LPSTR)pidl,
2209 0,
2210 &sfi,
2211 sizeof(sfi),
2212 SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX
2213 | SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED);
2214
2215 TRACE("-- Add %s attr=%08lx\n", sfi.szDisplayName, sfi.dwAttributes);
2216
2217 if((sfi.dwAttributes & SFGAO_FILESYSANCESTOR) || (sfi.dwAttributes & SFGAO_FILESYSTEM))
2218 {
2219 int iItemID;
2220
2221 TRACE("-- Add %s at %u\n", sfi.szDisplayName, tmpFolder->m_iIndent);
2222
2223 /* Add the item at the end of the list */
2224 if(iInsertId < 0)
2225 {
2226 iItemID = CBAddString(hwnd,sfi.szDisplayName);
2227 }
2228 /* Insert the item at the iInsertId position*/
2229 else
2230 {
2231 iItemID = CBInsertString(hwnd,sfi.szDisplayName,iInsertId);
2232 }
2233
2234 CBSetItemDataPtr(hwnd,iItemID,tmpFolder);
2235 return iItemID;
2236 }
2237
2238 MemFree( tmpFolder );
2239 return -1;
2240
2241}
2242
2243/***********************************************************************
2244 * FILEDLG95_LOOKIN_InsertItemAfterParent
2245 *
2246 * Insert an item below its parent
2247 */
2248static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl)
2249{
2250
2251 LPITEMIDLIST pidlParent = GetParentPidl(pidl);
2252 int iParentPos;
2253
2254 TRACE("\n");
2255
2256 iParentPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)pidlParent,SEARCH_PIDL);
2257
2258 if(iParentPos < 0)
2259 {
2260 iParentPos = FILEDLG95_LOOKIN_InsertItemAfterParent(hwnd,pidlParent);
2261 }
2262
2263 /* Free pidlParent memory */
2264 COMDLG32_SHFree((LPVOID)pidlParent);
2265
2266 return FILEDLG95_LOOKIN_AddItem(hwnd,pidl,iParentPos + 1);
2267}
2268
2269/***********************************************************************
2270 * FILEDLG95_LOOKIN_SelectItem
2271 *
2272 * Adds an absolute pidl item to the lookin combo box
2273 * returns the index of the inserted item
2274 */
2275int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl)
2276{
2277 int iItemPos;
2278 LookInInfos *liInfos;
2279
2280 TRACE("\n");
2281
2282 iItemPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)pidl,SEARCH_PIDL);
2283
2284 liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr);
2285
2286 if(iItemPos < 0)
2287 {
2288 while(FILEDLG95_LOOKIN_RemoveMostExpandedItem(hwnd) > -1);
2289 iItemPos = FILEDLG95_LOOKIN_InsertItemAfterParent(hwnd,pidl);
2290 }
2291
2292 else
2293 {
2294 SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
2295 while(liInfos->iMaxIndentation > tmpFolder->m_iIndent)
2296 {
2297 int iRemovedItem;
2298
2299 if(-1 == (iRemovedItem = FILEDLG95_LOOKIN_RemoveMostExpandedItem(hwnd)))
2300 break;
2301 if(iRemovedItem < iItemPos)
2302 iItemPos--;
2303 }
2304 }
2305
2306 CBSetCurSel(hwnd,iItemPos);
2307 liInfos->uSelectedItem = iItemPos;
2308
2309 return 0;
2310
2311}
2312
2313/***********************************************************************
2314 * FILEDLG95_LOOKIN_RemoveMostExpandedItem
2315 *
2316 * Remove the item with an expansion level over iExpansionLevel
2317 */
2318static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd)
2319{
2320 int iItemPos;
2321
2322 LookInInfos *liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr);
2323
2324 TRACE("\n");
2325
2326 if(liInfos->iMaxIndentation <= 2)
2327 return -1;
2328
2329 if((iItemPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)liInfos->iMaxIndentation,SEARCH_EXP)) >=0)
2330 {
2331 SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
2332 COMDLG32_SHFree(tmpFolder->pidlItem);
2333 MemFree(tmpFolder);
2334 CBDeleteString(hwnd,iItemPos);
2335 liInfos->iMaxIndentation--;
2336
2337 return iItemPos;
2338 }
2339
2340 return -1;
2341}
2342
2343/***********************************************************************
2344 * FILEDLG95_LOOKIN_SearchItem
2345 *
2346 * Search for pidl in the lookin combo box
2347 * returns the index of the found item
2348 */
2349static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMethod)
2350{
2351 int i = 0;
2352 int iCount = CBGetCount(hwnd);
2353
2354 TRACE("0x%08x 0x%x\n",searchArg, iSearchMethod);
2355
2356 if (iCount != CB_ERR)
2357 {
2358 for(;i<iCount;i++)
2359 {
2360 LPSFOLDER tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,i);
2361
2362 if(iSearchMethod == SEARCH_PIDL && COMDLG32_PIDL_ILIsEqual((LPITEMIDLIST)searchArg,tmpFolder->pidlItem))
2363 return i;
2364 if(iSearchMethod == SEARCH_EXP && tmpFolder->m_iIndent == (int)searchArg)
2365 return i;
2366 }
2367 }
2368
2369 return -1;
2370}
2371
2372/***********************************************************************
2373 * FILEDLG95_LOOKIN_Clean
2374 *
2375 * Clean the memory used by the lookin combo box
2376 */
2377static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
2378{
2379 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
2380 int iPos;
2381 int iCount = CBGetCount(fodInfos->DlgInfos.hwndLookInCB);
2382
2383 TRACE("\n");
2384
2385 /* Delete each string of the combo and their associated data */
2386 if (iCount != CB_ERR)
2387 {
2388 for(iPos = iCount-1;iPos>=0;iPos--)
2389 {
2390 SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos);
2391 COMDLG32_SHFree(tmpFolder->pidlItem);
2392 MemFree(tmpFolder);
2393 CBDeleteString(fodInfos->DlgInfos.hwndLookInCB,iPos);
2394 }
2395 }
2396
2397 /* LookInInfos structure */
2398 RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
2399
2400}
2401/***********************************************************************
2402 * FILEDLG95_FILENAME_FillFromSelection
2403 *
2404 * fills the edit box from the cached DataObject
2405 */
2406void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
2407{
2408 FileOpenDlgInfos *fodInfos;
2409 LPITEMIDLIST pidl;
2410 UINT nFiles = 0, nFileToOpen, nFileSelected, nLength = 0;
2411 char lpstrTemp[MAX_PATH];
2412 LPSTR lpstrAllFile = NULL, lpstrCurrFile = NULL;
2413
2414 TRACE("\n");
2415 fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
2416
2417 /* Count how many files we have */
2418 nFileSelected = GetNumSelected( fodInfos->Shell.FOIDataObject );
2419
2420 /* calculate the string length, count files */
2421 if (nFileSelected >= 1)
2422 {
2423 nLength += 3; /* first and last quotes, trailing \0 */
2424 for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
2425 {
2426 pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 );
2427
2428 if (pidl)
2429 {
2430 /* get the total length of the selected file names*/
2431 lpstrTemp[0] = '\0';
2432 GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER, lpstrTemp );
2433
2434 if ( ! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl) ) /* Ignore folders */
2435 {
2436 nLength += strlen( lpstrTemp ) + 3;
2437 nFiles++;
2438 }
2439 COMDLG32_SHFree( pidl );
2440 }
2441 }
2442 }
2443
2444 /* allocate the buffer */
2445 if (nFiles <= 1) nLength = MAX_PATH;
2446 lpstrAllFile = (LPSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength);
2447 lpstrAllFile[0] = '\0';
2448
2449 /* Generate the string for the edit control */
2450 if(nFiles >= 1)
2451 {
2452 lpstrCurrFile = lpstrAllFile;
2453 for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
2454 {
2455 pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 );
2456
2457 if (pidl)
2458 {
2459 /* get the file name */
2460 lpstrTemp[0] = '\0';
2461 GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER, lpstrTemp );
2462
2463 if (! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl)) /* Ignore folders */
2464 {
2465 if ( nFiles > 1)
2466 {
2467 *lpstrCurrFile++ = '\"';
2468 strcpy( lpstrCurrFile, lpstrTemp );
2469 lpstrCurrFile += strlen( lpstrTemp );
2470 strcpy( lpstrCurrFile, "\" " );
2471 lpstrCurrFile += 2;
2472 }
2473 else
2474 {
2475 strcpy( lpstrAllFile, lpstrTemp );
2476 }
2477 }
2478 COMDLG32_SHFree( (LPVOID) pidl );
2479 }
2480 }
2481 }
2482#ifdef __WIN32OS2__
2483 //Selecting a directory previously erased the last selected file
2484 if(nFiles) {
2485 SetWindowTextA( fodInfos->DlgInfos.hwndFileName, lpstrAllFile );
2486 }
2487#else
2488 SetWindowTextA( fodInfos->DlgInfos.hwndFileName, lpstrAllFile );
2489#endif
2490 HeapFree(GetProcessHeap(),0, lpstrAllFile );
2491}
2492
2493
2494/* copied from shell32 to avoid linking to it */
2495static HRESULT COMDLG32_StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
2496{
2497 switch (src->uType)
2498 {
2499 case STRRET_WSTR:
2500 WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
2501 COMDLG32_SHFree(src->u.pOleStr);
2502 break;
2503
2504 case STRRET_CSTRA:
2505 lstrcpynA((LPSTR)dest, src->u.cStr, len);
2506 break;
2507
2508 case STRRET_OFFSETA:
2509 lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
2510 break;
2511
2512 default:
2513 FIXME("unknown type!\n");
2514 if (len)
2515 {
2516 *(LPSTR)dest = '\0';
2517 }
2518 return(FALSE);
2519 }
2520 return S_OK;
2521}
2522
2523/***********************************************************************
2524 * FILEDLG95_FILENAME_GetFileNames
2525 *
2526 * copies the filenames to a 0-delimited string list (A\0B\0C\0\0)
2527 */
2528int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPSTR * lpstrFileList, UINT * sizeUsed)
2529{
2530 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
2531 UINT nStrCharCount = 0; /* index in src buffer */
2532 UINT nFileIndex = 0; /* index in dest buffer */
2533 UINT nFileCount = 0; /* number of files */
2534 UINT nStrLen = 0; /* length of string in edit control */
2535 LPSTR lpstrEdit; /* buffer for string from edit control */
2536
2537 TRACE("\n");
2538
2539 /* get the filenames from the edit control */
2540 nStrLen = SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0);
2541 lpstrEdit = MemAlloc(nStrLen+1);
2542 GetDlgItemTextA(hwnd, IDC_FILENAME, lpstrEdit, nStrLen+1);
2543
2544 TRACE("nStrLen=%u str=%s\n", nStrLen, lpstrEdit);
2545
2546 /* we might get single filename without any '"',
2547 * so we need nStrLen + terminating \0 + end-of-list \0 */
2548 *lpstrFileList = MemAlloc(nStrLen+2);
2549 *sizeUsed = 0;
2550
2551 /* build 0-delimited file list from filenames */
2552 while ( nStrCharCount <= nStrLen )
2553 {
2554 if ( lpstrEdit[nStrCharCount]=='"' )
2555 {
2556 nStrCharCount++;
2557 while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen))
2558 {
2559 (*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount];
2560 (*sizeUsed)++;
2561 nStrCharCount++;
2562 }
2563 (*lpstrFileList)[nFileIndex++] = '\0';
2564 (*sizeUsed)++;
2565 nFileCount++;
2566 }
2567 nStrCharCount++;
2568 }
2569
2570 /* single, unquoted string */
2571 if ((nStrLen > 0) && (*sizeUsed == 0) )
2572 {
2573 strcpy(*lpstrFileList, lpstrEdit);
2574 nFileIndex = strlen(lpstrEdit) + 1;
2575 (*sizeUsed) = nFileIndex;
2576 nFileCount = 1;
2577 }
2578
2579 /* trailing \0 */
2580 (*lpstrFileList)[nFileIndex] = '\0';
2581 (*sizeUsed)++;
2582
2583 MemFree(lpstrEdit);
2584 return nFileCount;
2585}
2586
2587#define SETDefFormatEtc(fe,cf,med) \
2588{ \
2589 (fe).cfFormat = cf;\
2590 (fe).dwAspect = DVASPECT_CONTENT; \
2591 (fe).ptd =NULL;\
2592 (fe).tymed = med;\
2593 (fe).lindex = -1;\
2594};
2595
2596/*
2597 * DATAOBJECT Helper functions
2598 */
2599
2600/***********************************************************************
2601 * COMCTL32_ReleaseStgMedium
2602 *
2603 * like ReleaseStgMedium from ole32
2604 */
2605static void COMCTL32_ReleaseStgMedium (STGMEDIUM medium)
2606{
2607 if(medium.pUnkForRelease)
2608 {
2609 IUnknown_Release(medium.pUnkForRelease);
2610 }
2611 else
2612 {
2613 GlobalUnlock(medium.u.hGlobal);
2614 GlobalFree(medium.u.hGlobal);
2615 }
2616}
2617
2618/***********************************************************************
2619 * GetPidlFromDataObject
2620 *
2621 * Return pidl(s) by number from the cached DataObject
2622 *
2623 * nPidlIndex=0 gets the fully qualified root path
2624 */
2625LPITEMIDLIST GetPidlFromDataObject ( IDataObject *doSelected, UINT nPidlIndex)
2626{
2627
2628 STGMEDIUM medium;
2629 FORMATETC formatetc;
2630 LPITEMIDLIST pidl = NULL;
2631
2632 TRACE("sv=%p index=%u\n", doSelected, nPidlIndex);
2633
2634 /* Set the FORMATETC structure*/
2635 SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
2636
2637 /* Get the pidls from IDataObject */
2638 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
2639 {
2640 LPIDA cida = GlobalLock(medium.u.hGlobal);
2641 if(nPidlIndex <= cida->cidl)
2642 {
2643 pidl = COMDLG32_PIDL_ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[nPidlIndex]]));
2644 }
2645 COMCTL32_ReleaseStgMedium(medium);
2646 }
2647 return pidl;
2648}
2649
2650/***********************************************************************
2651 * GetNumSelected
2652 *
2653 * Return the number of selected items in the DataObject.
2654 *
2655*/
2656UINT GetNumSelected( IDataObject *doSelected )
2657{
2658 UINT retVal = 0;
2659 STGMEDIUM medium;
2660 FORMATETC formatetc;
2661
2662 TRACE("sv=%p\n", doSelected);
2663
2664 if (!doSelected) return 0;
2665
2666 /* Set the FORMATETC structure*/
2667 SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
2668
2669 /* Get the pidls from IDataObject */
2670 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
2671 {
2672 LPIDA cida = GlobalLock(medium.u.hGlobal);
2673 retVal = cida->cidl;
2674 COMCTL32_ReleaseStgMedium(medium);
2675 return retVal;
2676 }
2677 return 0;
2678}
2679
2680/*
2681 * TOOLS
2682 */
2683
2684/***********************************************************************
2685 * GetName
2686 *
2687 * Get the pidl's display name (relative to folder) and
2688 * put it in lpstrFileName.
2689 *
2690 * Return NOERROR on success,
2691 * E_FAIL otherwise
2692 */
2693
2694HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName)
2695{
2696 STRRET str;
2697 HRESULT hRes;
2698
2699 TRACE("sf=%p pidl=%p\n", lpsf, pidl);
2700
2701 if(!lpsf)
2702 {
2703 HRESULT hRes;
2704 SHGetDesktopFolder(&lpsf);
2705 hRes = GetName(lpsf,pidl,dwFlags,lpstrFileName);
2706 IShellFolder_Release(lpsf);
2707 return hRes;
2708 }
2709
2710 /* Get the display name of the pidl relative to the folder */
2711 if (SUCCEEDED(hRes = IShellFolder_GetDisplayNameOf(lpsf, pidl, dwFlags, &str)))
2712 {
2713 return COMDLG32_StrRetToStrNA(lpstrFileName, MAX_PATH, &str, pidl);
2714 }
2715 return E_FAIL;
2716}
2717
2718/***********************************************************************
2719 * GetShellFolderFromPidl
2720 *
2721 * pidlRel is the item pidl relative
2722 * Return the IShellFolder of the absolute pidl
2723 */
2724IShellFolder *GetShellFolderFromPidl(LPITEMIDLIST pidlAbs)
2725{
2726 IShellFolder *psf = NULL,*psfParent;
2727
2728 TRACE("%p\n", pidlAbs);
2729
2730 if(SUCCEEDED(SHGetDesktopFolder(&psfParent)))
2731 {
2732 psf = psfParent;
2733 if(pidlAbs && pidlAbs->mkid.cb)
2734 {
2735 if(SUCCEEDED(IShellFolder_BindToObject(psfParent, pidlAbs, NULL, &IID_IShellFolder, (LPVOID*)&psf)))
2736 {
2737 IShellFolder_Release(psfParent);
2738 return psf;
2739 }
2740 }
2741 /* return the desktop */
2742 return psfParent;
2743 }
2744 return NULL;
2745}
2746
2747/***********************************************************************
2748 * GetParentPidl
2749 *
2750 * Return the LPITEMIDLIST to the parent of the pidl in the list
2751 */
2752LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl)
2753{
2754 LPITEMIDLIST pidlParent;
2755
2756 TRACE("%p\n", pidl);
2757
2758 pidlParent = COMDLG32_PIDL_ILClone(pidl);
2759 COMDLG32_PIDL_ILRemoveLastID(pidlParent);
2760
2761 return pidlParent;
2762}
2763
2764/***********************************************************************
2765 * GetPidlFromName
2766 *
2767 * returns the pidl of the file name relative to folder
2768 * NULL if an error occurred
2769 */
2770LPITEMIDLIST GetPidlFromName(IShellFolder *lpsf,LPCSTR lpcstrFileName)
2771{
2772 LPITEMIDLIST pidl;
2773 ULONG ulEaten;
2774 WCHAR lpwstrDirName[MAX_PATH];
2775
2776 TRACE("sf=%p file=%s\n", lpsf, lpcstrFileName);
2777
2778 if(!lpcstrFileName) return NULL;
2779 if(!*lpcstrFileName) return NULL;
2780
2781 MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpcstrFileName,-1,(LPWSTR)lpwstrDirName,MAX_PATH);
2782
2783 if(!lpsf)
2784 {
2785 SHGetDesktopFolder(&lpsf);
2786 pidl = GetPidlFromName(lpsf, lpcstrFileName);
2787 IShellFolder_Release(lpsf);
2788 }
2789 else
2790 {
2791 IShellFolder_ParseDisplayName(lpsf, 0, NULL, (LPWSTR)lpwstrDirName, &ulEaten, &pidl, NULL);
2792 }
2793 return pidl;
2794}
2795
2796/*
2797*/
2798BOOL IsPidlFolder (LPSHELLFOLDER psf, LPITEMIDLIST pidl)
2799{
2800 ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
2801 HRESULT ret;
2802
2803 TRACE("%p, %p\n", psf, pidl);
2804
2805 ret = IShellFolder_GetAttributesOf( psf, 1, &pidl, &uAttr );
2806
2807 TRACE("-- 0x%08lx 0x%08lx\n", uAttr, ret);
2808 /* see documentation shell 4.1*/
2809 return uAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER);
2810}
2811
2812/***********************************************************************
2813 * BrowseSelectedFolder
2814 */
2815static BOOL BrowseSelectedFolder(HWND hwnd)
2816{
2817 BOOL bBrowseSelFolder = FALSE;
2818 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
2819
2820 TRACE("\n");
2821
2822 if (GetNumSelected(fodInfos->Shell.FOIDataObject) == 1)
2823 {
2824 LPITEMIDLIST pidlSelection;
2825
2826 /* get the file selected */
2827 pidlSelection = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, 1);
2828 if (IsPidlFolder (fodInfos->Shell.FOIShellFolder, pidlSelection))
2829 {
2830 if ( FAILED( IShellBrowser_BrowseObject( fodInfos->Shell.FOIShellBrowser,
2831 pidlSelection, SBSP_RELATIVE ) ) )
2832 {
2833 MessageBoxA( hwnd, "Path does not exist", fodInfos->ofnInfos->lpstrTitle,
2834 MB_OK | MB_ICONEXCLAMATION );
2835 }
2836
2837 bBrowseSelFolder = TRUE;
2838 }
2839 COMDLG32_SHFree( pidlSelection );
2840 }
2841
2842 return bBrowseSelFolder;
2843}
2844
2845/*
2846 * Memory allocation methods */
2847static void *MemAlloc(UINT size)
2848{
2849 return HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,size);
2850}
2851
2852static void MemFree(void *mem)
2853{
2854 if(mem)
2855 {
2856 HeapFree(GetProcessHeap(),0,mem);
2857 }
2858}
2859
Note: See TracBrowser for help on using the repository browser.