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 const IShellBrowserVtbl *lpVtbl;
51 const ICommDlgBrowserVtbl *lpVtblCommDlgBrowser;
52 const IServiceProviderVtbl *lpVtblServiceProvider;
53 DWORD ref; /* Reference counter */
54 HWND hwndOwner; /* Owner dialog of the interface */
58 /**************************************************************************
61 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl;
62 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl;
63 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl;
65 /**************************************************************************
69 static HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
71 /**************************************************************************
74 extern const char *FileOpenDlgInfosStr;
76 extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
77 extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
78 extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
80 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
81 extern void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
88 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
89 static void COMDLG32_DumpSBSPFlags(UINT uflags)
91 if (TRACE_ON(commdlg))
98 #define FE(x) { x, #x}
99 /* SBSP_DEFBROWSER == 0 */
100 FE(SBSP_SAMEBROWSER),
103 /* SBSP_DEFMODE == 0 */
105 FE(SBSP_EXPLOREMODE),
107 FE(SBSP_NOTRANSFERHIST),
109 /* SBSP_ABSOLUTE == 0 */
112 FE(SBSP_NAVIGATEBACK),
113 FE(SBSP_NAVIGATEFORWARD),
114 FE(SBSP_ALLOW_AUTONAVIGATE),
116 FE(SBSP_NOAUTOSELECT),
117 FE(SBSP_WRITENOHISTORY),
120 FE(SBSP_INITIATEDBYHLINKFRAME),
123 DPRINTF("SBSP Flags: %08x =", uflags);
124 for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
125 if (flags[i].mask & uflags)
126 DPRINTF("%s ", flags[i].name);
131 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
133 LPSHELLFOLDER psfDesktop;
137 res = SHGetDesktopFolder(&psfDesktop);
141 res = IShellFolder_GetDisplayNameOf(psfDesktop, fodInfos->ShellInfos.pidlAbsCurrent,
142 SHGDN_FORPARSING, &strret);
143 if (SUCCEEDED(res)) {
144 WCHAR wszCurrentDir[MAX_PATH];
146 res = StrRetToBufW(&strret, fodInfos->ShellInfos.pidlAbsCurrent, wszCurrentDir, MAX_PATH);
148 SetCurrentDirectoryW(wszCurrentDir);
151 IShellFolder_Release(psfDesktop);
154 /* copied from shell32 to avoid linking to it */
155 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPCITEMIDLIST pidl)
157 TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest,len,src,pidl);
162 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
163 COMDLG32_SHFree(src->u.pOleStr);
167 if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
168 ((LPWSTR)dest)[len-1] = 0;
174 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
175 -1, (LPWSTR)dest, len ))
176 ((LPWSTR)dest)[len-1] = 0;
181 FIXME("unknown type!\n");
183 { *(LPWSTR)dest = '\0';
194 /**************************************************************************
195 * IShellBrowserImpl_Construct
197 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
199 IShellBrowserImpl *sb;
200 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
202 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
204 /* Initialisation of the member variables */
206 sb->hwndOwner = hwndOwner;
208 /* Initialisation of the vTables */
209 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
210 sb->lpVtblCommDlgBrowser = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
211 sb->lpVtblServiceProvider = &IShellBrowserImpl_IServiceProvider_Vtbl;
212 SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
213 &fodInfos->ShellInfos.pidlAbsCurrent);
217 return (IShellBrowser *) sb;
220 /***************************************************************************
221 * IShellBrowserImpl_QueryInterface
223 static HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
227 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
229 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
233 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
236 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
237 { *ppvObj = (IOleWindow*)This;
240 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
241 { *ppvObj = (IShellBrowser*)This;
244 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
245 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblCommDlgBrowser);
248 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
249 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblServiceProvider);
253 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
256 FIXME("Unknown interface requested\n");
257 return E_NOINTERFACE;
260 /**************************************************************************
261 * IShellBrowser::AddRef
263 static ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
265 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
266 ULONG ref = InterlockedIncrement(&This->ref);
268 TRACE("(%p,%lu)\n", This, ref - 1);
273 /**************************************************************************
274 * IShellBrowserImpl_Release
276 static ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
278 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
279 ULONG ref = InterlockedDecrement(&This->ref);
281 TRACE("(%p,%lu)\n", This, ref + 1);
285 COMDLG32_SHFree(This);
286 TRACE("-- destroyed\n");
296 /**************************************************************************
297 * IShellBrowserImpl_GetWindow (IOleWindow)
299 * Inherited from IOleWindow::GetWindow
301 * See Windows documentation for more details
303 * Note : We will never be window less in the File Open dialog
306 static HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
309 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
311 TRACE("(%p)\n", This);
316 *phwnd = This->hwndOwner;
318 return (*phwnd) ? S_OK : E_UNEXPECTED;
322 /**************************************************************************
323 * IShellBrowserImpl_ContextSensitiveHelp
325 static HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
328 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
330 TRACE("(%p)\n", This);
332 /* Feature not implemented */
340 /**************************************************************************
341 * IShellBrowserImpl_BrowseObject
343 * See Windows documentation on IShellBrowser::BrowseObject for more details
345 * This function will override user specified flags and will always
346 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
348 static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
353 IShellFolder *psfTmp;
355 FileOpenDlgInfos *fodInfos;
356 LPITEMIDLIST pidlTmp;
362 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
364 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This, pidl, wFlags);
365 COMDLG32_DumpSBSPFlags(wFlags);
367 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
369 /* Format the pidl according to its parameter's category */
370 if(wFlags & SBSP_RELATIVE)
373 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
374 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
375 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
377 ERR("bind to object failed\n");
380 /* create an absolute pidl */
381 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
384 else if(wFlags & SBSP_PARENT)
386 /* Browse the parent folder (ignores the pidl) */
387 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
388 psfTmp = GetShellFolderFromPidl(pidlTmp);
391 else /* SBSP_ABSOLUTE is 0x0000 */
393 /* An absolute pidl (relative from the desktop) */
394 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
395 psfTmp = GetShellFolderFromPidl(pidlTmp);
400 ERR("could not browse to folder\n");
404 /* If the pidl to browse to is equal to the actual pidl ...
405 do nothing and pretend you did it*/
406 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
408 IShellFolder_Release(psfTmp);
409 COMDLG32_SHFree(pidlTmp);
410 TRACE("keep current folder\n");
414 /* Release the current DataObject */
415 if (fodInfos->Shell.FOIDataObject)
417 IDataObject_Release(fodInfos->Shell.FOIDataObject);
418 fodInfos->Shell.FOIDataObject = NULL;
421 /* Create the associated view */
422 TRACE("create view object\n");
423 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
424 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
426 /* Check if listview has focus */
427 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
429 /* Get the foldersettings from the old view */
430 if(fodInfos->Shell.FOIShellView)
431 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
433 /* Release the old fodInfos->Shell.FOIShellView and update its value.
434 We have to update this early since ShellView_CreateViewWindow of native
435 shell32 calls OnStateChange and needs the correct view here.*/
436 if(fodInfos->Shell.FOIShellView)
438 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
439 IShellView_Release(fodInfos->Shell.FOIShellView);
441 fodInfos->Shell.FOIShellView = psvTmp;
443 /* Release old FOIShellFolder and update its value */
444 if (fodInfos->Shell.FOIShellFolder)
445 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
446 fodInfos->Shell.FOIShellFolder = psfTmp;
448 /* Release old pidlAbsCurrent and update its value */
449 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
450 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
452 COMDLG32_UpdateCurrentDir(fodInfos);
454 GetWindowRect(GetDlgItem(This->hwndOwner, IDC_SHELLSTATIC), &rectView);
455 MapWindowPoints(0, This->hwndOwner, (LPPOINT)&rectView, 2);
457 /* Create the window */
458 TRACE("create view window\n");
459 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
460 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
461 &rectView, &hwndView))) goto error;
463 fodInfos->ShellInfos.hwndView = hwndView;
465 /* Select the new folder in the Look In combo box of the Open file dialog */
466 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
468 /* changes the tab order of the ListView to reflect the window's File Dialog */
469 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
470 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
472 /* Since we destroyed the old view if it had focus set focus to the newly created view */
474 SetFocus(fodInfos->ShellInfos.hwndView);
478 ERR("Failed with error 0x%08lx\n", hRes);
482 /**************************************************************************
483 * IShellBrowserImpl_EnableModelessSB
485 static HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
489 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
491 TRACE("(%p)\n", This);
493 /* Feature not implemented */
497 /**************************************************************************
498 * IShellBrowserImpl_GetControlWindow
500 static HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
505 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
507 TRACE("(%p)\n", This);
509 /* Feature not implemented */
513 /**************************************************************************
514 * IShellBrowserImpl_GetViewStateStream
516 static HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
521 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
523 FIXME("(%p 0x%08lx %p)\n", This, grfMode, ppStrm);
525 /* Feature not implemented */
529 /**************************************************************************
530 * IShellBrowserImpl_InsertMenusSB
532 static HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
534 LPOLEMENUGROUPWIDTHS lpMenuWidths)
537 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
539 TRACE("(%p)\n", This);
541 /* Feature not implemented */
545 /**************************************************************************
546 * IShellBrowserImpl_OnViewWindowActive
548 static HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
552 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
554 TRACE("(%p)\n", This);
556 /* Feature not implemented */
560 /**************************************************************************
561 * IShellBrowserImpl_QueryActiveShellView
563 static HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
567 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
569 FileOpenDlgInfos *fodInfos;
571 TRACE("(%p)\n", This);
573 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
575 if(!(*ppshv = fodInfos->Shell.FOIShellView))
579 IShellView_AddRef(fodInfos->Shell.FOIShellView);
583 /**************************************************************************
584 * IShellBrowserImpl_RemoveMenusSB
586 static HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
590 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
592 TRACE("(%p)\n", This);
594 /* Feature not implemented */
598 /**************************************************************************
599 * IShellBrowserImpl_SendControlMsg
601 static HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
609 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
612 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
617 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
620 FIXME("ctrl id: %x\n", id);
623 if (pret) *pret = lres;
627 /**************************************************************************
628 * IShellBrowserImpl_SetMenuSB
630 static HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
632 HOLEMENU holemenuReserved,
633 HWND hwndActiveObject)
636 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
638 TRACE("(%p)\n", This);
640 /* Feature not implemented */
644 /**************************************************************************
645 * IShellBrowserImpl_SetStatusTextSB
647 static HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
648 LPCOLESTR lpszStatusText)
651 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
653 TRACE("(%p)\n", This);
655 /* Feature not implemented */
659 /**************************************************************************
660 * IShellBrowserImpl_SetToolbarItems
662 static HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
663 LPTBBUTTON lpButtons,
668 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
670 TRACE("(%p)\n", This);
672 /* Feature not implemented */
676 /**************************************************************************
677 * IShellBrowserImpl_TranslateAcceleratorSB
679 static HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
684 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
686 TRACE("(%p)\n", This);
688 /* Feature not implemented */
692 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl =
695 IShellBrowserImpl_QueryInterface,
696 IShellBrowserImpl_AddRef,
697 IShellBrowserImpl_Release,
699 IShellBrowserImpl_GetWindow,
700 IShellBrowserImpl_ContextSensitiveHelp,
702 IShellBrowserImpl_InsertMenusSB,
703 IShellBrowserImpl_SetMenuSB,
704 IShellBrowserImpl_RemoveMenusSB,
705 IShellBrowserImpl_SetStatusTextSB,
706 IShellBrowserImpl_EnableModelessSB,
707 IShellBrowserImpl_TranslateAcceleratorSB,
708 IShellBrowserImpl_BrowseObject,
709 IShellBrowserImpl_GetViewStateStream,
710 IShellBrowserImpl_GetControlWindow,
711 IShellBrowserImpl_SendControlMsg,
712 IShellBrowserImpl_QueryActiveShellView,
713 IShellBrowserImpl_OnViewWindowActive,
714 IShellBrowserImpl_SetToolbarItems
723 /***************************************************************************
724 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
726 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
727 ICommDlgBrowser *iface,
731 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
733 TRACE("(%p)\n", This);
735 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
738 /**************************************************************************
739 * IShellBrowserImpl_ICommDlgBrowser_AddRef
741 static ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
743 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
745 TRACE("(%p)\n", This);
747 return IShellBrowserImpl_AddRef(This);
750 /**************************************************************************
751 * IShellBrowserImpl_ICommDlgBrowser_Release
753 static ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
755 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
757 TRACE("(%p)\n", This);
759 return IShellBrowserImpl_Release(This);
762 /**************************************************************************
763 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
765 * Called when a user double-clicks in the view or presses the ENTER key
767 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
771 FileOpenDlgInfos *fodInfos;
773 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
775 TRACE("(%p)\n", This);
777 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
779 /* If the selected object is not a folder, send an IDOK command to parent window */
780 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
784 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
785 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, (LPCITEMIDLIST *)&pidl, &ulAttr);
786 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
788 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
789 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_FOLDERCHANGE);
793 /* Tell the dialog that the user selected a file */
794 PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
798 /* Free memory used by pidl */
799 COMDLG32_SHFree((LPVOID)pidl);
807 /**************************************************************************
808 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
810 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
815 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
817 TRACE("(%p shv=%p)\n", This, ppshv);
821 case CDBOSC_SETFOCUS:
822 /* FIXME: Reset the default button.
823 This should be taken care of by defdlg. If control
824 other than button receives focus the default button
825 should be restored. */
826 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
829 case CDBOSC_KILLFOCUS:
831 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
832 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
833 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
836 case CDBOSC_SELCHANGE:
837 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
846 /**************************************************************************
847 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
849 static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
853 FileOpenDlgInfos *fodInfos;
856 WCHAR szPathW[MAX_PATH];
858 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
860 TRACE("(%p)\n", This);
862 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
864 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
865 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
867 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
868 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
871 /* always include directories and links */
872 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
875 /* Check if there is a mask to apply if not */
876 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
879 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
881 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
883 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
891 /**************************************************************************
892 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
894 static HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
896 FileOpenDlgInfos *fodInfos;
898 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
900 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
901 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
903 /* release old selections */
904 if (fodInfos->Shell.FOIDataObject)
905 IDataObject_Release(fodInfos->Shell.FOIDataObject);
907 /* get a new DataObject from the ShellView */
908 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
909 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
912 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
914 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
918 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl =
921 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
922 IShellBrowserImpl_ICommDlgBrowser_AddRef,
923 IShellBrowserImpl_ICommDlgBrowser_Release,
924 /* ICommDlgBrowser */
925 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
926 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
927 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
937 /***************************************************************************
938 * IShellBrowserImpl_IServiceProvider_QueryInterface
940 static HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
941 IServiceProvider *iface,
945 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
947 FIXME("(%p)\n", This);
949 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
952 /**************************************************************************
953 * IShellBrowserImpl_IServiceProvider_AddRef
955 static ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface)
957 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
959 FIXME("(%p)\n", This);
961 return IShellBrowserImpl_AddRef(This);
964 /**************************************************************************
965 * IShellBrowserImpl_IServiceProvider_Release
967 static ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface)
969 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
971 FIXME("(%p)\n", This);
973 return IShellBrowserImpl_Release(This);
976 /**************************************************************************
977 * IShellBrowserImpl_IServiceProvider_Release
980 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
981 * riid = IShellBrowser) to call SendControlMsg ().
987 static HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
988 IServiceProvider * iface,
993 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
995 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
998 if(guidService && IsEqualIID(guidService, &SID_STopLevelBrowser))
1000 return IShellBrowserImpl_QueryInterface(This,riid,ppv);
1002 FIXME("(%p) unknown interface requested\n", This);
1003 return E_NOINTERFACE;
1007 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl =
1010 IShellBrowserImpl_IServiceProvider_QueryInterface,
1011 IShellBrowserImpl_IServiceProvider_AddRef,
1012 IShellBrowserImpl_IServiceProvider_Release,
1013 /* IServiceProvider */
1014 IShellBrowserImpl_IServiceProvider_QueryService