source: trunk/src/comdlg32/filedlgbrowser.c

Last change on this file was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 28.8 KB
RevLine 
[2607]1/*
2 * Implementation of IShellBrowser for the File Open common dialog
[6709]3 *
[2607]4 *
5 */
6
[5583]7#include <stdio.h>
8#include <string.h>
[2607]9
[4511]10#include "windef.h"
[5583]11#include "winbase.h"
12#include "winnls.h"
[4511]13#include "wingdi.h"
[2607]14#include "winuser.h"
15#include "heap.h"
16#include "debugtools.h"
[5583]17
18#include "shlwapi.h"
19#include "filedlgbrowser.h"
[2607]20#include "cdlg.h"
[5583]21#include "shlguid.h"
[4561]22#include "wine/obj_serviceprovider.h"
23
[5583]24#ifdef __WIN32OS2__
25#include <heapstring.h>
26#include <misc.h>
27#endif
28
[4511]29DEFAULT_DEBUG_CHANNEL(commdlg);
[2607]30
[4561]31typedef struct
[2607]32{
33
[4561]34 ICOM_VTABLE(IShellBrowser) * lpVtbl;
35 ICOM_VTABLE(ICommDlgBrowser) * lpVtblCommDlgBrowser;
36 ICOM_VTABLE(IServiceProvider)* lpVtblServiceProvider;
37 DWORD ref; /* Reference counter */
38 HWND hwndOwner; /* Owner dialog of the interface */
[2607]39
[4561]40} IShellBrowserImpl;
[2607]41
42/**************************************************************************
[4561]43* vtable
44*/
45static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl;
46static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl;
47static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl;
48
49/**************************************************************************
[2607]50* Local Prototypes
51*/
52
53HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
54#if 0
55LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
56#endif
57
58/**************************************************************************
59* External Prototypes
60*/
[6709]61extern const char *FileOpenDlgInfosStr;
[2607]62
63extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
64extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
65extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
66extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
67extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
68
69extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
70 LPITEMIDLIST pidlCurrentFolder,
71 LPSTR lpstrMask);
72
73extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
74extern BOOL FILEDLG95_OnOpen(HWND hwnd);
75extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
76
77
[4561]78/*
79 * Helper functions
80 */
81
[5583]82static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
83{
84 char lpstrPath[MAX_PATH];
[8792]85#ifdef __WIN32OS2__
86 if(SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath) == TRUE) {
87 SetCurrentDirectoryA(lpstrPath);
88 TRACE("new current folder %s\n", lpstrPath);
89 }
90#else
[5583]91 SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
92 SetCurrentDirectoryA(lpstrPath);
93 TRACE("new current folder %s\n", lpstrPath);
[8792]94#endif
[5583]95}
96
[4561]97/* copied from shell32 to avoid linking to it */
98static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
99{
[6709]100 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
[4561]101
[6709]102 switch (src->uType)
103 {
104 case STRRET_WSTR:
[21916]105 lstrcpynW((LPWSTR)dest, src->DUMMYUNIONNAME_DOT pOleStr, len);
106 COMDLG32_SHFree(src->DUMMYUNIONNAME_DOT pOleStr);
[6709]107 break;
[4561]108
[21512]109 case STRRET_CSTR:
[21916]110 if (len && !MultiByteToWideChar( CP_ACP, 0, src->DUMMYUNIONNAME_DOT cStr, -1, (LPWSTR)dest, len ))
[5583]111 ((LPWSTR)dest)[len-1] = 0;
[6709]112 break;
[4561]113
[21512]114 case STRRET_OFFSET:
[6709]115 if (pidl)
116 {
[21916]117 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->DUMMYUNIONNAME_DOT uOffset,
[5583]118 -1, (LPWSTR)dest, len ))
119 ((LPWSTR)dest)[len-1] = 0;
[6709]120 }
121 break;
[4561]122
[6709]123 default:
124 FIXME("unknown type!\n");
125 if (len)
126 { *(LPWSTR)dest = '\0';
127 }
128 return(FALSE);
129 }
130 return S_OK;
[4561]131}
132
133/*
[6709]134 * IShellBrowser
[4561]135 */
[6709]136
[2607]137/**************************************************************************
138* IShellBrowserImpl_Construct
139*/
140IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
141{
142 IShellBrowserImpl *sb;
143 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
144
[4511]145 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
[2607]146
147 /* Initialisation of the member variables */
148 sb->ref=1;
149 sb->hwndOwner = hwndOwner;
150
151 /* Initialisation of the vTables */
152 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
[4561]153 sb->lpVtblCommDlgBrowser = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
154 sb->lpVtblServiceProvider = &IShellBrowserImpl_IServiceProvider_Vtbl;
[5583]155 SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
[2607]156 &fodInfos->ShellInfos.pidlAbsCurrent);
157
158 TRACE("%p\n", sb);
159
160 return (IShellBrowser *) sb;
161}
162
163/***************************************************************************
164* IShellBrowserImpl_QueryInterface
165*/
166HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
[6709]167 REFIID riid,
[2607]168 LPVOID *ppvObj)
169{
170 ICOM_THIS(IShellBrowserImpl, iface);
171
[4561]172 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
[2607]173
174 *ppvObj = NULL;
175
176 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
[6709]177 { *ppvObj = This;
[2607]178 }
179 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
180 { *ppvObj = (IOleWindow*)This;
181 }
182
183 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
184 { *ppvObj = (IShellBrowser*)This;
185 }
186
187 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
[4561]188 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblCommDlgBrowser);
[2607]189 }
190
[4561]191 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
192 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblServiceProvider);
193 }
194
[2607]195 if(*ppvObj)
196 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
197 return S_OK;
198 }
[4561]199 FIXME("Unknown interface requested\n");
[2607]200 return E_NOINTERFACE;
201}
202
203/**************************************************************************
204* IShellBrowser::AddRef
205*/
206ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
207{
208 ICOM_THIS(IShellBrowserImpl, iface);
209
210 TRACE("(%p)\n", This);
211
212 return ++(This->ref);
213}
214
215/**************************************************************************
216* IShellBrowserImpl_Release
217*/
218ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
219{
220 ICOM_THIS(IShellBrowserImpl, iface);
221
222 TRACE("(%p)\n", This);
223
[6709]224 if (!--(This->ref))
225 {
[4511]226 HeapFree(GetProcessHeap(),0, This);
[2607]227 return 0;
228 }
229 return This->ref;
230}
231
232/*
233 * IOleWindow
234 */
235
236/**************************************************************************
237* IShellBrowserImpl_GetWindow (IOleWindow)
238*
239* Inherited from IOleWindow::GetWindow
240*
241* See Windows documentation for more details
242*
243* Note : We will never be window less in the File Open dialog
[6709]244*
[2607]245*/
[6709]246HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
[2607]247 HWND * phwnd)
248{
249 ICOM_THIS(IShellBrowserImpl, iface);
250
251 TRACE("(%p)\n", This);
252
253 if(!This->hwndOwner)
254 return E_FAIL;
255
256 *phwnd = This->hwndOwner;
257
[6709]258 return (*phwnd) ? S_OK : E_UNEXPECTED;
[2607]259
260}
261
262/**************************************************************************
263* IShellBrowserImpl_ContextSensitiveHelp
264*/
265HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
266 BOOL fEnterMode)
267{
268 ICOM_THIS(IShellBrowserImpl, iface);
269
270 TRACE("(%p)\n", This);
271
272 /* Feature not implemented */
273 return E_NOTIMPL;
274}
275
276/*
277 * IShellBrowser
278 */
279
280/**************************************************************************
281* IShellBrowserImpl_BrowseObject
282*
283* See Windows documentation on IShellBrowser::BrowseObject for more details
284*
[6709]285* This function will override user specified flags and will always
286* use SBSP_DEFBROWSER and SBSP_DEFMODE.
[2607]287*/
[6709]288HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
289 LPCITEMIDLIST pidl,
[2607]290 UINT wFlags)
291{
292 HRESULT hRes;
293 IShellFolder *psfTmp;
294 IShellView *psvTmp;
295 FileOpenDlgInfos *fodInfos;
296 LPITEMIDLIST pidlTmp;
[4511]297 HWND hwndView;
298 HWND hDlgWnd;
299 BOOL bViewHasFocus;
[2607]300
301 ICOM_THIS(IShellBrowserImpl, iface);
302
[4511]303 TRACE("(%p)(%p,0x%08x)\n", This, pidl, wFlags);
[2607]304
305 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
306
307 /* Format the pidl according to its parameter's category */
308 if(wFlags & SBSP_RELATIVE)
309 {
[6709]310
[2607]311 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
[4511]312 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
313 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
[2607]314 {
[4511]315 ERR("bind to object failed\n");
[6709]316 return hRes;
[2607]317 }
318 /* create an absolute pidl */
319 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
320 (LPITEMIDLIST)pidl);
321 }
322 else if(wFlags & SBSP_PARENT)
323 {
324 /* Browse the parent folder (ignores the pidl) */
325 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
326 psfTmp = GetShellFolderFromPidl(pidlTmp);
327
328 }
[4511]329 else /* SBSP_ABSOLUTE is 0x0000 */
[2607]330 {
331 /* An absolute pidl (relative from the desktop) */
332 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
333 psfTmp = GetShellFolderFromPidl(pidlTmp);
334 }
[6709]335
[4561]336 if(!psfTmp)
337 {
338 ERR("could not browse to folder\n");
339 return E_FAIL;
340 }
[2607]341
[6709]342 /* If the pidl to browse to is equal to the actual pidl ...
[2607]343 do nothing and pretend you did it*/
344 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
345 {
346 IShellFolder_Release(psfTmp);
[6709]347 COMDLG32_SHFree(pidlTmp);
[4561]348 TRACE("keep current folder\n");
[2607]349 return NOERROR;
350 }
351
[4511]352 /* Release the current DataObject */
353 if (fodInfos->Shell.FOIDataObject)
[3243]354 {
[4511]355 IDataObject_Release(fodInfos->Shell.FOIDataObject);
356 fodInfos->Shell.FOIDataObject = NULL;
[3243]357 }
358
[2607]359 /* Create the associated view */
[4561]360 TRACE("create view object\n");
[4511]361 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
[4561]362 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
[3243]363
[4511]364 /* Check if listview has focus */
365 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
[3243]366
[4511]367 /* Get the foldersettings from the old view */
368 if(fodInfos->Shell.FOIShellView)
369 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
[2607]370
[4511]371 /* Release the old fodInfos->Shell.FOIShellView and update its value.
372 We have to update this early since ShellView_CreateViewWindow of native
373 shell32 calls OnStateChange and needs the correct view here.*/
374 if(fodInfos->Shell.FOIShellView)
375 {
376 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
377 IShellView_Release(fodInfos->Shell.FOIShellView);
378 }
379 fodInfos->Shell.FOIShellView = psvTmp;
[2607]380
[4511]381 /* Release old FOIShellFolder and update its value */
382 if (fodInfos->Shell.FOIShellFolder)
383 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
384 fodInfos->Shell.FOIShellFolder = psfTmp;
[3216]385
[4511]386 /* Release old pidlAbsCurrent and update its value */
387 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
388 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
[2607]389
[5583]390 COMDLG32_UpdateCurrentDir(fodInfos);
391
[4511]392 /* Create the window */
393 TRACE("create view window\n");
394 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
395 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
[4561]396 &fodInfos->ShellInfos.rectView, &hwndView))) goto error;
[2607]397
[4511]398 fodInfos->ShellInfos.hwndView = hwndView;
[2607]399
[4511]400 /* Select the new folder in the Look In combo box of the Open file dialog */
401 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
[3216]402
[4511]403 /* changes the tab order of the ListView to reflect the window's File Dialog */
[6709]404 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
[4511]405 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
[3243]406
[4511]407 /* Since we destroyed the old view if it had focus set focus to the newly created view */
408 if (bViewHasFocus)
409 SetFocus(fodInfos->ShellInfos.hwndView);
[3243]410
[6709]411 return hRes;
[4561]412error:
413 ERR("Failed with error 0x%08lx\n", hRes);
414 return hRes;
[2607]415}
416
417/**************************************************************************
418* IShellBrowserImpl_EnableModelessSB
419*/
[6709]420HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
[2607]421 BOOL fEnable)
[6709]422
[2607]423{
424 ICOM_THIS(IShellBrowserImpl, iface);
425
426 TRACE("(%p)\n", This);
427
428 /* Feature not implemented */
429 return E_NOTIMPL;
430}
431
432/**************************************************************************
433* IShellBrowserImpl_GetControlWindow
434*/
[6709]435HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
436 UINT id,
[2607]437 HWND *lphwnd)
[6709]438
[2607]439{
440 ICOM_THIS(IShellBrowserImpl, iface);
441
442 TRACE("(%p)\n", This);
443
444 /* Feature not implemented */
445 return E_NOTIMPL;
446}
447/**************************************************************************
448* IShellBrowserImpl_GetViewStateStream
449*/
450HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
[6709]451 DWORD grfMode,
[2607]452 LPSTREAM *ppStrm)
[6709]453
[2607]454{
455 ICOM_THIS(IShellBrowserImpl, iface);
456
[4561]457 FIXME("(%p 0x%08lx %p)\n", This, grfMode, ppStrm);
[2607]458
459 /* Feature not implemented */
460 return E_NOTIMPL;
[6709]461}
[2607]462/**************************************************************************
463* IShellBrowserImpl_InsertMenusSB
464*/
465HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
466 HMENU hmenuShared,
467 LPOLEMENUGROUPWIDTHS lpMenuWidths)
[6709]468
[2607]469{
470 ICOM_THIS(IShellBrowserImpl, iface);
471
472 TRACE("(%p)\n", This);
473
474 /* Feature not implemented */
475 return E_NOTIMPL;
476}
477/**************************************************************************
478* IShellBrowserImpl_OnViewWindowActive
479*/
480HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
481 IShellView *ppshv)
[6709]482
[2607]483{
484 ICOM_THIS(IShellBrowserImpl, iface);
485
486 TRACE("(%p)\n", This);
487
488 /* Feature not implemented */
489 return E_NOTIMPL;
[6709]490}
[2607]491/**************************************************************************
492* IShellBrowserImpl_QueryActiveShellView
493*/
494HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
495 IShellView **ppshv)
[6709]496
[2607]497{
498 ICOM_THIS(IShellBrowserImpl, iface);
499
500 FileOpenDlgInfos *fodInfos;
501
502 TRACE("(%p)\n", This);
503
504 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
505
506 if(!(*ppshv = fodInfos->Shell.FOIShellView))
507 {
508 return E_FAIL;
509 }
510 IShellView_AddRef(fodInfos->Shell.FOIShellView);
511 return NOERROR;
[6709]512}
[2607]513/**************************************************************************
514* IShellBrowserImpl_RemoveMenusSB
515*/
516HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
517 HMENU hmenuShared)
[6709]518
[2607]519{
520 ICOM_THIS(IShellBrowserImpl, iface);
521
522 TRACE("(%p)\n", This);
523
524 /* Feature not implemented */
525 return E_NOTIMPL;
[6709]526}
[2607]527/**************************************************************************
528* IShellBrowserImpl_SendControlMsg
529*/
[6709]530HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
531 UINT id,
532 UINT uMsg,
533 WPARAM wParam,
[2607]534 LPARAM lParam,
535 LRESULT *pret)
[6709]536
[2607]537{
538 ICOM_THIS(IShellBrowserImpl, iface);
539 LRESULT lres;
[6709]540
[2607]541 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
542
543 switch (id)
544 {
545 case FCW_TOOLBAR:
546 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
[6709]547 break;
[2607]548 default:
549 FIXME("ctrl id: %x\n", id);
550 return E_NOTIMPL;
551 }
552 if (pret) *pret = lres;
553 return S_OK;
554}
555/**************************************************************************
556* IShellBrowserImpl_SetMenuSB
557*/
558HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
[6709]559 HMENU hmenuShared,
[2607]560 HOLEMENU holemenuReserved,
561 HWND hwndActiveObject)
[6709]562
[2607]563{
564 ICOM_THIS(IShellBrowserImpl, iface);
565
566 TRACE("(%p)\n", This);
567
568 /* Feature not implemented */
569 return E_NOTIMPL;
[6709]570}
[2607]571/**************************************************************************
572* IShellBrowserImpl_SetStatusTextSB
573*/
574HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
575 LPCOLESTR lpszStatusText)
[6709]576
[2607]577{
578 ICOM_THIS(IShellBrowserImpl, iface);
579
580 TRACE("(%p)\n", This);
581
582 /* Feature not implemented */
583 return E_NOTIMPL;
[6709]584}
[2607]585/**************************************************************************
586* IShellBrowserImpl_SetToolbarItems
587*/
588HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
[6709]589 LPTBBUTTON lpButtons,
590 UINT nButtons,
[2607]591 UINT uFlags)
[6709]592
[2607]593{
594 ICOM_THIS(IShellBrowserImpl, iface);
595
596 TRACE("(%p)\n", This);
597
598 /* Feature not implemented */
599 return E_NOTIMPL;
[6709]600}
[2607]601/**************************************************************************
602* IShellBrowserImpl_TranslateAcceleratorSB
603*/
604HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
[6709]605 LPMSG lpmsg,
[2607]606 WORD wID)
[6709]607
[2607]608{
609 ICOM_THIS(IShellBrowserImpl, iface);
610
611 TRACE("(%p)\n", This);
612
613 /* Feature not implemented */
614 return E_NOTIMPL;
615}
616
[4561]617static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl =
618{
619 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
620 /* IUnknown */
621 IShellBrowserImpl_QueryInterface,
622 IShellBrowserImpl_AddRef,
623 IShellBrowserImpl_Release,
624 /* IOleWindow */
625 IShellBrowserImpl_GetWindow,
626 IShellBrowserImpl_ContextSensitiveHelp,
627 /* IShellBrowser */
628 IShellBrowserImpl_InsertMenusSB,
629 IShellBrowserImpl_SetMenuSB,
630 IShellBrowserImpl_RemoveMenusSB,
631 IShellBrowserImpl_SetStatusTextSB,
632 IShellBrowserImpl_EnableModelessSB,
633 IShellBrowserImpl_TranslateAcceleratorSB,
634 IShellBrowserImpl_BrowseObject,
635 IShellBrowserImpl_GetViewStateStream,
636 IShellBrowserImpl_GetControlWindow,
637 IShellBrowserImpl_SendControlMsg,
638 IShellBrowserImpl_QueryActiveShellView,
639 IShellBrowserImpl_OnViewWindowActive,
640 IShellBrowserImpl_SetToolbarItems
641};
642
643
644
[2607]645/*
646 * ICommDlgBrowser
647 */
648
649/***************************************************************************
650* IShellBrowserImpl_ICommDlgBrowser_QueryInterface
651*/
[4561]652HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
[6709]653 ICommDlgBrowser *iface,
654 REFIID riid,
655 LPVOID *ppvObj)
[2607]656{
657 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
658
659 TRACE("(%p)\n", This);
660
661 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
662}
663
664/**************************************************************************
665* IShellBrowserImpl_ICommDlgBrowser_AddRef
666*/
667ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
668{
669 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
670
671 TRACE("(%p)\n", This);
672
673 return IShellBrowserImpl_AddRef(This);
674}
675
676/**************************************************************************
677* IShellBrowserImpl_ICommDlgBrowser_Release
678*/
679ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
680{
681 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
682
683 TRACE("(%p)\n", This);
684
685 return IShellBrowserImpl_Release(This);
686}
687/**************************************************************************
688* IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
689*
690* Called when a user double-clicks in the view or presses the ENTER key
691*/
692HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
693 IShellView *ppshv)
694{
695 LPITEMIDLIST pidl;
696 FileOpenDlgInfos *fodInfos;
697
698 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
699
700 TRACE("(%p)\n", This);
701
[6709]702 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
703
[2607]704 /* If the selected object is not a folder, send a IDOK command to parent window */
[4511]705 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
[2607]706 {
707 HRESULT hRes;
708
709 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
710 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
[6709]711 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
712 {
[4511]713 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
[6709]714 }
[2607]715 else
[6709]716 {
[4511]717 /* Tell the dialog that the user selected a file */
[6709]718 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
719 }
[2607]720
721 /* Free memory used by pidl */
722 COMDLG32_SHFree((LPVOID)pidl);
723
724 return hRes;
725 }
726
727 return E_FAIL;
728}
729
730/**************************************************************************
731* IShellBrowserImpl_ICommDlgBrowser_OnStateChange
732*/
733HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
734 IShellView *ppshv,
735 ULONG uChange)
736{
737
738 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
739
[4511]740 TRACE("(%p shv=%p)\n", This, ppshv);
[2607]741
742 switch (uChange)
743 {
744 case CDBOSC_SETFOCUS:
[3243]745 /* FIXME: Reset the default button.
[6709]746 This should be taken care of by defdlg. If control
747 other than button receives focus the default button
748 should be restored. */
[3243]749 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
[4511]750
[2607]751 break;
[6709]752 case CDBOSC_KILLFOCUS:
753 {
754 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
755 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
756 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
[2607]757 }
758 break;
759 case CDBOSC_SELCHANGE:
760 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
761 case CDBOSC_RENAME:
[6709]762 /* nothing to do */
[2607]763 break;
764 }
765
[6709]766 return NOERROR;
[2607]767}
[4511]768
[2607]769/**************************************************************************
770* IShellBrowserImpl_ICommDlgBrowser_IncludeObject
771*/
[6709]772HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
[2607]773 IShellView * ppshv,
774 LPCITEMIDLIST pidl)
775{
776 FileOpenDlgInfos *fodInfos;
777 ULONG ulAttr;
778 STRRET str;
779 WCHAR szPathW[MAX_PATH];
780
781 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
782
783 TRACE("(%p)\n", This);
[4511]784
[2607]785 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
786
787 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
788 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
[6709]789
[3216]790 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
791 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
[2607]792 return S_FALSE;
[4511]793
[2607]794 /* always include directorys and links */
[6709]795 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
[2607]796 return S_OK;
[4511]797
[2607]798 /* Check if there is a mask to apply if not */
[4511]799 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
[2607]800 return S_OK;
801
[4511]802 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
[3256]803 {
[4511]804 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
[2607]805 {
[6709]806 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
[4511]807 return S_OK;
[2607]808 }
809 }
810 return S_FALSE;
[4511]811
[2607]812}
813
814/**************************************************************************
815* IShellBrowserImpl_ICommDlgBrowser_OnSelChange
[6709]816*/
[2607]817HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
818{
819 FileOpenDlgInfos *fodInfos;
[3243]820
[2607]821 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
822
823 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
[4511]824 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
[6709]825
[4511]826 /* release old selections */
827 if (fodInfos->Shell.FOIDataObject)
828 IDataObject_Release(fodInfos->Shell.FOIDataObject);
[6709]829
[4511]830 /* get a new DataObject from the ShellView */
831 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
832 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
833 return E_FAIL;
[6709]834
[4511]835 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
[2607]836
[4511]837 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
838 return S_OK;
[2607]839}
840
[4561]841static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl =
842{
843 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
844 /* IUnknown */
845 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
846 IShellBrowserImpl_ICommDlgBrowser_AddRef,
847 IShellBrowserImpl_ICommDlgBrowser_Release,
848 /* ICommDlgBrowser */
849 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
850 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
851 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
852};
853
854
855
856
857/*
858 * IServiceProvider
859 */
860
861/***************************************************************************
862* IShellBrowserImpl_IServiceProvider_QueryInterface
863*/
864HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
[6709]865 IServiceProvider *iface,
866 REFIID riid,
867 LPVOID *ppvObj)
[4561]868{
869 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
870
871 FIXME("(%p)\n", This);
872
873 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
874}
875
876/**************************************************************************
877* IShellBrowserImpl_IServiceProvider_AddRef
878*/
879ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface)
880{
881 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
882
883 FIXME("(%p)\n", This);
884
885 return IShellBrowserImpl_AddRef(This);
886}
887
888/**************************************************************************
889* IShellBrowserImpl_IServiceProvider_Release
890*/
891ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface)
892{
893 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
894
895 FIXME("(%p)\n", This);
896
897 return IShellBrowserImpl_Release(This);
898}
899
900/**************************************************************************
901* IShellBrowserImpl_IServiceProvider_Release
902*
903* NOTES
[6709]904* the w2k shellview asks for
[4561]905* guidService = SID_STopLevelBrowser
906* riid = IShellBrowser
907*
908* FIXME
909* this is a hack!
910*/
911
912HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
[6709]913 IServiceProvider * iface,
914 REFGUID guidService,
915 REFIID riid,
916 void** ppv)
[4561]917{
918 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
919
920 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
921
922 *ppv = NULL;
923 if(guidService && IsEqualIID(guidService, &SID_STopLevelBrowser))
924 {
925 return IShellBrowserImpl_QueryInterface(This,riid,ppv);
926 }
927 FIXME("(%p) unknown interface requested\n", This);
928 return E_NOINTERFACE;
929
930}
931
932static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl =
933{
934 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
935 /* IUnknown */
936 IShellBrowserImpl_IServiceProvider_QueryInterface,
937 IShellBrowserImpl_IServiceProvider_AddRef,
938 IShellBrowserImpl_IServiceProvider_Release,
939 /* IServiceProvider */
940 IShellBrowserImpl_IServiceProvider_QueryService
941};
Note: See TracBrowser for help on using the repository browser.