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