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 const IShellBrowserVtbl *lpVtbl;
51 const ICommDlgBrowserVtbl *lpVtblCommDlgBrowser;
52 const IServiceProviderVtbl *lpVtblServiceProvider;
53 LONG ref; /* Reference counter */
54 HWND hwndOwner; /* Owner dialog of the interface */
58 static inline IShellBrowserImpl *impl_from_ICommDlgBrowser( ICommDlgBrowser *iface )
60 return (IShellBrowserImpl *)((char*)iface - FIELD_OFFSET(IShellBrowserImpl, lpVtblCommDlgBrowser));
63 static inline IShellBrowserImpl *impl_from_IServiceProvider( IServiceProvider *iface )
65 return (IShellBrowserImpl *)((char*)iface - FIELD_OFFSET(IShellBrowserImpl, lpVtblServiceProvider));
68 /**************************************************************************
71 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl;
72 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl;
73 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl;
75 /**************************************************************************
79 static HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, const IShellView *ppshv);
85 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
86 static void COMDLG32_DumpSBSPFlags(UINT uflags)
88 if (TRACE_ON(commdlg))
95 #define FE(x) { x, #x}
96 /* SBSP_DEFBROWSER == 0 */
100 /* SBSP_DEFMODE == 0 */
102 FE(SBSP_EXPLOREMODE),
104 FE(SBSP_NOTRANSFERHIST),
106 /* SBSP_ABSOLUTE == 0 */
109 FE(SBSP_NAVIGATEBACK),
110 FE(SBSP_NAVIGATEFORWARD),
111 FE(SBSP_ALLOW_AUTONAVIGATE),
113 FE(SBSP_NOAUTOSELECT),
114 FE(SBSP_WRITENOHISTORY),
117 FE(SBSP_INITIATEDBYHLINKFRAME),
120 TRACE("SBSP Flags: %08x =", uflags);
121 for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
122 if (flags[i].mask & uflags)
123 TRACE("%s ", flags[i].name);
128 static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos *fodInfos)
130 LPSHELLFOLDER psfDesktop;
134 res = SHGetDesktopFolder(&psfDesktop);
138 res = IShellFolder_GetDisplayNameOf(psfDesktop, fodInfos->ShellInfos.pidlAbsCurrent,
139 SHGDN_FORPARSING, &strret);
140 if (SUCCEEDED(res)) {
141 WCHAR wszCurrentDir[MAX_PATH];
143 res = StrRetToBufW(&strret, fodInfos->ShellInfos.pidlAbsCurrent, wszCurrentDir, MAX_PATH);
145 SetCurrentDirectoryW(wszCurrentDir);
148 IShellFolder_Release(psfDesktop);
151 /* copied from shell32 to avoid linking to it */
152 static BOOL COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPCITEMIDLIST pidl)
154 TRACE("dest=%p len=0x%x strret=%p pidl=%p stub\n",dest,len,src,pidl);
159 lstrcpynW(dest, src->u.pOleStr, len);
160 COMDLG32_SHFree(src->u.pOleStr);
164 if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ))
165 ((LPWSTR)dest)[len-1] = 0;
171 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
173 ((LPWSTR)dest)[len-1] = 0;
178 FIXME("unknown type!\n");
180 { *(LPWSTR)dest = '\0';
191 /**************************************************************************
192 * IShellBrowserImpl_Construct
194 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
196 IShellBrowserImpl *sb;
197 FileOpenDlgInfos *fodInfos = GetPropA(hwndOwner,FileOpenDlgInfosStr);
199 sb = COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
201 /* Initialisation of the member variables */
203 sb->hwndOwner = hwndOwner;
205 /* Initialisation of the vTables */
206 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
207 sb->lpVtblCommDlgBrowser = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
208 sb->lpVtblServiceProvider = &IShellBrowserImpl_IServiceProvider_Vtbl;
209 SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
210 &fodInfos->ShellInfos.pidlAbsCurrent);
214 return (IShellBrowser *) sb;
217 /***************************************************************************
218 * IShellBrowserImpl_QueryInterface
220 static HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
224 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
226 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
230 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
233 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
237 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
241 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
242 { *ppvObj = &(This->lpVtblCommDlgBrowser);
245 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
246 { *ppvObj = &(This->lpVtblServiceProvider);
250 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
253 FIXME("Unknown interface requested\n");
254 return E_NOINTERFACE;
257 /**************************************************************************
258 * IShellBrowser::AddRef
260 static ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
262 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
263 ULONG ref = InterlockedIncrement(&This->ref);
265 TRACE("(%p,%u)\n", This, ref - 1);
270 /**************************************************************************
271 * IShellBrowserImpl_Release
273 static ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
275 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
276 ULONG ref = InterlockedDecrement(&This->ref);
278 TRACE("(%p,%u)\n", This, ref + 1);
282 COMDLG32_SHFree(This);
283 TRACE("-- destroyed\n");
293 /**************************************************************************
294 * IShellBrowserImpl_GetWindow (IOleWindow)
296 * Inherited from IOleWindow::GetWindow
298 * See Windows documentation for more details
300 * Note : We will never be window less in the File Open dialog
303 static HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
306 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
308 TRACE("(%p)\n", This);
313 *phwnd = This->hwndOwner;
315 return (*phwnd) ? S_OK : E_UNEXPECTED;
319 /**************************************************************************
320 * IShellBrowserImpl_ContextSensitiveHelp
322 static HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
325 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
327 TRACE("(%p)\n", This);
329 /* Feature not implemented */
337 /**************************************************************************
338 * IShellBrowserImpl_BrowseObject
340 * See Windows documentation on IShellBrowser::BrowseObject for more details
342 * This function will override user specified flags and will always
343 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
345 static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
350 IShellFolder *psfTmp;
352 FileOpenDlgInfos *fodInfos;
353 LPITEMIDLIST pidlTmp;
359 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
361 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This, pidl, wFlags);
362 COMDLG32_DumpSBSPFlags(wFlags);
364 fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
366 /* Format the pidl according to its parameter's category */
367 if(wFlags & SBSP_RELATIVE)
370 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
371 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
372 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
374 ERR("bind to object failed\n");
377 /* create an absolute pidl */
378 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent, pidl);
380 else if(wFlags & SBSP_PARENT)
382 /* Browse the parent folder (ignores the pidl) */
383 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
384 psfTmp = GetShellFolderFromPidl(pidlTmp);
387 else /* SBSP_ABSOLUTE is 0x0000 */
389 /* An absolute pidl (relative from the desktop) */
390 pidlTmp = COMDLG32_PIDL_ILClone(pidl);
391 psfTmp = GetShellFolderFromPidl(pidlTmp);
396 ERR("could not browse to folder\n");
400 /* If the pidl to browse to is equal to the actual pidl ...
401 do nothing and pretend you did it*/
402 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
404 IShellFolder_Release(psfTmp);
405 COMDLG32_SHFree(pidlTmp);
406 TRACE("keep current folder\n");
410 /* Release the current DataObject */
411 if (fodInfos->Shell.FOIDataObject)
413 IDataObject_Release(fodInfos->Shell.FOIDataObject);
414 fodInfos->Shell.FOIDataObject = NULL;
417 /* Create the associated view */
418 TRACE("create view object\n");
419 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
420 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
422 /* Check if listview has focus */
423 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
425 /* Get the foldersettings from the old view */
426 if(fodInfos->Shell.FOIShellView)
427 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
429 /* Release the old fodInfos->Shell.FOIShellView and update its value.
430 We have to update this early since ShellView_CreateViewWindow of native
431 shell32 calls OnStateChange and needs the correct view here.*/
432 if(fodInfos->Shell.FOIShellView)
434 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
435 IShellView_Release(fodInfos->Shell.FOIShellView);
437 fodInfos->Shell.FOIShellView = psvTmp;
439 /* Release old FOIShellFolder and update its value */
440 if (fodInfos->Shell.FOIShellFolder)
441 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
442 fodInfos->Shell.FOIShellFolder = psfTmp;
444 /* Release old pidlAbsCurrent and update its value */
445 COMDLG32_SHFree(fodInfos->ShellInfos.pidlAbsCurrent);
446 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
448 COMDLG32_UpdateCurrentDir(fodInfos);
450 GetWindowRect(GetDlgItem(This->hwndOwner, IDC_SHELLSTATIC), &rectView);
451 MapWindowPoints(0, This->hwndOwner, (LPPOINT)&rectView, 2);
453 /* Create the window */
454 TRACE("create view window\n");
455 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
456 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
457 &rectView, &hwndView))) goto error;
459 fodInfos->ShellInfos.hwndView = hwndView;
461 /* Set view window control id to 5002 */
462 SetWindowLongPtrW(hwndView, GWLP_ID, lst2);
464 /* Select the new folder in the Look In combo box of the Open file dialog */
465 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
467 /* changes the tab order of the ListView to reflect the window's File Dialog */
468 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
469 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
471 /* Since we destroyed the old view if it had focus set focus to the newly created view */
473 SetFocus(fodInfos->ShellInfos.hwndView);
477 ERR("Failed with error 0x%08x\n", hRes);
481 /**************************************************************************
482 * IShellBrowserImpl_EnableModelessSB
484 static HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
488 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
490 TRACE("(%p)\n", This);
492 /* Feature not implemented */
496 /**************************************************************************
497 * IShellBrowserImpl_GetControlWindow
499 static HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
504 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
506 TRACE("(%p)\n", This);
508 /* Feature not implemented */
512 /**************************************************************************
513 * IShellBrowserImpl_GetViewStateStream
515 static HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
520 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
522 FIXME("(%p 0x%08x %p)\n", This, grfMode, ppStrm);
524 /* Feature not implemented */
528 /**************************************************************************
529 * IShellBrowserImpl_InsertMenusSB
531 static HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
533 LPOLEMENUGROUPWIDTHS lpMenuWidths)
536 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
538 TRACE("(%p)\n", This);
540 /* Feature not implemented */
544 /**************************************************************************
545 * IShellBrowserImpl_OnViewWindowActive
547 static HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
551 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
553 TRACE("(%p)\n", This);
555 /* Feature not implemented */
559 /**************************************************************************
560 * IShellBrowserImpl_QueryActiveShellView
562 static HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
566 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
568 FileOpenDlgInfos *fodInfos;
570 TRACE("(%p)\n", This);
572 fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
574 if(!(*ppshv = fodInfos->Shell.FOIShellView))
578 IShellView_AddRef(fodInfos->Shell.FOIShellView);
582 /**************************************************************************
583 * IShellBrowserImpl_RemoveMenusSB
585 static HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
589 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
591 TRACE("(%p)\n", This);
593 /* Feature not implemented */
597 /**************************************************************************
598 * IShellBrowserImpl_SendControlMsg
600 static HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
608 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
611 TRACE("(%p)->(0x%08x 0x%08x 0x%08lx 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
616 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
619 FIXME("ctrl id: %x\n", id);
622 if (pret) *pret = lres;
626 /**************************************************************************
627 * IShellBrowserImpl_SetMenuSB
629 static HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
631 HOLEMENU holemenuReserved,
632 HWND hwndActiveObject)
635 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
637 TRACE("(%p)\n", This);
639 /* Feature not implemented */
643 /**************************************************************************
644 * IShellBrowserImpl_SetStatusTextSB
646 static HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
647 LPCOLESTR lpszStatusText)
650 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
652 TRACE("(%p)\n", This);
654 /* Feature not implemented */
658 /**************************************************************************
659 * IShellBrowserImpl_SetToolbarItems
661 static HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
662 LPTBBUTTON lpButtons,
667 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
669 TRACE("(%p)\n", This);
671 /* Feature not implemented */
675 /**************************************************************************
676 * IShellBrowserImpl_TranslateAcceleratorSB
678 static HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
683 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
685 TRACE("(%p)\n", This);
687 /* Feature not implemented */
691 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl =
694 IShellBrowserImpl_QueryInterface,
695 IShellBrowserImpl_AddRef,
696 IShellBrowserImpl_Release,
698 IShellBrowserImpl_GetWindow,
699 IShellBrowserImpl_ContextSensitiveHelp,
701 IShellBrowserImpl_InsertMenusSB,
702 IShellBrowserImpl_SetMenuSB,
703 IShellBrowserImpl_RemoveMenusSB,
704 IShellBrowserImpl_SetStatusTextSB,
705 IShellBrowserImpl_EnableModelessSB,
706 IShellBrowserImpl_TranslateAcceleratorSB,
707 IShellBrowserImpl_BrowseObject,
708 IShellBrowserImpl_GetViewStateStream,
709 IShellBrowserImpl_GetControlWindow,
710 IShellBrowserImpl_SendControlMsg,
711 IShellBrowserImpl_QueryActiveShellView,
712 IShellBrowserImpl_OnViewWindowActive,
713 IShellBrowserImpl_SetToolbarItems
722 /***************************************************************************
723 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
725 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
726 ICommDlgBrowser *iface,
730 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
732 TRACE("(%p)\n", This);
734 return IShellBrowserImpl_QueryInterface((IShellBrowser *)This,riid,ppvObj);
737 /**************************************************************************
738 * IShellBrowserImpl_ICommDlgBrowser_AddRef
740 static ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
742 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
744 TRACE("(%p)\n", This);
746 return IShellBrowserImpl_AddRef((IShellBrowser *)This);
749 /**************************************************************************
750 * IShellBrowserImpl_ICommDlgBrowser_Release
752 static ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
754 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
756 TRACE("(%p)\n", This);
758 return IShellBrowserImpl_Release((IShellBrowser *)This);
761 /**************************************************************************
762 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
764 * Called when a user double-clicks in the view or presses the ENTER key
766 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
770 FileOpenDlgInfos *fodInfos;
772 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
774 TRACE("(%p)\n", This);
776 fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
778 /* If the selected object is not a folder, send an IDOK command to parent window */
779 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
783 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
784 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, (LPCITEMIDLIST *)&pidl, &ulAttr);
785 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
787 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
788 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_FOLDERCHANGE);
792 /* Tell the dialog that the user selected a file */
793 PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
797 /* Free memory used by pidl */
798 COMDLG32_SHFree(pidl);
806 /**************************************************************************
807 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
809 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
814 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
816 TRACE("(%p shv=%p)\n", This, ppshv);
820 case CDBOSC_SETFOCUS:
821 /* FIXME: Reset the default button.
822 This should be taken care of by defdlg. If control
823 other than button receives focus the default button
824 should be restored. */
825 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
828 case CDBOSC_KILLFOCUS:
830 FileOpenDlgInfos *fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
831 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
834 LoadStringW(COMDLG32_hInstance, IDS_SAVE_BUTTON, szSave, sizeof(szSave)/sizeof(WCHAR));
835 SetDlgItemTextW(fodInfos->ShellInfos.hwndOwner, IDOK, szSave);
839 case CDBOSC_SELCHANGE:
840 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
849 /* send_includeitem_notification
851 * Sends a CDN_INCLUDEITEM notification for "pidl" to hwndParentDlg
853 static LRESULT send_includeitem_notification(HWND hwndParentDlg, LPCITEMIDLIST pidl)
855 LRESULT hook_result = 0;
856 FileOpenDlgInfos *fodInfos = GetPropA(hwndParentDlg, FileOpenDlgInfosStr);
858 if(!fodInfos) return 0;
860 if(fodInfos->DlgInfos.hwndCustomDlg)
862 TRACE("call notify CDN_INCLUDEITEM for pidl=%p\n", pidl);
863 if(fodInfos->unicode)
865 OFNOTIFYEXW ofnNotify;
866 ofnNotify.psf = fodInfos->Shell.FOIShellFolder;
867 ofnNotify.pidl = (LPITEMIDLIST)pidl;
868 ofnNotify.hdr.hwndFrom = hwndParentDlg;
869 ofnNotify.hdr.idFrom = 0;
870 ofnNotify.hdr.code = CDN_INCLUDEITEM;
871 ofnNotify.lpOFN = fodInfos->ofnInfos;
872 hook_result = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg, WM_NOTIFY, 0, (LPARAM)&ofnNotify);
876 OFNOTIFYEXA ofnNotify;
877 ofnNotify.psf = fodInfos->Shell.FOIShellFolder;
878 ofnNotify.pidl = (LPITEMIDLIST)pidl;
879 ofnNotify.hdr.hwndFrom = hwndParentDlg;
880 ofnNotify.hdr.idFrom = 0;
881 ofnNotify.hdr.code = CDN_INCLUDEITEM;
882 ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;
883 hook_result = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg, WM_NOTIFY, 0, (LPARAM)&ofnNotify);
886 TRACE("Retval: 0x%08lx\n", hook_result);
890 /**************************************************************************
891 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
893 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
897 FileOpenDlgInfos *fodInfos;
900 WCHAR szPathW[MAX_PATH];
902 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
904 TRACE("(%p)\n", This);
906 fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
908 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
909 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
911 if( (ulAttr & SFGAO_HIDDEN) || /* hidden */
912 !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
915 /* always include directories and links */
916 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
919 /* if the application takes care of including the item we are done */
920 if(fodInfos->ofnInfos->Flags & OFN_ENABLEINCLUDENOTIFY &&
921 send_includeitem_notification(This->hwndOwner, pidl))
924 /* Check if there is a mask to apply if not */
925 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
928 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
930 if (COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl))
932 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
940 /**************************************************************************
941 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
943 static HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, const IShellView *ppshv)
945 FileOpenDlgInfos *fodInfos;
947 IShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
949 fodInfos = GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
950 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
952 /* release old selections */
953 if (fodInfos->Shell.FOIDataObject)
954 IDataObject_Release(fodInfos->Shell.FOIDataObject);
956 /* get a new DataObject from the ShellView */
957 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
958 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
961 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
963 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
967 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl =
970 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
971 IShellBrowserImpl_ICommDlgBrowser_AddRef,
972 IShellBrowserImpl_ICommDlgBrowser_Release,
973 /* ICommDlgBrowser */
974 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
975 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
976 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
986 /***************************************************************************
987 * IShellBrowserImpl_IServiceProvider_QueryInterface
989 static HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
990 IServiceProvider *iface,
994 IShellBrowserImpl *This = impl_from_IServiceProvider(iface);
996 FIXME("(%p)\n", This);
998 return IShellBrowserImpl_QueryInterface((IShellBrowser *)This,riid,ppvObj);
1001 /**************************************************************************
1002 * IShellBrowserImpl_IServiceProvider_AddRef
1004 static ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface)
1006 IShellBrowserImpl *This = impl_from_IServiceProvider(iface);
1008 FIXME("(%p)\n", This);
1010 return IShellBrowserImpl_AddRef((IShellBrowser *)This);
1013 /**************************************************************************
1014 * IShellBrowserImpl_IServiceProvider_Release
1016 static ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface)
1018 IShellBrowserImpl *This = impl_from_IServiceProvider(iface);
1020 FIXME("(%p)\n", This);
1022 return IShellBrowserImpl_Release((IShellBrowser *)This);
1025 /**************************************************************************
1026 * IShellBrowserImpl_IServiceProvider_Release
1029 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
1030 * riid = IShellBrowser) to call SendControlMsg ().
1036 static HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
1037 IServiceProvider * iface,
1038 REFGUID guidService,
1042 IShellBrowserImpl *This = impl_from_IServiceProvider(iface);
1044 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
1047 if(guidService && IsEqualIID(guidService, &SID_STopLevelBrowser))
1049 return IShellBrowserImpl_QueryInterface((IShellBrowser *)This,riid,ppv);
1051 FIXME("(%p) unknown interface requested\n", This);
1052 return E_NOINTERFACE;
1056 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl =
1059 IShellBrowserImpl_IServiceProvider_QueryInterface,
1060 IShellBrowserImpl_IServiceProvider_AddRef,
1061 IShellBrowserImpl_IServiceProvider_Release,
1062 /* IServiceProvider */
1063 IShellBrowserImpl_IServiceProvider_QueryService