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
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
35 #define NO_SHLWAPI_STREAM
37 #include "filedlgbrowser.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
48 ICOM_VTABLE(IShellBrowser) * lpVtbl;
49 ICOM_VTABLE(ICommDlgBrowser) * lpVtblCommDlgBrowser;
50 ICOM_VTABLE(IServiceProvider)* lpVtblServiceProvider;
51 DWORD ref; /* Reference counter */
52 HWND hwndOwner; /* Owner dialog of the interface */
56 /**************************************************************************
59 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl;
60 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl;
61 static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl;
63 /**************************************************************************
67 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
69 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
72 /**************************************************************************
75 extern const char *FileOpenDlgInfosStr;
77 extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
78 extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
79 extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
80 extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
81 extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
83 extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
84 LPITEMIDLIST pidlCurrentFolder,
87 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
88 extern BOOL FILEDLG95_OnOpen(HWND hwnd);
89 extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
96 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
98 char lpstrPath[MAX_PATH];
99 if(SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath)) {
100 SetCurrentDirectoryA(lpstrPath);
101 TRACE("new current folder %s\n", lpstrPath);
105 /* copied from shell32 to avoid linking to it */
106 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPCITEMIDLIST pidl)
108 TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest,len,src,pidl);
113 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
114 COMDLG32_SHFree(src->u.pOleStr);
118 if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
119 ((LPWSTR)dest)[len-1] = 0;
125 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
126 -1, (LPWSTR)dest, len ))
127 ((LPWSTR)dest)[len-1] = 0;
132 FIXME("unknown type!\n");
134 { *(LPWSTR)dest = '\0';
145 /**************************************************************************
146 * IShellBrowserImpl_Construct
148 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
150 IShellBrowserImpl *sb;
151 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
153 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
155 /* Initialisation of the member variables */
157 sb->hwndOwner = hwndOwner;
159 /* Initialisation of the vTables */
160 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
161 sb->lpVtblCommDlgBrowser = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
162 sb->lpVtblServiceProvider = &IShellBrowserImpl_IServiceProvider_Vtbl;
163 SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
164 &fodInfos->ShellInfos.pidlAbsCurrent);
168 return (IShellBrowser *) sb;
171 /***************************************************************************
172 * IShellBrowserImpl_QueryInterface
174 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
178 ICOM_THIS(IShellBrowserImpl, iface);
180 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
184 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
187 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
188 { *ppvObj = (IOleWindow*)This;
191 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
192 { *ppvObj = (IShellBrowser*)This;
195 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
196 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblCommDlgBrowser);
199 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
200 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblServiceProvider);
204 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
207 FIXME("Unknown interface requested\n");
208 return E_NOINTERFACE;
211 /**************************************************************************
212 * IShellBrowser::AddRef
214 ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
216 ICOM_THIS(IShellBrowserImpl, iface);
218 TRACE("(%p,%lu)\n", This, This->ref);
220 return ++(This->ref);
223 /**************************************************************************
224 * IShellBrowserImpl_Release
226 ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
228 ICOM_THIS(IShellBrowserImpl, iface);
230 TRACE("(%p,%lu)\n", This, This->ref);
234 COMDLG32_SHFree(This);
235 TRACE("-- destroyed\n");
245 /**************************************************************************
246 * IShellBrowserImpl_GetWindow (IOleWindow)
248 * Inherited from IOleWindow::GetWindow
250 * See Windows documentation for more details
252 * Note : We will never be window less in the File Open dialog
255 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
258 ICOM_THIS(IShellBrowserImpl, iface);
260 TRACE("(%p)\n", This);
265 *phwnd = This->hwndOwner;
267 return (*phwnd) ? S_OK : E_UNEXPECTED;
271 /**************************************************************************
272 * IShellBrowserImpl_ContextSensitiveHelp
274 HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
277 ICOM_THIS(IShellBrowserImpl, iface);
279 TRACE("(%p)\n", This);
281 /* Feature not implemented */
289 /**************************************************************************
290 * IShellBrowserImpl_BrowseObject
292 * See Windows documentation on IShellBrowser::BrowseObject for more details
294 * This function will override user specified flags and will always
295 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
297 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
302 IShellFolder *psfTmp;
304 FileOpenDlgInfos *fodInfos;
305 LPITEMIDLIST pidlTmp;
311 ICOM_THIS(IShellBrowserImpl, iface);
313 TRACE("(%p)(pidl=%p,flags=0x%08x(%s))\n", This, pidl, wFlags,
314 (wFlags & SBSP_RELATIVE) ? "SBSP_RELATIVE" :
315 (wFlags & SBSP_PARENT) ? "SBSP_PARENT" :
316 (wFlags & SBSP_ABSOLUTE) ? "SBSP_ABSOLUTE" : "SBPS_????");
318 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
320 /* Format the pidl according to its parameter's category */
321 if(wFlags & SBSP_RELATIVE)
324 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
325 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
326 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
328 ERR("bind to object failed\n");
331 /* create an absolute pidl */
332 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
335 else if(wFlags & SBSP_PARENT)
337 /* Browse the parent folder (ignores the pidl) */
338 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
339 psfTmp = GetShellFolderFromPidl(pidlTmp);
342 else /* SBSP_ABSOLUTE is 0x0000 */
344 /* An absolute pidl (relative from the desktop) */
345 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
346 psfTmp = GetShellFolderFromPidl(pidlTmp);
351 ERR("could not browse to folder\n");
355 /* If the pidl to browse to is equal to the actual pidl ...
356 do nothing and pretend you did it*/
357 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
359 IShellFolder_Release(psfTmp);
360 COMDLG32_SHFree(pidlTmp);
361 TRACE("keep current folder\n");
365 /* Release the current DataObject */
366 if (fodInfos->Shell.FOIDataObject)
368 IDataObject_Release(fodInfos->Shell.FOIDataObject);
369 fodInfos->Shell.FOIDataObject = NULL;
372 /* Create the associated view */
373 TRACE("create view object\n");
374 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
375 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
377 /* Check if listview has focus */
378 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
380 /* Get the foldersettings from the old view */
381 if(fodInfos->Shell.FOIShellView)
382 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
384 /* Release the old fodInfos->Shell.FOIShellView and update its value.
385 We have to update this early since ShellView_CreateViewWindow of native
386 shell32 calls OnStateChange and needs the correct view here.*/
387 if(fodInfos->Shell.FOIShellView)
389 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
390 IShellView_Release(fodInfos->Shell.FOIShellView);
392 fodInfos->Shell.FOIShellView = psvTmp;
394 /* Release old FOIShellFolder and update its value */
395 if (fodInfos->Shell.FOIShellFolder)
396 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
397 fodInfos->Shell.FOIShellFolder = psfTmp;
399 /* Release old pidlAbsCurrent and update its value */
400 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
401 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
403 COMDLG32_UpdateCurrentDir(fodInfos);
405 GetWindowRect(GetDlgItem(This->hwndOwner, IDC_SHELLSTATIC), &rectView);
406 MapWindowPoints(0, This->hwndOwner, (LPPOINT)&rectView, 2);
408 /* Create the window */
409 TRACE("create view window\n");
410 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
411 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
412 &rectView, &hwndView))) goto error;
414 fodInfos->ShellInfos.hwndView = hwndView;
416 /* Select the new folder in the Look In combo box of the Open file dialog */
417 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
419 /* changes the tab order of the ListView to reflect the window's File Dialog */
420 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
421 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
423 /* Since we destroyed the old view if it had focus set focus to the newly created view */
425 SetFocus(fodInfos->ShellInfos.hwndView);
429 ERR("Failed with error 0x%08lx\n", hRes);
433 /**************************************************************************
434 * IShellBrowserImpl_EnableModelessSB
436 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
440 ICOM_THIS(IShellBrowserImpl, iface);
442 TRACE("(%p)\n", This);
444 /* Feature not implemented */
448 /**************************************************************************
449 * IShellBrowserImpl_GetControlWindow
451 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
456 ICOM_THIS(IShellBrowserImpl, iface);
458 TRACE("(%p)\n", This);
460 /* Feature not implemented */
463 /**************************************************************************
464 * IShellBrowserImpl_GetViewStateStream
466 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
471 ICOM_THIS(IShellBrowserImpl, iface);
473 FIXME("(%p 0x%08lx %p)\n", This, grfMode, ppStrm);
475 /* Feature not implemented */
478 /**************************************************************************
479 * IShellBrowserImpl_InsertMenusSB
481 HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
483 LPOLEMENUGROUPWIDTHS lpMenuWidths)
486 ICOM_THIS(IShellBrowserImpl, iface);
488 TRACE("(%p)\n", This);
490 /* Feature not implemented */
493 /**************************************************************************
494 * IShellBrowserImpl_OnViewWindowActive
496 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
500 ICOM_THIS(IShellBrowserImpl, iface);
502 TRACE("(%p)\n", This);
504 /* Feature not implemented */
507 /**************************************************************************
508 * IShellBrowserImpl_QueryActiveShellView
510 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
514 ICOM_THIS(IShellBrowserImpl, iface);
516 FileOpenDlgInfos *fodInfos;
518 TRACE("(%p)\n", This);
520 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
522 if(!(*ppshv = fodInfos->Shell.FOIShellView))
526 IShellView_AddRef(fodInfos->Shell.FOIShellView);
529 /**************************************************************************
530 * IShellBrowserImpl_RemoveMenusSB
532 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
536 ICOM_THIS(IShellBrowserImpl, iface);
538 TRACE("(%p)\n", This);
540 /* Feature not implemented */
543 /**************************************************************************
544 * IShellBrowserImpl_SendControlMsg
546 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
554 ICOM_THIS(IShellBrowserImpl, iface);
557 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
562 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
565 FIXME("ctrl id: %x\n", id);
568 if (pret) *pret = lres;
571 /**************************************************************************
572 * IShellBrowserImpl_SetMenuSB
574 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
576 HOLEMENU holemenuReserved,
577 HWND hwndActiveObject)
580 ICOM_THIS(IShellBrowserImpl, iface);
582 TRACE("(%p)\n", This);
584 /* Feature not implemented */
587 /**************************************************************************
588 * IShellBrowserImpl_SetStatusTextSB
590 HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
591 LPCOLESTR lpszStatusText)
594 ICOM_THIS(IShellBrowserImpl, iface);
596 TRACE("(%p)\n", This);
598 /* Feature not implemented */
601 /**************************************************************************
602 * IShellBrowserImpl_SetToolbarItems
604 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
605 LPTBBUTTON lpButtons,
610 ICOM_THIS(IShellBrowserImpl, iface);
612 TRACE("(%p)\n", This);
614 /* Feature not implemented */
617 /**************************************************************************
618 * IShellBrowserImpl_TranslateAcceleratorSB
620 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
625 ICOM_THIS(IShellBrowserImpl, iface);
627 TRACE("(%p)\n", This);
629 /* Feature not implemented */
633 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl =
635 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
637 IShellBrowserImpl_QueryInterface,
638 IShellBrowserImpl_AddRef,
639 IShellBrowserImpl_Release,
641 IShellBrowserImpl_GetWindow,
642 IShellBrowserImpl_ContextSensitiveHelp,
644 IShellBrowserImpl_InsertMenusSB,
645 IShellBrowserImpl_SetMenuSB,
646 IShellBrowserImpl_RemoveMenusSB,
647 IShellBrowserImpl_SetStatusTextSB,
648 IShellBrowserImpl_EnableModelessSB,
649 IShellBrowserImpl_TranslateAcceleratorSB,
650 IShellBrowserImpl_BrowseObject,
651 IShellBrowserImpl_GetViewStateStream,
652 IShellBrowserImpl_GetControlWindow,
653 IShellBrowserImpl_SendControlMsg,
654 IShellBrowserImpl_QueryActiveShellView,
655 IShellBrowserImpl_OnViewWindowActive,
656 IShellBrowserImpl_SetToolbarItems
665 /***************************************************************************
666 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
668 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
669 ICommDlgBrowser *iface,
673 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
675 TRACE("(%p)\n", This);
677 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
680 /**************************************************************************
681 * IShellBrowserImpl_ICommDlgBrowser_AddRef
683 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
685 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
687 TRACE("(%p)\n", This);
689 return IShellBrowserImpl_AddRef(This);
692 /**************************************************************************
693 * IShellBrowserImpl_ICommDlgBrowser_Release
695 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
697 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
699 TRACE("(%p)\n", This);
701 return IShellBrowserImpl_Release(This);
703 /**************************************************************************
704 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
706 * Called when a user double-clicks in the view or presses the ENTER key
708 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
712 FileOpenDlgInfos *fodInfos;
714 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
716 TRACE("(%p)\n", This);
718 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
720 /* If the selected object is not a folder, send a IDOK command to parent window */
721 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
725 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
726 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, (LPCITEMIDLIST *)&pidl, &ulAttr);
727 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
729 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
730 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_FOLDERCHANGE);
734 /* Tell the dialog that the user selected a file */
735 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
738 /* Free memory used by pidl */
739 COMDLG32_SHFree((LPVOID)pidl);
747 /**************************************************************************
748 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
750 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
755 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
757 TRACE("(%p shv=%p)\n", This, ppshv);
761 case CDBOSC_SETFOCUS:
762 /* FIXME: Reset the default button.
763 This should be taken care of by defdlg. If control
764 other than button receives focus the default button
765 should be restored. */
766 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
769 case CDBOSC_KILLFOCUS:
771 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
772 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
773 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
776 case CDBOSC_SELCHANGE:
777 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
786 /**************************************************************************
787 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
789 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
793 FileOpenDlgInfos *fodInfos;
796 WCHAR szPathW[MAX_PATH];
798 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
800 TRACE("(%p)\n", This);
802 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
804 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
805 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
807 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
808 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
811 /* always include directories and links */
812 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
815 /* Check if there is a mask to apply if not */
816 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
819 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
821 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
823 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
831 /**************************************************************************
832 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
834 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
836 FileOpenDlgInfos *fodInfos;
838 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
840 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
841 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
843 /* release old selections */
844 if (fodInfos->Shell.FOIDataObject)
845 IDataObject_Release(fodInfos->Shell.FOIDataObject);
847 /* get a new DataObject from the ShellView */
848 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
849 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
852 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
854 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
858 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl =
860 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
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 ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl =
950 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
952 IShellBrowserImpl_IServiceProvider_QueryInterface,
953 IShellBrowserImpl_IServiceProvider_AddRef,
954 IShellBrowserImpl_IServiceProvider_Release,
955 /* IServiceProvider */
956 IShellBrowserImpl_IServiceProvider_QueryService