2 * Implementation of IShellBrowser for the File Open common dialog
4 * Copyright 1999 Francois Boisvert
5 * Copyright 1999, 2000 Juergen Schmied
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
37 #define NO_SHLWAPI_STREAM
39 #include "filedlgbrowser.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
50 IShellBrowser IShellBrowser_iface;
51 ICommDlgBrowser ICommDlgBrowser_iface;
52 IServiceProvider IServiceProvider_iface;
53 LONG ref; /* Reference counter */
54 HWND hwndOwner; /* Owner dialog of the interface */
58 static inline IShellBrowserImpl *impl_from_IShellBrowser(IShellBrowser *iface)
60 return CONTAINING_RECORD(iface, IShellBrowserImpl, IShellBrowser_iface);
63 static inline IShellBrowserImpl *impl_from_ICommDlgBrowser( ICommDlgBrowser *iface )
65 return CONTAINING_RECORD(iface, IShellBrowserImpl, ICommDlgBrowser_iface);
68 static inline IShellBrowserImpl *impl_from_IServiceProvider( IServiceProvider *iface )
70 return CONTAINING_RECORD(iface, IShellBrowserImpl, IServiceProvider_iface);
73 /**************************************************************************
76 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl;
77 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl;
78 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl;
84 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
85 static void COMDLG32_DumpSBSPFlags(UINT uflags)
87 if (TRACE_ON(commdlg))
94 #define FE(x) { x, #x}
95 /* SBSP_DEFBROWSER == 0 */
99 /* SBSP_DEFMODE == 0 */
101 FE(SBSP_EXPLOREMODE),
103 FE(SBSP_NOTRANSFERHIST),
105 /* SBSP_ABSOLUTE == 0 */
108 FE(SBSP_NAVIGATEBACK),
109 FE(SBSP_NAVIGATEFORWARD),
110 FE(SBSP_ALLOW_AUTONAVIGATE),
112 FE(SBSP_NOAUTOSELECT),
113 FE(SBSP_WRITENOHISTORY),
116 FE(SBSP_INITIATEDBYHLINKFRAME),
119 TRACE("SBSP Flags: %08x =", uflags);
120 for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
121 if (flags[i].mask & uflags)
122 TRACE("%s ", flags[i].name);
127 static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos *fodInfos)
129 LPSHELLFOLDER psfDesktop;
133 res = SHGetDesktopFolder(&psfDesktop);
137 res = IShellFolder_GetDisplayNameOf(psfDesktop, fodInfos->ShellInfos.pidlAbsCurrent,
138 SHGDN_FORPARSING, &strret);
139 if (SUCCEEDED(res)) {
140 WCHAR wszCurrentDir[MAX_PATH];
142 res = StrRetToBufW(&strret, fodInfos->ShellInfos.pidlAbsCurrent, wszCurrentDir, MAX_PATH);
144 SetCurrentDirectoryW(wszCurrentDir);
147 IShellFolder_Release(psfDesktop);
150 /* copied from shell32 to avoid linking to it */
151 static BOOL COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPCITEMIDLIST pidl)
153 TRACE("dest=%p len=0x%x strret=%p pidl=%p stub\n",dest,len,src,pidl);
158 lstrcpynW(dest, src->u.pOleStr, len);
159 COMDLG32_SHFree(src->u.pOleStr);
163 if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ))
164 ((LPWSTR)dest)[len-1] = 0;
170 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
172 ((LPWSTR)dest)[len-1] = 0;
177 FIXME("unknown type!\n");
179 { *(LPWSTR)dest = '\0';
190 /**************************************************************************
191 * IShellBrowserImpl_Construct
193 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
195 IShellBrowserImpl *sb;
196 FileOpenDlgInfos *fodInfos = GetPropA(hwndOwner,FileOpenDlgInfosStr);
198 sb = COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
200 /* Initialisation of the member variables */
202 sb->hwndOwner = hwndOwner;
204 /* Initialisation of the vTables */
205 sb->IShellBrowser_iface.lpVtbl = &IShellBrowserImpl_Vtbl;
206 sb->ICommDlgBrowser_iface.lpVtbl = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
207 sb->IServiceProvider_iface.lpVtbl = &IShellBrowserImpl_IServiceProvider_Vtbl;
208 SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
209 &fodInfos->ShellInfos.pidlAbsCurrent);
213 return &sb->IShellBrowser_iface;
216 /***************************************************************************
217 * IShellBrowserImpl_QueryInterface
219 static HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
223 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
225 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
229 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
232 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
236 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
240 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
241 *ppvObj = &This->ICommDlgBrowser_iface;
242 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
243 *ppvObj = &This->IServiceProvider_iface;
246 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
249 FIXME("Unknown interface requested\n");
250 return E_NOINTERFACE;
253 /**************************************************************************
254 * IShellBrowser::AddRef
256 static ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
258 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
259 ULONG ref = InterlockedIncrement(&This->ref);
261 TRACE("(%p,%u)\n", This, ref - 1);
266 /**************************************************************************
267 * IShellBrowserImpl_Release
269 static ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
271 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
272 ULONG ref = InterlockedDecrement(&This->ref);
274 TRACE("(%p,%u)\n", This, ref + 1);
278 COMDLG32_SHFree(This);
279 TRACE("-- destroyed\n");
289 /**************************************************************************
290 * IShellBrowserImpl_GetWindow (IOleWindow)
292 * Inherited from IOleWindow::GetWindow
294 * See Windows documentation for more details
296 * Note : We will never be window less in the File Open dialog
299 static HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
302 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
304 TRACE("(%p)\n", This);
309 *phwnd = This->hwndOwner;
311 return (*phwnd) ? S_OK : E_UNEXPECTED;
315 /**************************************************************************
316 * IShellBrowserImpl_ContextSensitiveHelp
318 static HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
321 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
323 TRACE("(%p)\n", This);
325 /* Feature not implemented */
333 /**************************************************************************
334 * IShellBrowserImpl_BrowseObject
336 * See Windows documentation on IShellBrowser::BrowseObject for more details
338 * This function will override user specified flags and will always
339 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
341 static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
346 IShellFolder *psfTmp;
348 FileOpenDlgInfos *fodInfos;
349 LPITEMIDLIST pidlTmp;
355 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
357 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This, pidl, wFlags);
358 COMDLG32_DumpSBSPFlags(wFlags);
360 fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
362 /* Format the pidl according to its parameter's category */
363 if(wFlags & SBSP_RELATIVE)
366 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
367 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
368 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
370 ERR("bind to object failed\n");
373 /* create an absolute pidl */
374 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent, pidl);
376 else if(wFlags & SBSP_PARENT)
378 /* Browse the parent folder (ignores the pidl) */
379 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
380 psfTmp = GetShellFolderFromPidl(pidlTmp);
383 else /* SBSP_ABSOLUTE is 0x0000 */
385 /* An absolute pidl (relative from the desktop) */
386 pidlTmp = COMDLG32_PIDL_ILClone(pidl);
387 psfTmp = GetShellFolderFromPidl(pidlTmp);
392 ERR("could not browse to folder\n");
396 /* If the pidl to browse to is equal to the actual pidl ...
397 do nothing and pretend you did it*/
398 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
400 IShellFolder_Release(psfTmp);
401 COMDLG32_SHFree(pidlTmp);
402 TRACE("keep current folder\n");
406 /* Release the current DataObject */
407 if (fodInfos->Shell.FOIDataObject)
409 IDataObject_Release(fodInfos->Shell.FOIDataObject);
410 fodInfos->Shell.FOIDataObject = NULL;
413 /* Create the associated view */
414 TRACE("create view object\n");
415 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
416 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
418 /* Check if listview has focus */
419 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
421 /* Get the foldersettings from the old view */
422 if(fodInfos->Shell.FOIShellView)
423 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
425 /* Release the old fodInfos->Shell.FOIShellView and update its value.
426 We have to update this early since ShellView_CreateViewWindow of native
427 shell32 calls OnStateChange and needs the correct view here.*/
428 if(fodInfos->Shell.FOIShellView)
430 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
431 IShellView_Release(fodInfos->Shell.FOIShellView);
433 fodInfos->Shell.FOIShellView = psvTmp;
435 /* Release old FOIShellFolder and update its value */
436 if (fodInfos->Shell.FOIShellFolder)
437 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
438 fodInfos->Shell.FOIShellFolder = psfTmp;
440 /* Release old pidlAbsCurrent and update its value */
441 COMDLG32_SHFree(fodInfos->ShellInfos.pidlAbsCurrent);
442 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
444 COMDLG32_UpdateCurrentDir(fodInfos);
446 GetWindowRect(GetDlgItem(This->hwndOwner, IDC_SHELLSTATIC), &rectView);
447 MapWindowPoints(0, This->hwndOwner, (LPPOINT)&rectView, 2);
449 /* Create the window */
450 TRACE("create view window\n");
451 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
452 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
453 &rectView, &hwndView))) goto error;
455 fodInfos->ShellInfos.hwndView = hwndView;
457 /* Set view window control id to 5002 */
458 SetWindowLongPtrW(hwndView, GWLP_ID, lst2);
460 /* Select the new folder in the Look In combo box of the Open file dialog */
461 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
463 /* changes the tab order of the ListView to reflect the window's File Dialog */
464 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
465 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
467 /* Since we destroyed the old view if it had focus set focus to the newly created view */
469 SetFocus(fodInfos->ShellInfos.hwndView);
473 ERR("Failed with error 0x%08x\n", hRes);
477 /**************************************************************************
478 * IShellBrowserImpl_EnableModelessSB
480 static HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
484 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
486 TRACE("(%p)\n", This);
488 /* Feature not implemented */
492 /**************************************************************************
493 * IShellBrowserImpl_GetControlWindow
495 static HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
500 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
502 TRACE("(%p)\n", This);
504 /* Feature not implemented */
508 /**************************************************************************
509 * IShellBrowserImpl_GetViewStateStream
511 static HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
516 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
518 FIXME("(%p 0x%08x %p)\n", This, grfMode, ppStrm);
520 /* Feature not implemented */
524 /**************************************************************************
525 * IShellBrowserImpl_InsertMenusSB
527 static HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
529 LPOLEMENUGROUPWIDTHS lpMenuWidths)
532 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
534 TRACE("(%p)\n", This);
536 /* Feature not implemented */
540 /**************************************************************************
541 * IShellBrowserImpl_OnViewWindowActive
543 static HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
547 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
549 TRACE("(%p)\n", This);
551 /* Feature not implemented */
555 /**************************************************************************
556 * IShellBrowserImpl_QueryActiveShellView
558 static HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
562 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
564 FileOpenDlgInfos *fodInfos;
566 TRACE("(%p)\n", This);
568 fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
570 if(!(*ppshv = fodInfos->Shell.FOIShellView))
574 IShellView_AddRef(fodInfos->Shell.FOIShellView);
578 /**************************************************************************
579 * IShellBrowserImpl_RemoveMenusSB
581 static HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
585 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
587 TRACE("(%p)\n", This);
589 /* Feature not implemented */
593 /**************************************************************************
594 * IShellBrowserImpl_SendControlMsg
596 static HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
604 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
607 TRACE("(%p)->(0x%08x 0x%08x 0x%08lx 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
612 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
615 FIXME("ctrl id: %x\n", id);
618 if (pret) *pret = lres;
622 /**************************************************************************
623 * IShellBrowserImpl_SetMenuSB
625 static HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
627 HOLEMENU holemenuReserved,
628 HWND hwndActiveObject)
631 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
633 TRACE("(%p)\n", This);
635 /* Feature not implemented */
639 /**************************************************************************
640 * IShellBrowserImpl_SetStatusTextSB
642 static HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
643 LPCOLESTR lpszStatusText)
646 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
648 TRACE("(%p)\n", This);
650 /* Feature not implemented */
654 /**************************************************************************
655 * IShellBrowserImpl_SetToolbarItems
657 static HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
658 LPTBBUTTON lpButtons,
663 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
665 TRACE("(%p)\n", This);
667 /* Feature not implemented */
671 /**************************************************************************
672 * IShellBrowserImpl_TranslateAcceleratorSB
674 static HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
679 IShellBrowserImpl *This = impl_from_IShellBrowser(iface);
681 TRACE("(%p)\n", This);
683 /* Feature not implemented */
687 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl =
690 IShellBrowserImpl_QueryInterface,
691 IShellBrowserImpl_AddRef,
692 IShellBrowserImpl_Release,
694 IShellBrowserImpl_GetWindow,
695 IShellBrowserImpl_ContextSensitiveHelp,
697 IShellBrowserImpl_InsertMenusSB,
698 IShellBrowserImpl_SetMenuSB,
699 IShellBrowserImpl_RemoveMenusSB,
700 IShellBrowserImpl_SetStatusTextSB,
701 IShellBrowserImpl_EnableModelessSB,
702 IShellBrowserImpl_TranslateAcceleratorSB,
703 IShellBrowserImpl_BrowseObject,
704 IShellBrowserImpl_GetViewStateStream,
705 IShellBrowserImpl_GetControlWindow,
706 IShellBrowserImpl_SendControlMsg,
707 IShellBrowserImpl_QueryActiveShellView,
708 IShellBrowserImpl_OnViewWindowActive,
709 IShellBrowserImpl_SetToolbarItems
718 /***************************************************************************
719 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
721 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
722 ICommDlgBrowser *iface,
726 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
728 TRACE("(%p)\n", This);
730 return IShellBrowserImpl_QueryInterface(&This->IShellBrowser_iface,riid,ppvObj);
733 /**************************************************************************
734 * IShellBrowserImpl_ICommDlgBrowser_AddRef
736 static ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
738 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
740 TRACE("(%p)\n", This);
742 return IShellBrowserImpl_AddRef(&This->IShellBrowser_iface);
745 /**************************************************************************
746 * IShellBrowserImpl_ICommDlgBrowser_Release
748 static ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
750 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
752 TRACE("(%p)\n", This);
754 return IShellBrowserImpl_Release(&This->IShellBrowser_iface);
757 /**************************************************************************
758 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
760 * Called when a user double-clicks in the view or presses the ENTER key
762 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
766 FileOpenDlgInfos *fodInfos;
768 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
770 TRACE("(%p)\n", This);
772 fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
774 /* If the selected object is not a folder, send an IDOK command to parent window */
775 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
779 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
780 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, (LPCITEMIDLIST *)&pidl, &ulAttr);
781 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
783 hRes = IShellBrowser_BrowseObject(&This->IShellBrowser_iface,pidl,SBSP_RELATIVE);
784 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
785 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_FOLDERCHANGE);
789 /* Tell the dialog that the user selected a file */
790 PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
794 /* Free memory used by pidl */
795 COMDLG32_SHFree(pidl);
803 /**************************************************************************
804 * IShellBrowserImpl_OnSelChange
806 static HRESULT IShellBrowserImpl_OnSelChange(IShellBrowserImpl *This, const IShellView *ppshv)
808 FileOpenDlgInfos *fodInfos;
810 fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
811 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
813 /* release old selections */
814 if (fodInfos->Shell.FOIDataObject)
815 IDataObject_Release(fodInfos->Shell.FOIDataObject);
817 /* get a new DataObject from the ShellView */
818 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
819 &IID_IDataObject, (void**)&fodInfos->Shell.FOIDataObject)))
822 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
824 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
825 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
829 /**************************************************************************
830 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
832 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
837 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
839 TRACE("(%p shv=%p)\n", This, ppshv);
843 case CDBOSC_SETFOCUS:
844 /* FIXME: Reset the default button.
845 This should be taken care of by defdlg. If control
846 other than button receives focus the default button
847 should be restored. */
848 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
851 case CDBOSC_KILLFOCUS:
853 FileOpenDlgInfos *fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
854 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
857 LoadStringW(COMDLG32_hInstance, IDS_SAVE_BUTTON, szSave, sizeof(szSave)/sizeof(WCHAR));
858 SetDlgItemTextW(fodInfos->ShellInfos.hwndOwner, IDOK, szSave);
862 case CDBOSC_SELCHANGE:
863 return IShellBrowserImpl_OnSelChange(This, ppshv);
872 /* send_includeitem_notification
874 * Sends a CDN_INCLUDEITEM notification for "pidl" to hwndParentDlg
876 static LRESULT send_includeitem_notification(HWND hwndParentDlg, LPCITEMIDLIST pidl)
878 LRESULT hook_result = 0;
879 FileOpenDlgInfos *fodInfos = GetPropA(hwndParentDlg, FileOpenDlgInfosStr);
881 if(!fodInfos) return 0;
883 if(fodInfos->DlgInfos.hwndCustomDlg)
885 TRACE("call notify CDN_INCLUDEITEM for pidl=%p\n", pidl);
886 if(fodInfos->unicode)
888 OFNOTIFYEXW ofnNotify;
889 ofnNotify.psf = fodInfos->Shell.FOIShellFolder;
890 ofnNotify.pidl = (LPITEMIDLIST)pidl;
891 ofnNotify.hdr.hwndFrom = hwndParentDlg;
892 ofnNotify.hdr.idFrom = 0;
893 ofnNotify.hdr.code = CDN_INCLUDEITEM;
894 ofnNotify.lpOFN = fodInfos->ofnInfos;
895 hook_result = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg, WM_NOTIFY, 0, (LPARAM)&ofnNotify);
899 OFNOTIFYEXA ofnNotify;
900 ofnNotify.psf = fodInfos->Shell.FOIShellFolder;
901 ofnNotify.pidl = (LPITEMIDLIST)pidl;
902 ofnNotify.hdr.hwndFrom = hwndParentDlg;
903 ofnNotify.hdr.idFrom = 0;
904 ofnNotify.hdr.code = CDN_INCLUDEITEM;
905 ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;
906 hook_result = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg, WM_NOTIFY, 0, (LPARAM)&ofnNotify);
909 TRACE("Retval: 0x%08lx\n", hook_result);
913 /**************************************************************************
914 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
916 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
920 FileOpenDlgInfos *fodInfos;
923 WCHAR szPathW[MAX_PATH];
925 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
927 TRACE("(%p)\n", This);
929 fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
931 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
932 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
934 if( (ulAttr & SFGAO_HIDDEN) || /* hidden */
935 !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
938 /* always include directories and links */
939 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
942 /* if the application takes care of including the item we are done */
943 if(fodInfos->ofnInfos->Flags & OFN_ENABLEINCLUDENOTIFY &&
944 send_includeitem_notification(This->hwndOwner, pidl))
947 /* Check if there is a mask to apply if not */
948 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
951 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
953 if (COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl))
955 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
963 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl =
966 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
967 IShellBrowserImpl_ICommDlgBrowser_AddRef,
968 IShellBrowserImpl_ICommDlgBrowser_Release,
969 /* ICommDlgBrowser */
970 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
971 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
972 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
982 /***************************************************************************
983 * IShellBrowserImpl_IServiceProvider_QueryInterface
985 static HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
986 IServiceProvider *iface,
990 IShellBrowserImpl *This = impl_from_IServiceProvider(iface);
992 FIXME("(%p)\n", This);
994 return IShellBrowserImpl_QueryInterface(&This->IShellBrowser_iface,riid,ppvObj);
997 /**************************************************************************
998 * IShellBrowserImpl_IServiceProvider_AddRef
1000 static ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface)
1002 IShellBrowserImpl *This = impl_from_IServiceProvider(iface);
1004 FIXME("(%p)\n", This);
1006 return IShellBrowserImpl_AddRef(&This->IShellBrowser_iface);
1009 /**************************************************************************
1010 * IShellBrowserImpl_IServiceProvider_Release
1012 static ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface)
1014 IShellBrowserImpl *This = impl_from_IServiceProvider(iface);
1016 FIXME("(%p)\n", This);
1018 return IShellBrowserImpl_Release(&This->IShellBrowser_iface);
1021 /**************************************************************************
1022 * IShellBrowserImpl_IServiceProvider_Release
1025 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
1026 * riid = IShellBrowser) to call SendControlMsg ().
1032 static HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
1033 IServiceProvider * iface,
1034 REFGUID guidService,
1038 IShellBrowserImpl *This = impl_from_IServiceProvider(iface);
1040 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
1043 if(guidService && IsEqualIID(guidService, &SID_STopLevelBrowser))
1044 return IShellBrowserImpl_QueryInterface(&This->IShellBrowser_iface,riid,ppv);
1046 FIXME("(%p) unknown interface requested\n", This);
1047 return E_NOINTERFACE;
1051 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl =
1054 IShellBrowserImpl_IServiceProvider_QueryInterface,
1055 IShellBrowserImpl_IServiceProvider_AddRef,
1056 IShellBrowserImpl_IServiceProvider_Release,
1057 /* IServiceProvider */
1058 IShellBrowserImpl_IServiceProvider_QueryService