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
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 IShellBrowserVtbl * lpVtbl;
51 ICommDlgBrowserVtbl * lpVtblCommDlgBrowser;
52 IServiceProviderVtbl* lpVtblServiceProvider;
53 DWORD ref; /* Reference counter */
54 HWND hwndOwner; /* Owner dialog of the interface */
58 /**************************************************************************
61 static IShellBrowserVtbl IShellBrowserImpl_Vtbl;
62 static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl;
63 static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl;
65 /**************************************************************************
69 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
71 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
74 /**************************************************************************
77 extern const char *FileOpenDlgInfosStr;
79 extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
80 extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
81 extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
82 extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
83 extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
85 extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
86 LPITEMIDLIST pidlCurrentFolder,
89 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
90 extern BOOL FILEDLG95_OnOpen(HWND hwnd);
91 extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
98 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
100 char lpstrPath[MAX_PATH];
101 if(SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath)) {
102 SetCurrentDirectoryA(lpstrPath);
103 TRACE("new current folder %s\n", lpstrPath);
107 /* copied from shell32 to avoid linking to it */
108 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPCITEMIDLIST pidl)
110 TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest,len,src,pidl);
115 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
116 COMDLG32_SHFree(src->u.pOleStr);
120 if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
121 ((LPWSTR)dest)[len-1] = 0;
127 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
128 -1, (LPWSTR)dest, len ))
129 ((LPWSTR)dest)[len-1] = 0;
134 FIXME("unknown type!\n");
136 { *(LPWSTR)dest = '\0';
147 /**************************************************************************
148 * IShellBrowserImpl_Construct
150 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
152 IShellBrowserImpl *sb;
153 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
155 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
157 /* Initialisation of the member variables */
159 sb->hwndOwner = hwndOwner;
161 /* Initialisation of the vTables */
162 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
163 sb->lpVtblCommDlgBrowser = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
164 sb->lpVtblServiceProvider = &IShellBrowserImpl_IServiceProvider_Vtbl;
165 SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
166 &fodInfos->ShellInfos.pidlAbsCurrent);
170 return (IShellBrowser *) sb;
173 /***************************************************************************
174 * IShellBrowserImpl_QueryInterface
176 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
180 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
182 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
186 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
189 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
190 { *ppvObj = (IOleWindow*)This;
193 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
194 { *ppvObj = (IShellBrowser*)This;
197 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
198 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblCommDlgBrowser);
201 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
202 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblServiceProvider);
206 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
209 FIXME("Unknown interface requested\n");
210 return E_NOINTERFACE;
213 /**************************************************************************
214 * IShellBrowser::AddRef
216 ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
218 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
220 TRACE("(%p,%lu)\n", This, This->ref);
222 return ++(This->ref);
225 /**************************************************************************
226 * IShellBrowserImpl_Release
228 ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
230 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
232 TRACE("(%p,%lu)\n", This, This->ref);
236 COMDLG32_SHFree(This);
237 TRACE("-- destroyed\n");
247 /**************************************************************************
248 * IShellBrowserImpl_GetWindow (IOleWindow)
250 * Inherited from IOleWindow::GetWindow
252 * See Windows documentation for more details
254 * Note : We will never be window less in the File Open dialog
257 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
260 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
262 TRACE("(%p)\n", This);
267 *phwnd = This->hwndOwner;
269 return (*phwnd) ? S_OK : E_UNEXPECTED;
273 /**************************************************************************
274 * IShellBrowserImpl_ContextSensitiveHelp
276 HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
279 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
281 TRACE("(%p)\n", This);
283 /* Feature not implemented */
291 /**************************************************************************
292 * IShellBrowserImpl_BrowseObject
294 * See Windows documentation on IShellBrowser::BrowseObject for more details
296 * This function will override user specified flags and will always
297 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
299 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
304 IShellFolder *psfTmp;
306 FileOpenDlgInfos *fodInfos;
307 LPITEMIDLIST pidlTmp;
313 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
315 TRACE("(%p)(pidl=%p,flags=0x%08x(%s))\n", This, pidl, wFlags,
316 (wFlags & SBSP_RELATIVE) ? "SBSP_RELATIVE" :
317 (wFlags & SBSP_PARENT) ? "SBSP_PARENT" :
318 (wFlags & SBSP_ABSOLUTE) ? "SBSP_ABSOLUTE" : "SBPS_????");
320 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
322 /* Format the pidl according to its parameter's category */
323 if(wFlags & SBSP_RELATIVE)
326 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
327 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
328 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
330 ERR("bind to object failed\n");
333 /* create an absolute pidl */
334 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
337 else if(wFlags & SBSP_PARENT)
339 /* Browse the parent folder (ignores the pidl) */
340 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
341 psfTmp = GetShellFolderFromPidl(pidlTmp);
344 else /* SBSP_ABSOLUTE is 0x0000 */
346 /* An absolute pidl (relative from the desktop) */
347 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
348 psfTmp = GetShellFolderFromPidl(pidlTmp);
353 ERR("could not browse to folder\n");
357 /* If the pidl to browse to is equal to the actual pidl ...
358 do nothing and pretend you did it*/
359 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
361 IShellFolder_Release(psfTmp);
362 COMDLG32_SHFree(pidlTmp);
363 TRACE("keep current folder\n");
367 /* Release the current DataObject */
368 if (fodInfos->Shell.FOIDataObject)
370 IDataObject_Release(fodInfos->Shell.FOIDataObject);
371 fodInfos->Shell.FOIDataObject = NULL;
374 /* Create the associated view */
375 TRACE("create view object\n");
376 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
377 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
379 /* Check if listview has focus */
380 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
382 /* Get the foldersettings from the old view */
383 if(fodInfos->Shell.FOIShellView)
384 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
386 /* Release the old fodInfos->Shell.FOIShellView and update its value.
387 We have to update this early since ShellView_CreateViewWindow of native
388 shell32 calls OnStateChange and needs the correct view here.*/
389 if(fodInfos->Shell.FOIShellView)
391 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
392 IShellView_Release(fodInfos->Shell.FOIShellView);
394 fodInfos->Shell.FOIShellView = psvTmp;
396 /* Release old FOIShellFolder and update its value */
397 if (fodInfos->Shell.FOIShellFolder)
398 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
399 fodInfos->Shell.FOIShellFolder = psfTmp;
401 /* Release old pidlAbsCurrent and update its value */
402 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
403 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
405 COMDLG32_UpdateCurrentDir(fodInfos);
407 GetWindowRect(GetDlgItem(This->hwndOwner, IDC_SHELLSTATIC), &rectView);
408 MapWindowPoints(0, This->hwndOwner, (LPPOINT)&rectView, 2);
410 /* Create the window */
411 TRACE("create view window\n");
412 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
413 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
414 &rectView, &hwndView))) goto error;
416 fodInfos->ShellInfos.hwndView = hwndView;
418 /* Select the new folder in the Look In combo box of the Open file dialog */
419 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
421 /* changes the tab order of the ListView to reflect the window's File Dialog */
422 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
423 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
425 /* Since we destroyed the old view if it had focus set focus to the newly created view */
427 SetFocus(fodInfos->ShellInfos.hwndView);
431 ERR("Failed with error 0x%08lx\n", hRes);
435 /**************************************************************************
436 * IShellBrowserImpl_EnableModelessSB
438 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
442 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
444 TRACE("(%p)\n", This);
446 /* Feature not implemented */
450 /**************************************************************************
451 * IShellBrowserImpl_GetControlWindow
453 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
458 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
460 TRACE("(%p)\n", This);
462 /* Feature not implemented */
465 /**************************************************************************
466 * IShellBrowserImpl_GetViewStateStream
468 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
473 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
475 FIXME("(%p 0x%08lx %p)\n", This, grfMode, ppStrm);
477 /* Feature not implemented */
480 /**************************************************************************
481 * IShellBrowserImpl_InsertMenusSB
483 HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
485 LPOLEMENUGROUPWIDTHS lpMenuWidths)
488 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
490 TRACE("(%p)\n", This);
492 /* Feature not implemented */
495 /**************************************************************************
496 * IShellBrowserImpl_OnViewWindowActive
498 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
502 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
504 TRACE("(%p)\n", This);
506 /* Feature not implemented */
509 /**************************************************************************
510 * IShellBrowserImpl_QueryActiveShellView
512 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
516 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
518 FileOpenDlgInfos *fodInfos;
520 TRACE("(%p)\n", This);
522 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
524 if(!(*ppshv = fodInfos->Shell.FOIShellView))
528 IShellView_AddRef(fodInfos->Shell.FOIShellView);
531 /**************************************************************************
532 * IShellBrowserImpl_RemoveMenusSB
534 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
538 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
540 TRACE("(%p)\n", This);
542 /* Feature not implemented */
545 /**************************************************************************
546 * IShellBrowserImpl_SendControlMsg
548 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
556 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
559 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
564 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
567 FIXME("ctrl id: %x\n", id);
570 if (pret) *pret = lres;
573 /**************************************************************************
574 * IShellBrowserImpl_SetMenuSB
576 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
578 HOLEMENU holemenuReserved,
579 HWND hwndActiveObject)
582 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
584 TRACE("(%p)\n", This);
586 /* Feature not implemented */
589 /**************************************************************************
590 * IShellBrowserImpl_SetStatusTextSB
592 HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
593 LPCOLESTR lpszStatusText)
596 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
598 TRACE("(%p)\n", This);
600 /* Feature not implemented */
603 /**************************************************************************
604 * IShellBrowserImpl_SetToolbarItems
606 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
607 LPTBBUTTON lpButtons,
612 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
614 TRACE("(%p)\n", This);
616 /* Feature not implemented */
619 /**************************************************************************
620 * IShellBrowserImpl_TranslateAcceleratorSB
622 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
627 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
629 TRACE("(%p)\n", This);
631 /* Feature not implemented */
635 static IShellBrowserVtbl IShellBrowserImpl_Vtbl =
638 IShellBrowserImpl_QueryInterface,
639 IShellBrowserImpl_AddRef,
640 IShellBrowserImpl_Release,
642 IShellBrowserImpl_GetWindow,
643 IShellBrowserImpl_ContextSensitiveHelp,
645 IShellBrowserImpl_InsertMenusSB,
646 IShellBrowserImpl_SetMenuSB,
647 IShellBrowserImpl_RemoveMenusSB,
648 IShellBrowserImpl_SetStatusTextSB,
649 IShellBrowserImpl_EnableModelessSB,
650 IShellBrowserImpl_TranslateAcceleratorSB,
651 IShellBrowserImpl_BrowseObject,
652 IShellBrowserImpl_GetViewStateStream,
653 IShellBrowserImpl_GetControlWindow,
654 IShellBrowserImpl_SendControlMsg,
655 IShellBrowserImpl_QueryActiveShellView,
656 IShellBrowserImpl_OnViewWindowActive,
657 IShellBrowserImpl_SetToolbarItems
666 /***************************************************************************
667 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
669 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
670 ICommDlgBrowser *iface,
674 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
676 TRACE("(%p)\n", This);
678 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
681 /**************************************************************************
682 * IShellBrowserImpl_ICommDlgBrowser_AddRef
684 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
686 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
688 TRACE("(%p)\n", This);
690 return IShellBrowserImpl_AddRef(This);
693 /**************************************************************************
694 * IShellBrowserImpl_ICommDlgBrowser_Release
696 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
698 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
700 TRACE("(%p)\n", This);
702 return IShellBrowserImpl_Release(This);
704 /**************************************************************************
705 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
707 * Called when a user double-clicks in the view or presses the ENTER key
709 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
713 FileOpenDlgInfos *fodInfos;
715 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
717 TRACE("(%p)\n", This);
719 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
721 /* If the selected object is not a folder, send a IDOK command to parent window */
722 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
726 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
727 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, (LPCITEMIDLIST *)&pidl, &ulAttr);
728 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
730 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
731 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_FOLDERCHANGE);
735 /* Tell the dialog that the user selected a file */
736 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
739 /* Free memory used by pidl */
740 COMDLG32_SHFree((LPVOID)pidl);
748 /**************************************************************************
749 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
751 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
756 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
758 TRACE("(%p shv=%p)\n", This, ppshv);
762 case CDBOSC_SETFOCUS:
763 /* FIXME: Reset the default button.
764 This should be taken care of by defdlg. If control
765 other than button receives focus the default button
766 should be restored. */
767 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
770 case CDBOSC_KILLFOCUS:
772 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
773 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
774 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
777 case CDBOSC_SELCHANGE:
778 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
787 /**************************************************************************
788 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
790 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
794 FileOpenDlgInfos *fodInfos;
797 WCHAR szPathW[MAX_PATH];
799 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
801 TRACE("(%p)\n", This);
803 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
805 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
806 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
808 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
809 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
812 /* always include directories and links */
813 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
816 /* Check if there is a mask to apply if not */
817 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
820 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
822 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
824 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
832 /**************************************************************************
833 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
835 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
837 FileOpenDlgInfos *fodInfos;
839 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
841 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
842 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
844 /* release old selections */
845 if (fodInfos->Shell.FOIDataObject)
846 IDataObject_Release(fodInfos->Shell.FOIDataObject);
848 /* get a new DataObject from the ShellView */
849 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
850 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
853 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
855 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
859 static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl =
862 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
863 IShellBrowserImpl_ICommDlgBrowser_AddRef,
864 IShellBrowserImpl_ICommDlgBrowser_Release,
865 /* ICommDlgBrowser */
866 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
867 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
868 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
878 /***************************************************************************
879 * IShellBrowserImpl_IServiceProvider_QueryInterface
881 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
882 IServiceProvider *iface,
886 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
888 FIXME("(%p)\n", This);
890 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
893 /**************************************************************************
894 * IShellBrowserImpl_IServiceProvider_AddRef
896 ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface)
898 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
900 FIXME("(%p)\n", This);
902 return IShellBrowserImpl_AddRef(This);
905 /**************************************************************************
906 * IShellBrowserImpl_IServiceProvider_Release
908 ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface)
910 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
912 FIXME("(%p)\n", This);
914 return IShellBrowserImpl_Release(This);
917 /**************************************************************************
918 * IShellBrowserImpl_IServiceProvider_Release
921 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
922 * riid = IShellBrowser) to call SendControlMsg ().
928 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
929 IServiceProvider * iface,
934 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
936 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
939 if(guidService && IsEqualIID(guidService, &SID_STopLevelBrowser))
941 return IShellBrowserImpl_QueryInterface(This,riid,ppv);
943 FIXME("(%p) unknown interface requested\n", This);
944 return E_NOINTERFACE;
948 static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl =
951 IShellBrowserImpl_IServiceProvider_QueryInterface,
952 IShellBrowserImpl_IServiceProvider_AddRef,
953 IShellBrowserImpl_IServiceProvider_Release,
954 /* IServiceProvider */
955 IShellBrowserImpl_IServiceProvider_QueryService