Add stub implementation of RtlAddAuditAccessAce.
[wine/multimedia.git] / dlls / commdlg / filedlgbrowser.c
blob0287a6fa70d93f24019f732cfde76e90d9cc82d1
1 /*
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
22 #include <stdarg.h>
23 #include <stdio.h>
24 #include <string.h>
26 #define COBJMACROS
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winnls.h"
33 #include "wingdi.h"
34 #include "winuser.h"
35 #include "winreg.h"
37 #define NO_SHLWAPI_STREAM
38 #include "shlwapi.h"
39 #include "filedlgbrowser.h"
40 #include "cdlg.h"
41 #include "shlguid.h"
42 #include "servprov.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
47 typedef struct
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 */
56 } IShellBrowserImpl;
58 /**************************************************************************
59 * vtable
61 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl;
62 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl;
63 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl;
65 /**************************************************************************
66 * Local Prototypes
69 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
70 #if 0
71 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
72 #endif
74 /**************************************************************************
75 * External Prototypes
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);
88 * Helper functions
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))
96 unsigned int i;
97 static const struct {
98 DWORD mask;
99 const char *name;
100 } flags[] = {
101 #define FE(x) { x, #x}
102 /* SBSP_DEFBROWSER == 0 */
103 FE(SBSP_SAMEBROWSER),
104 FE(SBSP_NEWBROWSER),
106 /* SBSP_DEFMODE == 0 */
107 FE(SBSP_OPENMODE),
108 FE(SBSP_EXPLOREMODE),
109 FE(SBSP_HELPMODE),
110 FE(SBSP_NOTRANSFERHIST),
112 /* SBSP_ABSOLUTE == 0 */
113 FE(SBSP_RELATIVE),
114 FE(SBSP_PARENT),
115 FE(SBSP_NAVIGATEBACK),
116 FE(SBSP_NAVIGATEFORWARD),
117 FE(SBSP_ALLOW_AUTONAVIGATE),
119 FE(SBSP_NOAUTOSELECT),
120 FE(SBSP_WRITENOHISTORY),
122 FE(SBSP_REDIRECT),
123 FE(SBSP_INITIATEDBYHLINKFRAME),
125 #undef FE
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);
130 DPRINTF("\n");
134 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
136 LPSHELLFOLDER psfDesktop;
137 STRRET strret;
138 HRESULT res;
140 res = SHGetDesktopFolder(&psfDesktop);
141 if (FAILED(res))
142 return;
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);
150 if (SUCCEEDED(res))
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);
162 switch (src->uType)
164 case STRRET_WSTR:
165 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
166 COMDLG32_SHFree(src->u.pOleStr);
167 break;
169 case STRRET_CSTR:
170 if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
171 ((LPWSTR)dest)[len-1] = 0;
172 break;
174 case STRRET_OFFSET:
175 if (pidl)
177 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
178 -1, (LPWSTR)dest, len ))
179 ((LPWSTR)dest)[len-1] = 0;
181 break;
183 default:
184 FIXME("unknown type!\n");
185 if (len)
186 { *(LPWSTR)dest = '\0';
188 return(FALSE);
190 return S_OK;
194 * IShellBrowser
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 */
208 sb->ref=1;
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);
218 TRACE("%p\n", sb);
220 return (IShellBrowser *) sb;
223 /***************************************************************************
224 * IShellBrowserImpl_QueryInterface
226 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
227 REFIID riid,
228 LPVOID *ppvObj)
230 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
232 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
234 *ppvObj = NULL;
236 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
237 { *ppvObj = This;
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);
255 if(*ppvObj)
256 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
257 return S_OK;
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);
273 return ref;
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);
286 if (!ref)
288 COMDLG32_SHFree(This);
289 TRACE("-- destroyed\n");
290 return 0;
292 return ref;
296 * IOleWindow
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,
310 HWND * phwnd)
312 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
314 TRACE("(%p)\n", This);
316 if(!This->hwndOwner)
317 return E_FAIL;
319 *phwnd = This->hwndOwner;
321 return (*phwnd) ? S_OK : E_UNEXPECTED;
325 /**************************************************************************
326 * IShellBrowserImpl_ContextSensitiveHelp
328 HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
329 BOOL fEnterMode)
331 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
333 TRACE("(%p)\n", This);
335 /* Feature not implemented */
336 return E_NOTIMPL;
340 * IShellBrowser
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,
352 LPCITEMIDLIST pidl,
353 UINT wFlags)
355 HRESULT hRes;
356 IShellFolder *psfTmp;
357 IShellView *psvTmp;
358 FileOpenDlgInfos *fodInfos;
359 LPITEMIDLIST pidlTmp;
360 HWND hwndView;
361 HWND hDlgWnd;
362 BOOL bViewHasFocus;
363 RECT rectView;
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");
381 return hRes;
383 /* create an absolute pidl */
384 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
385 (LPITEMIDLIST)pidl);
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);
401 if(!psfTmp)
403 ERR("could not browse to folder\n");
404 return E_FAIL;
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");
414 return NOERROR;
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 */
476 if (bViewHasFocus)
477 SetFocus(fodInfos->ShellInfos.hwndView);
479 return hRes;
480 error:
481 ERR("Failed with error 0x%08lx\n", hRes);
482 return hRes;
485 /**************************************************************************
486 * IShellBrowserImpl_EnableModelessSB
488 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
489 BOOL fEnable)
492 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
494 TRACE("(%p)\n", This);
496 /* Feature not implemented */
497 return E_NOTIMPL;
500 /**************************************************************************
501 * IShellBrowserImpl_GetControlWindow
503 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
504 UINT id,
505 HWND *lphwnd)
508 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
510 TRACE("(%p)\n", This);
512 /* Feature not implemented */
513 return E_NOTIMPL;
515 /**************************************************************************
516 * IShellBrowserImpl_GetViewStateStream
518 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
519 DWORD grfMode,
520 LPSTREAM *ppStrm)
523 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
525 FIXME("(%p 0x%08lx %p)\n", This, grfMode, ppStrm);
527 /* Feature not implemented */
528 return E_NOTIMPL;
530 /**************************************************************************
531 * IShellBrowserImpl_InsertMenusSB
533 HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
534 HMENU hmenuShared,
535 LPOLEMENUGROUPWIDTHS lpMenuWidths)
538 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
540 TRACE("(%p)\n", This);
542 /* Feature not implemented */
543 return E_NOTIMPL;
545 /**************************************************************************
546 * IShellBrowserImpl_OnViewWindowActive
548 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
549 IShellView *ppshv)
552 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
554 TRACE("(%p)\n", This);
556 /* Feature not implemented */
557 return E_NOTIMPL;
559 /**************************************************************************
560 * IShellBrowserImpl_QueryActiveShellView
562 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
563 IShellView **ppshv)
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))
576 return E_FAIL;
578 IShellView_AddRef(fodInfos->Shell.FOIShellView);
579 return NOERROR;
581 /**************************************************************************
582 * IShellBrowserImpl_RemoveMenusSB
584 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
585 HMENU hmenuShared)
588 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
590 TRACE("(%p)\n", This);
592 /* Feature not implemented */
593 return E_NOTIMPL;
595 /**************************************************************************
596 * IShellBrowserImpl_SendControlMsg
598 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
599 UINT id,
600 UINT uMsg,
601 WPARAM wParam,
602 LPARAM lParam,
603 LRESULT *pret)
606 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
607 LRESULT lres;
609 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
611 switch (id)
613 case FCW_TOOLBAR:
614 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
615 break;
616 default:
617 FIXME("ctrl id: %x\n", id);
618 return E_NOTIMPL;
620 if (pret) *pret = lres;
621 return S_OK;
623 /**************************************************************************
624 * IShellBrowserImpl_SetMenuSB
626 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
627 HMENU hmenuShared,
628 HOLEMENU holemenuReserved,
629 HWND hwndActiveObject)
632 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
634 TRACE("(%p)\n", This);
636 /* Feature not implemented */
637 return E_NOTIMPL;
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 */
651 return E_NOTIMPL;
653 /**************************************************************************
654 * IShellBrowserImpl_SetToolbarItems
656 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
657 LPTBBUTTON lpButtons,
658 UINT nButtons,
659 UINT uFlags)
662 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
664 TRACE("(%p)\n", This);
666 /* Feature not implemented */
667 return E_NOTIMPL;
669 /**************************************************************************
670 * IShellBrowserImpl_TranslateAcceleratorSB
672 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
673 LPMSG lpmsg,
674 WORD wID)
677 IShellBrowserImpl *This = (IShellBrowserImpl *)iface;
679 TRACE("(%p)\n", This);
681 /* Feature not implemented */
682 return E_NOTIMPL;
685 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl =
687 /* IUnknown */
688 IShellBrowserImpl_QueryInterface,
689 IShellBrowserImpl_AddRef,
690 IShellBrowserImpl_Release,
691 /* IOleWindow */
692 IShellBrowserImpl_GetWindow,
693 IShellBrowserImpl_ContextSensitiveHelp,
694 /* IShellBrowser */
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
713 * ICommDlgBrowser
716 /***************************************************************************
717 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
719 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
720 ICommDlgBrowser *iface,
721 REFIID riid,
722 LPVOID *ppvObj)
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,
760 IShellView *ppshv)
762 LPITEMIDLIST pidl;
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)))
774 HRESULT hRes;
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);
783 else
785 /* Tell the dialog that the user selected a file */
786 PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
787 hRes = S_OK;
790 /* Free memory used by pidl */
791 COMDLG32_SHFree((LPVOID)pidl);
793 return hRes;
796 return E_FAIL;
799 /**************************************************************************
800 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
802 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
803 IShellView *ppshv,
804 ULONG uChange)
807 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
809 TRACE("(%p shv=%p)\n", This, ppshv);
811 switch (uChange)
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);
820 break;
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");
827 break;
828 case CDBOSC_SELCHANGE:
829 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
830 case CDBOSC_RENAME:
831 /* nothing to do */
832 break;
835 return NOERROR;
838 /**************************************************************************
839 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
841 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
842 IShellView * ppshv,
843 LPCITEMIDLIST pidl)
845 FileOpenDlgInfos *fodInfos;
846 ULONG ulAttr;
847 STRRET str;
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 */
861 return S_FALSE;
863 /* always include directories and links */
864 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
865 return S_OK;
867 /* Check if there is a mask to apply if not */
868 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
869 return S_OK;
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))
876 return S_OK;
879 return S_FALSE;
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)))
902 return E_FAIL;
904 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
906 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
907 return S_OK;
910 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl =
912 /* IUnknown */
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
926 * IServiceProvider
929 /***************************************************************************
930 * IShellBrowserImpl_IServiceProvider_QueryInterface
932 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
933 IServiceProvider *iface,
934 REFIID riid,
935 LPVOID *ppvObj)
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
971 * NOTES
972 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
973 * riid = IShellBrowser) to call SendControlMsg ().
975 * FIXME
976 * this is a hack!
979 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
980 IServiceProvider * iface,
981 REFGUID guidService,
982 REFIID riid,
983 void** ppv)
985 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
987 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
989 *ppv = NULL;
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 =
1001 /* IUnknown */
1002 IShellBrowserImpl_IServiceProvider_QueryInterface,
1003 IShellBrowserImpl_IServiceProvider_AddRef,
1004 IShellBrowserImpl_IServiceProvider_Release,
1005 /* IServiceProvider */
1006 IShellBrowserImpl_IServiceProvider_QueryService