1 | /* $Id: filedlgbrowser.cpp,v 1.4 1999-11-28 12:32:28 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Implementation of IShellBrowser for the File Open common dialog
|
---|
4 | *
|
---|
5 | *
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include <stdio.h>
|
---|
9 | #ifdef __WIN32OS2__
|
---|
10 | // ><DJR 17.05.99 Force to use C-interfaces for now to prevent CALLBACK definition compiler error
|
---|
11 | #define CINTERFACE 1
|
---|
12 | #include <os2win.h>
|
---|
13 | #include "unknwn.h"
|
---|
14 | #include "filedlgbrowser.h"
|
---|
15 | #else
|
---|
16 | #include "unknwn.h"
|
---|
17 | #include "filedlgbrowser.h"
|
---|
18 | #include "winuser.h"
|
---|
19 | #endif
|
---|
20 | #include "heap.h"
|
---|
21 | #include "wine/obj_dataobject.h"
|
---|
22 | #include "debugtools.h"
|
---|
23 | #include "cdlg.h"
|
---|
24 | #include "wine/undocshell.h"
|
---|
25 |
|
---|
26 | DEFAULT_DEBUG_CHANNEL(commdlg)
|
---|
27 |
|
---|
28 | #define SETDefFormatEtc(fe,cf,med) \
|
---|
29 | { \
|
---|
30 | (fe).cfFormat = cf;\
|
---|
31 | (fe).dwAspect = DVASPECT_CONTENT; \
|
---|
32 | (fe).ptd =NULL;\
|
---|
33 | (fe).tymed = med;\
|
---|
34 | (fe).lindex = -1;\
|
---|
35 | };
|
---|
36 |
|
---|
37 |
|
---|
38 | /**************************************************************************
|
---|
39 | * Structure
|
---|
40 | */
|
---|
41 | static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl =
|
---|
42 | {
|
---|
43 | /* IUnknown */
|
---|
44 | IShellBrowserImpl_QueryInterface,
|
---|
45 | IShellBrowserImpl_AddRef,
|
---|
46 | IShellBrowserImpl_Release,
|
---|
47 | /* IOleWindow */
|
---|
48 | IShellBrowserImpl_GetWindow,
|
---|
49 | IShellBrowserImpl_ContextSensitiveHelp,
|
---|
50 | /* IShellBrowser */
|
---|
51 | IShellBrowserImpl_InsertMenusSB,
|
---|
52 | IShellBrowserImpl_SetMenuSB,
|
---|
53 | IShellBrowserImpl_RemoveMenusSB,
|
---|
54 | IShellBrowserImpl_SetStatusTextSB,
|
---|
55 | IShellBrowserImpl_EnableModelessSB,
|
---|
56 | IShellBrowserImpl_TranslateAcceleratorSB,
|
---|
57 | IShellBrowserImpl_BrowseObject,
|
---|
58 | IShellBrowserImpl_GetViewStateStream,
|
---|
59 | IShellBrowserImpl_GetControlWindow,
|
---|
60 | IShellBrowserImpl_SendControlMsg,
|
---|
61 | IShellBrowserImpl_QueryActiveShellView,
|
---|
62 | IShellBrowserImpl_OnViewWindowActive,
|
---|
63 | IShellBrowserImpl_SetToolbarItems
|
---|
64 | };
|
---|
65 |
|
---|
66 | static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl =
|
---|
67 | {
|
---|
68 | /* IUnknown */
|
---|
69 | IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
|
---|
70 | IShellBrowserImpl_ICommDlgBrowser_AddRef,
|
---|
71 | IShellBrowserImpl_ICommDlgBrowser_Release,
|
---|
72 | /* ICommDlgBrowser */
|
---|
73 | IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
|
---|
74 | IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
|
---|
75 | IShellBrowserImpl_ICommDlgBrowser_IncludeObject
|
---|
76 | };
|
---|
77 |
|
---|
78 |
|
---|
79 | /**************************************************************************
|
---|
80 | * Local Prototypes
|
---|
81 | */
|
---|
82 |
|
---|
83 | HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
|
---|
84 | #if 0
|
---|
85 | LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
|
---|
86 | #endif
|
---|
87 |
|
---|
88 | /**************************************************************************
|
---|
89 | * External Prototypes
|
---|
90 | */
|
---|
91 | extern const char *FileOpenDlgInfosStr;
|
---|
92 |
|
---|
93 | extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
|
---|
94 | extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
|
---|
95 | extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
|
---|
96 | extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
|
---|
97 | extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
|
---|
98 |
|
---|
99 | extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
|
---|
100 | LPITEMIDLIST pidlCurrentFolder,
|
---|
101 | LPSTR lpstrMask);
|
---|
102 |
|
---|
103 | extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
|
---|
104 | extern BOOL FILEDLG95_OnOpen(HWND hwnd);
|
---|
105 | extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
|
---|
106 |
|
---|
107 |
|
---|
108 | /**************************************************************************
|
---|
109 | * IShellBrowserImpl_Construct
|
---|
110 | */
|
---|
111 | IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
|
---|
112 | {
|
---|
113 | IShellBrowserImpl *sb;
|
---|
114 | FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
|
---|
115 |
|
---|
116 | sb=(IShellBrowserImpl*)SHAlloc(sizeof(IShellBrowserImpl));
|
---|
117 |
|
---|
118 | /* Initialisation of the member variables */
|
---|
119 | sb->ref=1;
|
---|
120 | sb->hwndOwner = hwndOwner;
|
---|
121 |
|
---|
122 | /* Initialisation of the vTables */
|
---|
123 | sb->lpVtbl = &IShellBrowserImpl_Vtbl;
|
---|
124 | sb->lpVtbl2 = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
|
---|
125 |
|
---|
126 | COMDLG32_SHGetSpecialFolderLocation(hwndOwner,
|
---|
127 | CSIDL_DESKTOP,
|
---|
128 | &fodInfos->ShellInfos.pidlAbsCurrent);
|
---|
129 |
|
---|
130 | TRACE("%p\n", sb);
|
---|
131 |
|
---|
132 | return (IShellBrowser *) sb;
|
---|
133 | }
|
---|
134 |
|
---|
135 | /**************************************************************************
|
---|
136 | *
|
---|
137 | *
|
---|
138 | * The INTERFACE of the IShellBrowser object
|
---|
139 | *
|
---|
140 | */
|
---|
141 |
|
---|
142 | /*
|
---|
143 | * IUnknown
|
---|
144 | */
|
---|
145 |
|
---|
146 | /***************************************************************************
|
---|
147 | * IShellBrowserImpl_QueryInterface
|
---|
148 | */
|
---|
149 | HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
|
---|
150 | REFIID riid,
|
---|
151 | LPVOID *ppvObj)
|
---|
152 | {
|
---|
153 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
154 |
|
---|
155 | TRACE("(%p)\n", This);
|
---|
156 |
|
---|
157 | *ppvObj = NULL;
|
---|
158 |
|
---|
159 | if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
|
---|
160 | { *ppvObj = This;
|
---|
161 | }
|
---|
162 | else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
|
---|
163 | { *ppvObj = (IOleWindow*)This;
|
---|
164 | }
|
---|
165 |
|
---|
166 | else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
|
---|
167 | { *ppvObj = (IShellBrowser*)This;
|
---|
168 | }
|
---|
169 |
|
---|
170 | else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
|
---|
171 | { *ppvObj = (ICommDlgBrowser*) &(This->lpVtbl2);
|
---|
172 | }
|
---|
173 |
|
---|
174 | if(*ppvObj)
|
---|
175 | { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
|
---|
176 | return S_OK;
|
---|
177 | }
|
---|
178 | return E_NOINTERFACE;
|
---|
179 | }
|
---|
180 |
|
---|
181 | /**************************************************************************
|
---|
182 | * IShellBrowser::AddRef
|
---|
183 | */
|
---|
184 | ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
|
---|
185 | {
|
---|
186 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
187 |
|
---|
188 | TRACE("(%p)\n", This);
|
---|
189 |
|
---|
190 | return ++(This->ref);
|
---|
191 | }
|
---|
192 |
|
---|
193 | /**************************************************************************
|
---|
194 | * IShellBrowserImpl_Release
|
---|
195 | */
|
---|
196 | ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
|
---|
197 | {
|
---|
198 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
199 |
|
---|
200 | TRACE("(%p)\n", This);
|
---|
201 |
|
---|
202 | if (!--(This->ref))
|
---|
203 | {
|
---|
204 | COMDLG32_SHFree(This);
|
---|
205 | return 0;
|
---|
206 | }
|
---|
207 | return This->ref;
|
---|
208 | }
|
---|
209 |
|
---|
210 | /*
|
---|
211 | * IOleWindow
|
---|
212 | */
|
---|
213 |
|
---|
214 | /**************************************************************************
|
---|
215 | * IShellBrowserImpl_GetWindow (IOleWindow)
|
---|
216 | *
|
---|
217 | * Inherited from IOleWindow::GetWindow
|
---|
218 | *
|
---|
219 | * See Windows documentation for more details
|
---|
220 | *
|
---|
221 | * Note : We will never be window less in the File Open dialog
|
---|
222 | *
|
---|
223 | */
|
---|
224 | HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
|
---|
225 | HWND * phwnd)
|
---|
226 | {
|
---|
227 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
228 |
|
---|
229 | TRACE("(%p)\n", This);
|
---|
230 |
|
---|
231 | if(!This->hwndOwner)
|
---|
232 | return E_FAIL;
|
---|
233 |
|
---|
234 | *phwnd = This->hwndOwner;
|
---|
235 |
|
---|
236 | return (*phwnd) ? S_OK : E_UNEXPECTED;
|
---|
237 |
|
---|
238 | }
|
---|
239 |
|
---|
240 | /**************************************************************************
|
---|
241 | * IShellBrowserImpl_ContextSensitiveHelp
|
---|
242 | */
|
---|
243 | HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
|
---|
244 | BOOL fEnterMode)
|
---|
245 | {
|
---|
246 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
247 |
|
---|
248 | TRACE("(%p)\n", This);
|
---|
249 |
|
---|
250 | /* Feature not implemented */
|
---|
251 | return E_NOTIMPL;
|
---|
252 | }
|
---|
253 |
|
---|
254 | /*
|
---|
255 | * IShellBrowser
|
---|
256 | */
|
---|
257 |
|
---|
258 | /**************************************************************************
|
---|
259 | * IShellBrowserImpl_BrowseObject
|
---|
260 | *
|
---|
261 | * See Windows documentation on IShellBrowser::BrowseObject for more details
|
---|
262 | *
|
---|
263 | * This function will override user specified flags and will always
|
---|
264 | * use SBSP_DEFBROWSER and SBSP_DEFMODE.
|
---|
265 | */
|
---|
266 | HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
|
---|
267 | LPCITEMIDLIST pidl,
|
---|
268 | UINT wFlags)
|
---|
269 | {
|
---|
270 | HRESULT hRes;
|
---|
271 | IShellFolder *psfTmp;
|
---|
272 | IShellView *psvTmp;
|
---|
273 | FileOpenDlgInfos *fodInfos;
|
---|
274 | LPITEMIDLIST pidlTmp;
|
---|
275 |
|
---|
276 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
277 |
|
---|
278 | TRACE("(%p)\n", This);
|
---|
279 |
|
---|
280 | fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
|
---|
281 |
|
---|
282 | /* Format the pidl according to its parameter's category */
|
---|
283 | if(wFlags & SBSP_RELATIVE)
|
---|
284 | {
|
---|
285 |
|
---|
286 | /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
|
---|
287 | hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
|
---|
288 | pidl,
|
---|
289 | NULL,
|
---|
290 | &IID_IShellFolder,
|
---|
291 | (LPVOID *)&psfTmp);
|
---|
292 | if(FAILED(hRes))
|
---|
293 | {
|
---|
294 | return hRes;
|
---|
295 | }
|
---|
296 | /* create an absolute pidl */
|
---|
297 | pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
|
---|
298 | (LPITEMIDLIST)pidl);
|
---|
299 |
|
---|
300 | }
|
---|
301 | else if(wFlags & SBSP_PARENT)
|
---|
302 | {
|
---|
303 | /* Browse the parent folder (ignores the pidl) */
|
---|
304 |
|
---|
305 | pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
|
---|
306 | psfTmp = GetShellFolderFromPidl(pidlTmp);
|
---|
307 |
|
---|
308 | }
|
---|
309 | else
|
---|
310 | {
|
---|
311 | /* An absolute pidl (relative from the desktop) */
|
---|
312 | pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
|
---|
313 | psfTmp = GetShellFolderFromPidl(pidlTmp);
|
---|
314 | }
|
---|
315 |
|
---|
316 |
|
---|
317 | /* Retrieve the IShellFolder interface of the pidl specified folder */
|
---|
318 | if(!psfTmp)
|
---|
319 | return E_FAIL;
|
---|
320 |
|
---|
321 | /* If the pidl to browse to is equal to the actual pidl ...
|
---|
322 | do nothing and pretend you did it*/
|
---|
323 | if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
|
---|
324 | {
|
---|
325 | IShellFolder_Release(psfTmp);
|
---|
326 | COMDLG32_SHFree(pidlTmp);
|
---|
327 | return NOERROR;
|
---|
328 | }
|
---|
329 |
|
---|
330 | /* Release the current fodInfos->Shell.FOIShellFolder and update its value */
|
---|
331 | IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
|
---|
332 | fodInfos->Shell.FOIShellFolder = psfTmp;
|
---|
333 |
|
---|
334 | /* Create the associated view */
|
---|
335 | if(SUCCEEDED(hRes = IShellFolder_CreateViewObject(psfTmp,
|
---|
336 | fodInfos->ShellInfos.hwndOwner,
|
---|
337 | &IID_IShellView,
|
---|
338 | (LPVOID *)&psvTmp)))
|
---|
339 | {
|
---|
340 | HWND hwndView;
|
---|
341 | /* Get the foldersettings from the old view */
|
---|
342 | if(fodInfos->Shell.FOIShellView)
|
---|
343 | {
|
---|
344 | IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView,
|
---|
345 | &fodInfos->ShellInfos.folderSettings);
|
---|
346 | }
|
---|
347 |
|
---|
348 | /* Create the window */
|
---|
349 | if(SUCCEEDED(hRes = IShellView_CreateViewWindow(psvTmp,
|
---|
350 | NULL,
|
---|
351 | &fodInfos->ShellInfos.folderSettings,
|
---|
352 | fodInfos->Shell.FOIShellBrowser,
|
---|
353 | &fodInfos->ShellInfos.rectView,
|
---|
354 | &hwndView)))
|
---|
355 | {
|
---|
356 | /* Fit the created view in the appropriate RECT */
|
---|
357 | MoveWindow(hwndView,
|
---|
358 | fodInfos->ShellInfos.rectView.left,
|
---|
359 | fodInfos->ShellInfos.rectView.top,
|
---|
360 | fodInfos->ShellInfos.rectView.right-fodInfos->ShellInfos.rectView.left,
|
---|
361 | fodInfos->ShellInfos.rectView.bottom-fodInfos->ShellInfos.rectView.top,
|
---|
362 | FALSE);
|
---|
363 |
|
---|
364 | /* Select the new folder in the Look In combo box of the Open file dialog */
|
---|
365 |
|
---|
366 | FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,pidlTmp);
|
---|
367 |
|
---|
368 | /* Release old pidlAbsCurrent memory and update its value */
|
---|
369 | COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
|
---|
370 | fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
|
---|
371 |
|
---|
372 | /* Release the current fodInfos->Shell.FOIShellView and update its value */
|
---|
373 | if(fodInfos->Shell.FOIShellView)
|
---|
374 | {
|
---|
375 | IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
|
---|
376 | IShellView_Release(fodInfos->Shell.FOIShellView);
|
---|
377 | }
|
---|
378 | #if 0
|
---|
379 | ShowWindow(fodInfos->ShellInfos.hwndView,SW_HIDE);
|
---|
380 | #endif
|
---|
381 | fodInfos->Shell.FOIShellView = psvTmp;
|
---|
382 |
|
---|
383 | fodInfos->ShellInfos.hwndView = hwndView;
|
---|
384 |
|
---|
385 | return NOERROR;
|
---|
386 | }
|
---|
387 | }
|
---|
388 |
|
---|
389 | FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
|
---|
390 | return hRes;
|
---|
391 | }
|
---|
392 |
|
---|
393 | /**************************************************************************
|
---|
394 | * IShellBrowserImpl_EnableModelessSB
|
---|
395 | */
|
---|
396 | HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
|
---|
397 | BOOL fEnable)
|
---|
398 |
|
---|
399 | {
|
---|
400 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
401 |
|
---|
402 | TRACE("(%p)\n", This);
|
---|
403 |
|
---|
404 | /* Feature not implemented */
|
---|
405 | return E_NOTIMPL;
|
---|
406 | }
|
---|
407 |
|
---|
408 | /**************************************************************************
|
---|
409 | * IShellBrowserImpl_GetControlWindow
|
---|
410 | */
|
---|
411 | HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
|
---|
412 | UINT id,
|
---|
413 | HWND *lphwnd)
|
---|
414 |
|
---|
415 | {
|
---|
416 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
417 |
|
---|
418 | TRACE("(%p)\n", This);
|
---|
419 |
|
---|
420 | /* Feature not implemented */
|
---|
421 | return E_NOTIMPL;
|
---|
422 | }
|
---|
423 | /**************************************************************************
|
---|
424 | * IShellBrowserImpl_GetViewStateStream
|
---|
425 | */
|
---|
426 | HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
|
---|
427 | DWORD grfMode,
|
---|
428 | LPSTREAM *ppStrm)
|
---|
429 |
|
---|
430 | {
|
---|
431 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
432 |
|
---|
433 | TRACE("(%p)\n", This);
|
---|
434 |
|
---|
435 | /* Feature not implemented */
|
---|
436 | return E_NOTIMPL;
|
---|
437 | }
|
---|
438 | /**************************************************************************
|
---|
439 | * IShellBrowserImpl_InsertMenusSB
|
---|
440 | */
|
---|
441 | HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
|
---|
442 | HMENU hmenuShared,
|
---|
443 | LPOLEMENUGROUPWIDTHS lpMenuWidths)
|
---|
444 |
|
---|
445 | {
|
---|
446 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
447 |
|
---|
448 | TRACE("(%p)\n", This);
|
---|
449 |
|
---|
450 | /* Feature not implemented */
|
---|
451 | return E_NOTIMPL;
|
---|
452 | }
|
---|
453 | /**************************************************************************
|
---|
454 | * IShellBrowserImpl_OnViewWindowActive
|
---|
455 | */
|
---|
456 | HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
|
---|
457 | IShellView *ppshv)
|
---|
458 |
|
---|
459 | {
|
---|
460 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
461 |
|
---|
462 | TRACE("(%p)\n", This);
|
---|
463 |
|
---|
464 | /* Feature not implemented */
|
---|
465 | return E_NOTIMPL;
|
---|
466 | }
|
---|
467 | /**************************************************************************
|
---|
468 | * IShellBrowserImpl_QueryActiveShellView
|
---|
469 | */
|
---|
470 | HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
|
---|
471 | IShellView **ppshv)
|
---|
472 |
|
---|
473 | {
|
---|
474 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
475 |
|
---|
476 | FileOpenDlgInfos *fodInfos;
|
---|
477 |
|
---|
478 | TRACE("(%p)\n", This);
|
---|
479 |
|
---|
480 | fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
|
---|
481 |
|
---|
482 | if(!(*ppshv = fodInfos->Shell.FOIShellView))
|
---|
483 | {
|
---|
484 | return E_FAIL;
|
---|
485 | }
|
---|
486 | IShellView_AddRef(fodInfos->Shell.FOIShellView);
|
---|
487 | return NOERROR;
|
---|
488 | }
|
---|
489 | /**************************************************************************
|
---|
490 | * IShellBrowserImpl_RemoveMenusSB
|
---|
491 | */
|
---|
492 | HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
|
---|
493 | HMENU hmenuShared)
|
---|
494 |
|
---|
495 | {
|
---|
496 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
497 |
|
---|
498 | TRACE("(%p)\n", This);
|
---|
499 |
|
---|
500 | /* Feature not implemented */
|
---|
501 | return E_NOTIMPL;
|
---|
502 | }
|
---|
503 | /**************************************************************************
|
---|
504 | * IShellBrowserImpl_SendControlMsg
|
---|
505 | */
|
---|
506 | HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
|
---|
507 | UINT id,
|
---|
508 | UINT uMsg,
|
---|
509 | WPARAM wParam,
|
---|
510 | LPARAM lParam,
|
---|
511 | LRESULT *pret)
|
---|
512 |
|
---|
513 | {
|
---|
514 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
515 | LRESULT lres;
|
---|
516 |
|
---|
517 | // TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
|
---|
518 |
|
---|
519 | switch (id)
|
---|
520 | {
|
---|
521 | case FCW_TOOLBAR:
|
---|
522 | lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
|
---|
523 | break;
|
---|
524 | default:
|
---|
525 | FIXME("ctrl id: %x\n", id);
|
---|
526 | return E_NOTIMPL;
|
---|
527 | }
|
---|
528 | if (pret) *pret = lres;
|
---|
529 | return S_OK;
|
---|
530 | }
|
---|
531 | /**************************************************************************
|
---|
532 | * IShellBrowserImpl_SetMenuSB
|
---|
533 | */
|
---|
534 | HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
|
---|
535 | HMENU hmenuShared,
|
---|
536 | HOLEMENU holemenuReserved,
|
---|
537 | HWND hwndActiveObject)
|
---|
538 |
|
---|
539 | {
|
---|
540 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
541 |
|
---|
542 | TRACE("(%p)\n", This);
|
---|
543 |
|
---|
544 | /* Feature not implemented */
|
---|
545 | return E_NOTIMPL;
|
---|
546 | }
|
---|
547 | /**************************************************************************
|
---|
548 | * IShellBrowserImpl_SetStatusTextSB
|
---|
549 | */
|
---|
550 | HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
|
---|
551 | LPCOLESTR lpszStatusText)
|
---|
552 |
|
---|
553 | {
|
---|
554 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
555 |
|
---|
556 | TRACE("(%p)\n", This);
|
---|
557 |
|
---|
558 | /* Feature not implemented */
|
---|
559 | return E_NOTIMPL;
|
---|
560 | }
|
---|
561 | /**************************************************************************
|
---|
562 | * IShellBrowserImpl_SetToolbarItems
|
---|
563 | */
|
---|
564 | HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
|
---|
565 | LPTBBUTTON lpButtons,
|
---|
566 | UINT nButtons,
|
---|
567 | UINT uFlags)
|
---|
568 |
|
---|
569 | {
|
---|
570 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
571 |
|
---|
572 | TRACE("(%p)\n", This);
|
---|
573 |
|
---|
574 | /* Feature not implemented */
|
---|
575 | return E_NOTIMPL;
|
---|
576 | }
|
---|
577 | /**************************************************************************
|
---|
578 | * IShellBrowserImpl_TranslateAcceleratorSB
|
---|
579 | */
|
---|
580 | HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
|
---|
581 | LPMSG lpmsg,
|
---|
582 | WORD wID)
|
---|
583 |
|
---|
584 | {
|
---|
585 | ICOM_THIS(IShellBrowserImpl, iface);
|
---|
586 |
|
---|
587 | TRACE("(%p)\n", This);
|
---|
588 |
|
---|
589 | /* Feature not implemented */
|
---|
590 | return E_NOTIMPL;
|
---|
591 | }
|
---|
592 |
|
---|
593 | /*
|
---|
594 | * ICommDlgBrowser
|
---|
595 | */
|
---|
596 |
|
---|
597 | /***************************************************************************
|
---|
598 | * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
|
---|
599 | */
|
---|
600 | HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(ICommDlgBrowser *iface,
|
---|
601 | REFIID riid,
|
---|
602 | LPVOID *ppvObj)
|
---|
603 | {
|
---|
604 | _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
|
---|
605 |
|
---|
606 | TRACE("(%p)\n", This);
|
---|
607 |
|
---|
608 | return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
|
---|
609 | }
|
---|
610 |
|
---|
611 | /**************************************************************************
|
---|
612 | * IShellBrowserImpl_ICommDlgBrowser_AddRef
|
---|
613 | */
|
---|
614 | ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
|
---|
615 | {
|
---|
616 | _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
|
---|
617 |
|
---|
618 | TRACE("(%p)\n", This);
|
---|
619 |
|
---|
620 | return IShellBrowserImpl_AddRef(This);
|
---|
621 | }
|
---|
622 |
|
---|
623 | /**************************************************************************
|
---|
624 | * IShellBrowserImpl_ICommDlgBrowser_Release
|
---|
625 | */
|
---|
626 | ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
|
---|
627 | {
|
---|
628 | _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
|
---|
629 |
|
---|
630 | TRACE("(%p)\n", This);
|
---|
631 |
|
---|
632 | return IShellBrowserImpl_Release(This);
|
---|
633 | }
|
---|
634 | /**************************************************************************
|
---|
635 | * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
|
---|
636 | *
|
---|
637 | * Called when a user double-clicks in the view or presses the ENTER key
|
---|
638 | */
|
---|
639 | HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
|
---|
640 | IShellView *ppshv)
|
---|
641 | {
|
---|
642 | LPITEMIDLIST pidl;
|
---|
643 | FileOpenDlgInfos *fodInfos;
|
---|
644 |
|
---|
645 | _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
|
---|
646 |
|
---|
647 | TRACE("(%p)\n", This);
|
---|
648 |
|
---|
649 | fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
|
---|
650 |
|
---|
651 | /* If the selected object is not a folder, send a IDOK command to parent window */
|
---|
652 | if((pidl = GetSelectedPidl(ppshv)))
|
---|
653 | {
|
---|
654 | HRESULT hRes;
|
---|
655 |
|
---|
656 | ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
|
---|
657 | IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
|
---|
658 | if (ulAttr)
|
---|
659 | hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
|
---|
660 | /* Tell the dialog that the user selected a file */
|
---|
661 | else
|
---|
662 | {
|
---|
663 | hRes = FILEDLG95_OnOpen(This->hwndOwner);
|
---|
664 | }
|
---|
665 |
|
---|
666 | /* Free memory used by pidl */
|
---|
667 | COMDLG32_SHFree((LPVOID)pidl);
|
---|
668 |
|
---|
669 | return hRes;
|
---|
670 | }
|
---|
671 |
|
---|
672 | return E_FAIL;
|
---|
673 | }
|
---|
674 |
|
---|
675 | /**************************************************************************
|
---|
676 | * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
|
---|
677 | */
|
---|
678 | HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
|
---|
679 | IShellView *ppshv,
|
---|
680 | ULONG uChange)
|
---|
681 | {
|
---|
682 |
|
---|
683 | _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
|
---|
684 |
|
---|
685 | TRACE("(%p)\n", This);
|
---|
686 |
|
---|
687 | switch (uChange)
|
---|
688 | {
|
---|
689 | case CDBOSC_SETFOCUS:
|
---|
690 | break;
|
---|
691 | case CDBOSC_KILLFOCUS:
|
---|
692 | {
|
---|
693 | FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
|
---|
694 | if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
|
---|
695 | SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
|
---|
696 | }
|
---|
697 | break;
|
---|
698 | case CDBOSC_SELCHANGE:
|
---|
699 | return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
|
---|
700 | case CDBOSC_RENAME:
|
---|
701 | break;
|
---|
702 | }
|
---|
703 |
|
---|
704 | return NOERROR;
|
---|
705 | }
|
---|
706 | /**************************************************************************
|
---|
707 | * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
|
---|
708 | */
|
---|
709 | HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
|
---|
710 | IShellView * ppshv,
|
---|
711 | LPCITEMIDLIST pidl)
|
---|
712 | {
|
---|
713 | FileOpenDlgInfos *fodInfos;
|
---|
714 | ULONG ulAttr;
|
---|
715 | STRRET str;
|
---|
716 | WCHAR szPathW[MAX_PATH];
|
---|
717 |
|
---|
718 | _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
|
---|
719 |
|
---|
720 | TRACE("(%p)\n", This);
|
---|
721 |
|
---|
722 | fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
|
---|
723 |
|
---|
724 | ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
|
---|
725 | IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
|
---|
726 |
|
---|
727 |
|
---|
728 | if( (ulAttr & SFGAO_HIDDEN) /* hidden */
|
---|
729 | | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
|
---|
730 | return S_FALSE;
|
---|
731 | /* always include directorys and links */
|
---|
732 | if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
|
---|
733 | return S_OK;
|
---|
734 | /* Check if there is a mask to apply if not */
|
---|
735 | if(!fodInfos->ShellInfos.lpstrCurrentFilter ||
|
---|
736 | !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
|
---|
737 | return S_OK;
|
---|
738 |
|
---|
739 | if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_FORPARSING, &str)))
|
---|
740 | { if (SUCCEEDED(StrRetToBufW(&str, pidl,szPathW, MAX_PATH)))
|
---|
741 | {
|
---|
742 | if (COMDLG32_PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
|
---|
743 | return S_OK;
|
---|
744 | }
|
---|
745 | }
|
---|
746 | return S_FALSE;
|
---|
747 |
|
---|
748 | }
|
---|
749 |
|
---|
750 | /**************************************************************************
|
---|
751 | * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
|
---|
752 | */
|
---|
753 | HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
|
---|
754 | {
|
---|
755 | LPITEMIDLIST pidl;
|
---|
756 | FileOpenDlgInfos *fodInfos;
|
---|
757 | _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
|
---|
758 |
|
---|
759 | fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
|
---|
760 | TRACE("(%p)\n", This);
|
---|
761 |
|
---|
762 | if((pidl = GetSelectedPidl(ppshv)))
|
---|
763 | {
|
---|
764 | HRESULT hRes = E_FAIL;
|
---|
765 | char lpstrFileName[MAX_PATH];
|
---|
766 |
|
---|
767 | ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
|
---|
768 | IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
|
---|
769 | if (!ulAttr)
|
---|
770 | {
|
---|
771 | if(SUCCEEDED(hRes = GetName(fodInfos->Shell.FOIShellFolder,pidl,SHGDN_NORMAL,lpstrFileName)))
|
---|
772 | SetWindowTextA(fodInfos->DlgInfos.hwndFileName,lpstrFileName);
|
---|
773 | if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
|
---|
774 | SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
|
---|
775 | }
|
---|
776 | else
|
---|
777 | SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Open");
|
---|
778 |
|
---|
779 | fodInfos->DlgInfos.dwDlgProp |= FODPROP_USEVIEW;
|
---|
780 |
|
---|
781 | COMDLG32_SHFree((LPVOID)pidl);
|
---|
782 | SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
|
---|
783 | return hRes;
|
---|
784 | }
|
---|
785 | if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
|
---|
786 | SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
|
---|
787 |
|
---|
788 | fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
|
---|
789 | return E_FAIL;
|
---|
790 | }
|
---|
791 |
|
---|
792 | /***********************************************************************
|
---|
793 | * GetSelectedPidl
|
---|
794 | *
|
---|
795 | * Return the pidl of the first selected item in the view
|
---|
796 | */
|
---|
797 | LPITEMIDLIST GetSelectedPidl(IShellView *ppshv)
|
---|
798 | {
|
---|
799 |
|
---|
800 | IDataObject *doSelected;
|
---|
801 | LPITEMIDLIST pidlSelected = NULL;
|
---|
802 |
|
---|
803 | TRACE("sv=%p\n", ppshv);
|
---|
804 |
|
---|
805 | /* Get an IDataObject from the view */
|
---|
806 | if(SUCCEEDED(IShellView_GetItemObject(ppshv,
|
---|
807 | SVGIO_SELECTION,
|
---|
808 | &IID_IDataObject,
|
---|
809 | (LPVOID *)&doSelected)))
|
---|
810 | {
|
---|
811 | STGMEDIUM medium;
|
---|
812 | FORMATETC formatetc;
|
---|
813 |
|
---|
814 | /* Set the FORMATETC structure*/
|
---|
815 | SETDefFormatEtc(formatetc,
|
---|
816 | RegisterClipboardFormatA(CFSTR_SHELLIDLIST),
|
---|
817 | TYMED_HGLOBAL);
|
---|
818 |
|
---|
819 | /* Get the pidl from IDataObject */
|
---|
820 | if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
|
---|
821 | {
|
---|
822 | LPIDA cida = (LPIDA)GlobalLock(medium.u.hGlobal);
|
---|
823 | TRACE("cida=%p\n", cida);
|
---|
824 | pidlSelected = COMDLG32_PIDL_ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[1]]));
|
---|
825 |
|
---|
826 | if(medium.pUnkForRelease)
|
---|
827 | IUnknown_Release(medium.pUnkForRelease);
|
---|
828 | else
|
---|
829 | {
|
---|
830 | GlobalUnlock(medium.u.hGlobal);
|
---|
831 | GlobalFree(medium.u.hGlobal);
|
---|
832 | }
|
---|
833 | }
|
---|
834 | IDataObject_Release(doSelected);
|
---|
835 | return pidlSelected;
|
---|
836 | }
|
---|
837 |
|
---|
838 | return NULL;
|
---|
839 | }
|
---|
840 |
|
---|
841 |
|
---|
842 |
|
---|
843 |
|
---|
844 |
|
---|