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

Last change on this file since 6688 was 6645, checked in by bird, 24 years ago

Added $Id:$ keyword.

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