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 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
71 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
74 /**************************************************************************
77 extern const char *FileOpenDlgInfosStr;
79 extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
80 extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
81 extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
83 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
84 extern void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
91 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
92 static void COMDLG32_DumpSBSPFlags(UINT uflags)
94 if (TRACE_ON(commdlg))
101 #define FE(x) { x, #x}
102 /* SBSP_DEFBROWSER == 0 */
103 FE(SBSP_SAMEBROWSER),
106 /* SBSP_DEFMODE == 0 */
108 FE(SBSP_EXPLOREMODE),
110 FE(SBSP_NOTRANSFERHIST),
112 /* SBSP_ABSOLUTE == 0 */
115 FE(SBSP_NAVIGATEBACK),
116 FE(SBSP_NAVIGATEFORWARD),
117 FE(SBSP_ALLOW_AUTONAVIGATE),
119 FE(SBSP_NOAUTOSELECT),
120 FE(SBSP_WRITENOHISTORY),
123 FE(SBSP_INITIATEDBYHLINKFRAME),
126 DPRINTF("SBSP Flags: %08x =", uflags);
127 for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
128 if (flags[i].mask & uflags)
129 DPRINTF("%s ", flags[i].name);
134 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
136 LPSHELLFOLDER psfDesktop;
140 res = SHGetDesktopFolder(&psfDesktop);
144 res = IShellFolder_GetDisplayNameOf(psfDesktop, fodInfos->ShellInfos.pidlAbsCurrent,
145 SHGDN_FORPARSING, &strret);
146 if (SUCCEEDED(res)) {
147 WCHAR wszCurrentDir[MAX_PATH];
149 res = StrRetToBufW(&strret, fodInfos->ShellInfos.pidlAbsCurrent, wszCurrentDir, MAX_PATH);
151 SetCurrentDirectoryW(wszCurrentDir);
154 IShellFolder_Release(psfDesktop);
157 /* copied from shell32 to avoid linking to it */
158 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPCITEMIDLIST pidl)
160 TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest,len,src,pidl);
165 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
166 COMDLG32_SHFree(src->u.pOleStr);
170 if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
171 ((LPWSTR)dest)[len-1] = 0;
177 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
178 -1, (LPWSTR)dest, len ))
179 ((LPWSTR)dest)[len-1] = 0;
184 FIXME("unknown type!\n");
186 { *(LPWSTR)dest = '\0';
197 /**************************************************************************
198 * IShellBrowserImpl_Construct
200 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
202 IShellBrowserImpl *sb;
203 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
205 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
207 /* Initialisation of the member variables */
209 sb->hwndOwner = hwndOwner;
211 /* Initialisation of the vTables */
212 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
213 sb->lpVtblCommDlgBrowser = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
214 sb->lpVtblServiceProvider = &IShellBrowserImpl_IServiceProvider_Vtbl;
215 SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
216 &fodInfos->ShellInfos.pidlAbsCurrent);
220 return (IShellBrowser *) sb;
223 /***************************************************************************
224 * IShellBrowserImpl_QueryInterface
226 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
230 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
232 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
236 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
239 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
240 { *ppvObj = (IOleWindow*)This;
243 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
244 { *ppvObj = (IShellBrowser*)This;
247 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
248 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblCommDlgBrowser);
251 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
252 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblServiceProvider);
256 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
259 FIXME("Unknown interface requested\n");
260 return E_NOINTERFACE;
263 /**************************************************************************
264 * IShellBrowser::AddRef
266 ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
268 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
269 ULONG ref = InterlockedIncrement(&This->ref);
271 TRACE("(%p,%lu)\n", This, ref - 1);
276 /**************************************************************************
277 * IShellBrowserImpl_Release
279 ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
281 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
282 ULONG ref = InterlockedDecrement(&This->ref);
284 TRACE("(%p,%lu)\n", This, ref + 1);
288 COMDLG32_SHFree(This);
289 TRACE("-- destroyed\n");
299 /**************************************************************************
300 * IShellBrowserImpl_GetWindow (IOleWindow)
302 * Inherited from IOleWindow::GetWindow
304 * See Windows documentation for more details
306 * Note : We will never be window less in the File Open dialog
309 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
312 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
314 TRACE("(%p)\n", This);
319 *phwnd = This->hwndOwner;
321 return (*phwnd) ? S_OK : E_UNEXPECTED;
325 /**************************************************************************
326 * IShellBrowserImpl_ContextSensitiveHelp
328 HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
331 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
333 TRACE("(%p)\n", This);
335 /* Feature not implemented */
343 /**************************************************************************
344 * IShellBrowserImpl_BrowseObject
346 * See Windows documentation on IShellBrowser::BrowseObject for more details
348 * This function will override user specified flags and will always
349 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
351 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
356 IShellFolder *psfTmp;
358 FileOpenDlgInfos *fodInfos;
359 LPITEMIDLIST pidlTmp;
365 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
367 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This, pidl, wFlags);
368 COMDLG32_DumpSBSPFlags(wFlags);
370 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
372 /* Format the pidl according to its parameter's category */
373 if(wFlags & SBSP_RELATIVE)
376 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
377 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
378 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
380 ERR("bind to object failed\n");
383 /* create an absolute pidl */
384 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
387 else if(wFlags & SBSP_PARENT)
389 /* Browse the parent folder (ignores the pidl) */
390 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
391 psfTmp = GetShellFolderFromPidl(pidlTmp);
394 else /* SBSP_ABSOLUTE is 0x0000 */
396 /* An absolute pidl (relative from the desktop) */
397 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
398 psfTmp = GetShellFolderFromPidl(pidlTmp);
403 ERR("could not browse to folder\n");
407 /* If the pidl to browse to is equal to the actual pidl ...
408 do nothing and pretend you did it*/
409 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
411 IShellFolder_Release(psfTmp);
412 COMDLG32_SHFree(pidlTmp);
413 TRACE("keep current folder\n");
417 /* Release the current DataObject */
418 if (fodInfos->Shell.FOIDataObject)
420 IDataObject_Release(fodInfos->Shell.FOIDataObject);
421 fodInfos->Shell.FOIDataObject = NULL;
424 /* Create the associated view */
425 TRACE("create view object\n");
426 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
427 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
429 /* Check if listview has focus */
430 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
432 /* Get the foldersettings from the old view */
433 if(fodInfos->Shell.FOIShellView)
434 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
436 /* Release the old fodInfos->Shell.FOIShellView and update its value.
437 We have to update this early since ShellView_CreateViewWindow of native
438 shell32 calls OnStateChange and needs the correct view here.*/
439 if(fodInfos->Shell.FOIShellView)
441 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
442 IShellView_Release(fodInfos->Shell.FOIShellView);
444 fodInfos->Shell.FOIShellView = psvTmp;
446 /* Release old FOIShellFolder and update its value */
447 if (fodInfos->Shell.FOIShellFolder)
448 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
449 fodInfos->Shell.FOIShellFolder = psfTmp;
451 /* Release old pidlAbsCurrent and update its value */
452 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
453 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
455 COMDLG32_UpdateCurrentDir(fodInfos);
457 GetWindowRect(GetDlgItem(This->hwndOwner, IDC_SHELLSTATIC), &rectView);
458 MapWindowPoints(0, This->hwndOwner, (LPPOINT)&rectView, 2);
460 /* Create the window */
461 TRACE("create view window\n");
462 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
463 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
464 &rectView, &hwndView))) goto error;
466 fodInfos->ShellInfos.hwndView = hwndView;
468 /* Select the new folder in the Look In combo box of the Open file dialog */
469 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
471 /* changes the tab order of the ListView to reflect the window's File Dialog */
472 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
473 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
475 /* Since we destroyed the old view if it had focus set focus to the newly created view */
477 SetFocus(fodInfos->ShellInfos.hwndView);
481 ERR("Failed with error 0x%08lx\n", hRes);
485 /**************************************************************************
486 * IShellBrowserImpl_EnableModelessSB
488 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
492 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
494 TRACE("(%p)\n", This);
496 /* Feature not implemented */
500 /**************************************************************************
501 * IShellBrowserImpl_GetControlWindow
503 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
508 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
510 TRACE("(%p)\n", This);
512 /* Feature not implemented */
515 /**************************************************************************
516 * IShellBrowserImpl_GetViewStateStream
518 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
523 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
525 FIXME("(%p 0x%08lx %p)\n", This, grfMode, ppStrm);
527 /* Feature not implemented */
530 /**************************************************************************
531 * IShellBrowserImpl_InsertMenusSB
533 HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
535 LPOLEMENUGROUPWIDTHS lpMenuWidths)
538 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
540 TRACE("(%p)\n", This);
542 /* Feature not implemented */
545 /**************************************************************************
546 * IShellBrowserImpl_OnViewWindowActive
548 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
552 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
554 TRACE("(%p)\n", This);
556 /* Feature not implemented */
559 /**************************************************************************
560 * IShellBrowserImpl_QueryActiveShellView
562 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
566 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
568 FileOpenDlgInfos *fodInfos;
570 TRACE("(%p)\n", This);
572 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
574 if(!(*ppshv = fodInfos->Shell.FOIShellView))
578 IShellView_AddRef(fodInfos->Shell.FOIShellView);
581 /**************************************************************************
582 * IShellBrowserImpl_RemoveMenusSB
584 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
588 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
590 TRACE("(%p)\n", This);
592 /* Feature not implemented */
595 /**************************************************************************
596 * IShellBrowserImpl_SendControlMsg
598 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
606 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
609 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
614 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
617 FIXME("ctrl id: %x\n", id);
620 if (pret) *pret = lres;
623 /**************************************************************************
624 * IShellBrowserImpl_SetMenuSB
626 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
628 HOLEMENU holemenuReserved,
629 HWND hwndActiveObject)
632 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
634 TRACE("(%p)\n", This);
636 /* Feature not implemented */
639 /**************************************************************************
640 * IShellBrowserImpl_SetStatusTextSB
642 HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
643 LPCOLESTR lpszStatusText)
646 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
648 TRACE("(%p)\n", This);
650 /* Feature not implemented */
653 /**************************************************************************
654 * IShellBrowserImpl_SetToolbarItems
656 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
657 LPTBBUTTON lpButtons,
662 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
664 TRACE("(%p)\n", This);
666 /* Feature not implemented */
669 /**************************************************************************
670 * IShellBrowserImpl_TranslateAcceleratorSB
672 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
677 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
679 TRACE("(%p)\n", This);
681 /* Feature not implemented */
685 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl =
688 IShellBrowserImpl_QueryInterface,
689 IShellBrowserImpl_AddRef,
690 IShellBrowserImpl_Release,
692 IShellBrowserImpl_GetWindow,
693 IShellBrowserImpl_ContextSensitiveHelp,
695 IShellBrowserImpl_InsertMenusSB,
696 IShellBrowserImpl_SetMenuSB,
697 IShellBrowserImpl_RemoveMenusSB,
698 IShellBrowserImpl_SetStatusTextSB,
699 IShellBrowserImpl_EnableModelessSB,
700 IShellBrowserImpl_TranslateAcceleratorSB,
701 IShellBrowserImpl_BrowseObject,
702 IShellBrowserImpl_GetViewStateStream,
703 IShellBrowserImpl_GetControlWindow,
704 IShellBrowserImpl_SendControlMsg,
705 IShellBrowserImpl_QueryActiveShellView,
706 IShellBrowserImpl_OnViewWindowActive,
707 IShellBrowserImpl_SetToolbarItems
716 /***************************************************************************
717 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
719 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
720 ICommDlgBrowser *iface,
724 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
726 TRACE("(%p)\n", This);
728 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
731 /**************************************************************************
732 * IShellBrowserImpl_ICommDlgBrowser_AddRef
734 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
736 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
738 TRACE("(%p)\n", This);
740 return IShellBrowserImpl_AddRef(This);
743 /**************************************************************************
744 * IShellBrowserImpl_ICommDlgBrowser_Release
746 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
748 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
750 TRACE("(%p)\n", This);
752 return IShellBrowserImpl_Release(This);
754 /**************************************************************************
755 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
757 * Called when a user double-clicks in the view or presses the ENTER key
759 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
763 FileOpenDlgInfos *fodInfos;
765 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
767 TRACE("(%p)\n", This);
769 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
771 /* If the selected object is not a folder, send an IDOK command to parent window */
772 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
776 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
777 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, (LPCITEMIDLIST *)&pidl, &ulAttr);
778 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
780 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
781 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_FOLDERCHANGE);
785 /* Tell the dialog that the user selected a file */
786 PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
790 /* Free memory used by pidl */
791 COMDLG32_SHFree((LPVOID)pidl);
799 /**************************************************************************
800 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
802 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
807 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
809 TRACE("(%p shv=%p)\n", This, ppshv);
813 case CDBOSC_SETFOCUS:
814 /* FIXME: Reset the default button.
815 This should be taken care of by defdlg. If control
816 other than button receives focus the default button
817 should be restored. */
818 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
821 case CDBOSC_KILLFOCUS:
823 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
824 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
825 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
828 case CDBOSC_SELCHANGE:
829 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
838 /**************************************************************************
839 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
841 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
845 FileOpenDlgInfos *fodInfos;
848 WCHAR szPathW[MAX_PATH];
850 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
852 TRACE("(%p)\n", This);
854 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
856 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
857 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
859 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
860 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
863 /* always include directories and links */
864 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
867 /* Check if there is a mask to apply if not */
868 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
871 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
873 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
875 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
883 /**************************************************************************
884 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
886 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
888 FileOpenDlgInfos *fodInfos;
890 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
892 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
893 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
895 /* release old selections */
896 if (fodInfos->Shell.FOIDataObject)
897 IDataObject_Release(fodInfos->Shell.FOIDataObject);
899 /* get a new DataObject from the ShellView */
900 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
901 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
904 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
906 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
910 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl =
913 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
914 IShellBrowserImpl_ICommDlgBrowser_AddRef,
915 IShellBrowserImpl_ICommDlgBrowser_Release,
916 /* ICommDlgBrowser */
917 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
918 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
919 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
929 /***************************************************************************
930 * IShellBrowserImpl_IServiceProvider_QueryInterface
932 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
933 IServiceProvider *iface,
937 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
939 FIXME("(%p)\n", This);
941 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
944 /**************************************************************************
945 * IShellBrowserImpl_IServiceProvider_AddRef
947 ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface)
949 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
951 FIXME("(%p)\n", This);
953 return IShellBrowserImpl_AddRef(This);
956 /**************************************************************************
957 * IShellBrowserImpl_IServiceProvider_Release
959 ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface)
961 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
963 FIXME("(%p)\n", This);
965 return IShellBrowserImpl_Release(This);
968 /**************************************************************************
969 * IShellBrowserImpl_IServiceProvider_Release
972 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
973 * riid = IShellBrowser) to call SendControlMsg ().
979 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
980 IServiceProvider * iface,
985 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
987 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
990 if(guidService && IsEqualIID(guidService, &SID_STopLevelBrowser))
992 return IShellBrowserImpl_QueryInterface(This,riid,ppv);
994 FIXME("(%p) unknown interface requested\n", This);
995 return E_NOINTERFACE;
999 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl =
1002 IShellBrowserImpl_IServiceProvider_QueryInterface,
1003 IShellBrowserImpl_IServiceProvider_AddRef,
1004 IShellBrowserImpl_IServiceProvider_Release,
1005 /* IServiceProvider */
1006 IShellBrowserImpl_IServiceProvider_QueryService