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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
34 #define NO_SHLWAPI_STREAM
36 #include "filedlgbrowser.h"
39 #include "wine/obj_serviceprovider.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
47 ICOM_VTABLE(IShellBrowser) * lpVtbl;
48 ICOM_VTABLE(ICommDlgBrowser) * lpVtblCommDlgBrowser;
49 ICOM_VTABLE(IServiceProvider)* lpVtblServiceProvider;
50 DWORD ref; /* Reference counter */
51 HWND hwndOwner; /* Owner dialog of the interface */
55 /**************************************************************************
58 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl;
59 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl;
60 static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl;
62 /**************************************************************************
66 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
68 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
71 /**************************************************************************
74 extern const char *FileOpenDlgInfosStr;
76 extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
77 extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
78 extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
79 extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
80 extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
82 extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
83 LPITEMIDLIST pidlCurrentFolder,
86 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
87 extern BOOL FILEDLG95_OnOpen(HWND hwnd);
88 extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
95 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
97 char lpstrPath[MAX_PATH];
98 if(SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath)) {
99 SetCurrentDirectoryA(lpstrPath);
100 TRACE("new current folder %s\n", lpstrPath);
104 /* copied from shell32 to avoid linking to it */
105 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
107 TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest,len,src,pidl);
112 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
113 COMDLG32_SHFree(src->u.pOleStr);
117 if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
118 ((LPWSTR)dest)[len-1] = 0;
124 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
125 -1, (LPWSTR)dest, len ))
126 ((LPWSTR)dest)[len-1] = 0;
131 FIXME("unknown type!\n");
133 { *(LPWSTR)dest = '\0';
144 /**************************************************************************
145 * IShellBrowserImpl_Construct
147 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
149 IShellBrowserImpl *sb;
150 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
152 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
154 /* Initialisation of the member variables */
156 sb->hwndOwner = hwndOwner;
158 /* Initialisation of the vTables */
159 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
160 sb->lpVtblCommDlgBrowser = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
161 sb->lpVtblServiceProvider = &IShellBrowserImpl_IServiceProvider_Vtbl;
162 SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
163 &fodInfos->ShellInfos.pidlAbsCurrent);
167 return (IShellBrowser *) sb;
170 /***************************************************************************
171 * IShellBrowserImpl_QueryInterface
173 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
177 ICOM_THIS(IShellBrowserImpl, iface);
179 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
183 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
186 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
187 { *ppvObj = (IOleWindow*)This;
190 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
191 { *ppvObj = (IShellBrowser*)This;
194 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
195 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblCommDlgBrowser);
198 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
199 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblServiceProvider);
203 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
206 FIXME("Unknown interface requested\n");
207 return E_NOINTERFACE;
210 /**************************************************************************
211 * IShellBrowser::AddRef
213 ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
215 ICOM_THIS(IShellBrowserImpl, iface);
217 TRACE("(%p,%lu)\n", This, This->ref);
219 return ++(This->ref);
222 /**************************************************************************
223 * IShellBrowserImpl_Release
225 ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
227 ICOM_THIS(IShellBrowserImpl, iface);
229 TRACE("(%p,%lu)\n", This, This->ref);
233 COMDLG32_SHFree(This);
234 TRACE("-- destroyed\n");
244 /**************************************************************************
245 * IShellBrowserImpl_GetWindow (IOleWindow)
247 * Inherited from IOleWindow::GetWindow
249 * See Windows documentation for more details
251 * Note : We will never be window less in the File Open dialog
254 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
257 ICOM_THIS(IShellBrowserImpl, iface);
259 TRACE("(%p)\n", This);
264 *phwnd = This->hwndOwner;
266 return (*phwnd) ? S_OK : E_UNEXPECTED;
270 /**************************************************************************
271 * IShellBrowserImpl_ContextSensitiveHelp
273 HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
276 ICOM_THIS(IShellBrowserImpl, iface);
278 TRACE("(%p)\n", This);
280 /* Feature not implemented */
288 /**************************************************************************
289 * IShellBrowserImpl_BrowseObject
291 * See Windows documentation on IShellBrowser::BrowseObject for more details
293 * This function will override user specified flags and will always
294 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
296 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
301 IShellFolder *psfTmp;
303 FileOpenDlgInfos *fodInfos;
304 LPITEMIDLIST pidlTmp;
310 ICOM_THIS(IShellBrowserImpl, iface);
312 TRACE("(%p)(pidl=%p,flags=0x%08x(%s))\n", This, pidl, wFlags,
313 (wFlags & SBSP_RELATIVE) ? "SBSP_RELATIVE" :
314 (wFlags & SBSP_PARENT) ? "SBSP_PARENT" :
315 (wFlags & SBSP_ABSOLUTE) ? "SBSP_ABSOLUTE" : "SBPS_????");
317 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
319 /* Format the pidl according to its parameter's category */
320 if(wFlags & SBSP_RELATIVE)
323 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
324 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
325 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
327 ERR("bind to object failed\n");
330 /* create an absolute pidl */
331 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
334 else if(wFlags & SBSP_PARENT)
336 /* Browse the parent folder (ignores the pidl) */
337 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
338 psfTmp = GetShellFolderFromPidl(pidlTmp);
341 else /* SBSP_ABSOLUTE is 0x0000 */
343 /* An absolute pidl (relative from the desktop) */
344 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
345 psfTmp = GetShellFolderFromPidl(pidlTmp);
350 ERR("could not browse to folder\n");
354 /* If the pidl to browse to is equal to the actual pidl ...
355 do nothing and pretend you did it*/
356 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
358 IShellFolder_Release(psfTmp);
359 COMDLG32_SHFree(pidlTmp);
360 TRACE("keep current folder\n");
364 /* Release the current DataObject */
365 if (fodInfos->Shell.FOIDataObject)
367 IDataObject_Release(fodInfos->Shell.FOIDataObject);
368 fodInfos->Shell.FOIDataObject = NULL;
371 /* Create the associated view */
372 TRACE("create view object\n");
373 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
374 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
376 /* Check if listview has focus */
377 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
379 /* Get the foldersettings from the old view */
380 if(fodInfos->Shell.FOIShellView)
381 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
383 /* Release the old fodInfos->Shell.FOIShellView and update its value.
384 We have to update this early since ShellView_CreateViewWindow of native
385 shell32 calls OnStateChange and needs the correct view here.*/
386 if(fodInfos->Shell.FOIShellView)
388 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
389 IShellView_Release(fodInfos->Shell.FOIShellView);
391 fodInfos->Shell.FOIShellView = psvTmp;
393 /* Release old FOIShellFolder and update its value */
394 if (fodInfos->Shell.FOIShellFolder)
395 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
396 fodInfos->Shell.FOIShellFolder = psfTmp;
398 /* Release old pidlAbsCurrent and update its value */
399 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
400 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
402 COMDLG32_UpdateCurrentDir(fodInfos);
404 GetWindowRect(GetDlgItem(This->hwndOwner, IDC_SHELLSTATIC), &rectView);
405 MapWindowPoints(0, This->hwndOwner, (LPPOINT)&rectView, 2);
407 /* Create the window */
408 TRACE("create view window\n");
409 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
410 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
411 &rectView, &hwndView))) goto error;
413 fodInfos->ShellInfos.hwndView = hwndView;
415 /* Select the new folder in the Look In combo box of the Open file dialog */
416 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
418 /* changes the tab order of the ListView to reflect the window's File Dialog */
419 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
420 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
422 /* Since we destroyed the old view if it had focus set focus to the newly created view */
424 SetFocus(fodInfos->ShellInfos.hwndView);
428 ERR("Failed with error 0x%08lx\n", hRes);
432 /**************************************************************************
433 * IShellBrowserImpl_EnableModelessSB
435 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
439 ICOM_THIS(IShellBrowserImpl, iface);
441 TRACE("(%p)\n", This);
443 /* Feature not implemented */
447 /**************************************************************************
448 * IShellBrowserImpl_GetControlWindow
450 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
455 ICOM_THIS(IShellBrowserImpl, iface);
457 TRACE("(%p)\n", This);
459 /* Feature not implemented */
462 /**************************************************************************
463 * IShellBrowserImpl_GetViewStateStream
465 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
470 ICOM_THIS(IShellBrowserImpl, iface);
472 FIXME("(%p 0x%08lx %p)\n", This, grfMode, ppStrm);
474 /* Feature not implemented */
477 /**************************************************************************
478 * IShellBrowserImpl_InsertMenusSB
480 HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
482 LPOLEMENUGROUPWIDTHS lpMenuWidths)
485 ICOM_THIS(IShellBrowserImpl, iface);
487 TRACE("(%p)\n", This);
489 /* Feature not implemented */
492 /**************************************************************************
493 * IShellBrowserImpl_OnViewWindowActive
495 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
499 ICOM_THIS(IShellBrowserImpl, iface);
501 TRACE("(%p)\n", This);
503 /* Feature not implemented */
506 /**************************************************************************
507 * IShellBrowserImpl_QueryActiveShellView
509 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
513 ICOM_THIS(IShellBrowserImpl, iface);
515 FileOpenDlgInfos *fodInfos;
517 TRACE("(%p)\n", This);
519 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
521 if(!(*ppshv = fodInfos->Shell.FOIShellView))
525 IShellView_AddRef(fodInfos->Shell.FOIShellView);
528 /**************************************************************************
529 * IShellBrowserImpl_RemoveMenusSB
531 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
535 ICOM_THIS(IShellBrowserImpl, iface);
537 TRACE("(%p)\n", This);
539 /* Feature not implemented */
542 /**************************************************************************
543 * IShellBrowserImpl_SendControlMsg
545 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
553 ICOM_THIS(IShellBrowserImpl, iface);
556 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
561 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
564 FIXME("ctrl id: %x\n", id);
567 if (pret) *pret = lres;
570 /**************************************************************************
571 * IShellBrowserImpl_SetMenuSB
573 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
575 HOLEMENU holemenuReserved,
576 HWND hwndActiveObject)
579 ICOM_THIS(IShellBrowserImpl, iface);
581 TRACE("(%p)\n", This);
583 /* Feature not implemented */
586 /**************************************************************************
587 * IShellBrowserImpl_SetStatusTextSB
589 HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
590 LPCOLESTR lpszStatusText)
593 ICOM_THIS(IShellBrowserImpl, iface);
595 TRACE("(%p)\n", This);
597 /* Feature not implemented */
600 /**************************************************************************
601 * IShellBrowserImpl_SetToolbarItems
603 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
604 LPTBBUTTON lpButtons,
609 ICOM_THIS(IShellBrowserImpl, iface);
611 TRACE("(%p)\n", This);
613 /* Feature not implemented */
616 /**************************************************************************
617 * IShellBrowserImpl_TranslateAcceleratorSB
619 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
624 ICOM_THIS(IShellBrowserImpl, iface);
626 TRACE("(%p)\n", This);
628 /* Feature not implemented */
632 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl =
634 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
636 IShellBrowserImpl_QueryInterface,
637 IShellBrowserImpl_AddRef,
638 IShellBrowserImpl_Release,
640 IShellBrowserImpl_GetWindow,
641 IShellBrowserImpl_ContextSensitiveHelp,
643 IShellBrowserImpl_InsertMenusSB,
644 IShellBrowserImpl_SetMenuSB,
645 IShellBrowserImpl_RemoveMenusSB,
646 IShellBrowserImpl_SetStatusTextSB,
647 IShellBrowserImpl_EnableModelessSB,
648 IShellBrowserImpl_TranslateAcceleratorSB,
649 IShellBrowserImpl_BrowseObject,
650 IShellBrowserImpl_GetViewStateStream,
651 IShellBrowserImpl_GetControlWindow,
652 IShellBrowserImpl_SendControlMsg,
653 IShellBrowserImpl_QueryActiveShellView,
654 IShellBrowserImpl_OnViewWindowActive,
655 IShellBrowserImpl_SetToolbarItems
664 /***************************************************************************
665 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
667 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
668 ICommDlgBrowser *iface,
672 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
674 TRACE("(%p)\n", This);
676 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
679 /**************************************************************************
680 * IShellBrowserImpl_ICommDlgBrowser_AddRef
682 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
684 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
686 TRACE("(%p)\n", This);
688 return IShellBrowserImpl_AddRef(This);
691 /**************************************************************************
692 * IShellBrowserImpl_ICommDlgBrowser_Release
694 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
696 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
698 TRACE("(%p)\n", This);
700 return IShellBrowserImpl_Release(This);
702 /**************************************************************************
703 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
705 * Called when a user double-clicks in the view or presses the ENTER key
707 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
711 FileOpenDlgInfos *fodInfos;
713 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
715 TRACE("(%p)\n", This);
717 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
719 /* If the selected object is not a folder, send a IDOK command to parent window */
720 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
724 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
725 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
726 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
728 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
729 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_FOLDERCHANGE);
733 /* Tell the dialog that the user selected a file */
734 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
737 /* Free memory used by pidl */
738 COMDLG32_SHFree((LPVOID)pidl);
746 /**************************************************************************
747 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
749 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
754 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
756 TRACE("(%p shv=%p)\n", This, ppshv);
760 case CDBOSC_SETFOCUS:
761 /* FIXME: Reset the default button.
762 This should be taken care of by defdlg. If control
763 other than button receives focus the default button
764 should be restored. */
765 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
768 case CDBOSC_KILLFOCUS:
770 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
771 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
772 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
775 case CDBOSC_SELCHANGE:
776 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
785 /**************************************************************************
786 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
788 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
792 FileOpenDlgInfos *fodInfos;
795 WCHAR szPathW[MAX_PATH];
797 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
799 TRACE("(%p)\n", This);
801 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
803 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
804 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
806 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
807 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
810 /* always include directories and links */
811 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
814 /* Check if there is a mask to apply if not */
815 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
818 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
820 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
822 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
830 /**************************************************************************
831 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
833 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
835 FileOpenDlgInfos *fodInfos;
837 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
839 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
840 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
842 /* release old selections */
843 if (fodInfos->Shell.FOIDataObject)
844 IDataObject_Release(fodInfos->Shell.FOIDataObject);
846 /* get a new DataObject from the ShellView */
847 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
848 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
851 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
853 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
857 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl =
859 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
861 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
862 IShellBrowserImpl_ICommDlgBrowser_AddRef,
863 IShellBrowserImpl_ICommDlgBrowser_Release,
864 /* ICommDlgBrowser */
865 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
866 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
867 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
877 /***************************************************************************
878 * IShellBrowserImpl_IServiceProvider_QueryInterface
880 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
881 IServiceProvider *iface,
885 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
887 FIXME("(%p)\n", This);
889 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
892 /**************************************************************************
893 * IShellBrowserImpl_IServiceProvider_AddRef
895 ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface)
897 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
899 FIXME("(%p)\n", This);
901 return IShellBrowserImpl_AddRef(This);
904 /**************************************************************************
905 * IShellBrowserImpl_IServiceProvider_Release
907 ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface)
909 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
911 FIXME("(%p)\n", This);
913 return IShellBrowserImpl_Release(This);
916 /**************************************************************************
917 * IShellBrowserImpl_IServiceProvider_Release
920 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
921 * riid = IShellBrowser) to call SendControlMsg ().
927 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
928 IServiceProvider * iface,
933 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
935 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
938 if(guidService && IsEqualIID(guidService, &SID_STopLevelBrowser))
940 return IShellBrowserImpl_QueryInterface(This,riid,ppv);
942 FIXME("(%p) unknown interface requested\n", This);
943 return E_NOINTERFACE;
947 static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl =
949 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
951 IShellBrowserImpl_IServiceProvider_QueryInterface,
952 IShellBrowserImpl_IServiceProvider_AddRef,
953 IShellBrowserImpl_IServiceProvider_Release,
954 /* IServiceProvider */
955 IShellBrowserImpl_IServiceProvider_QueryService