Do not pass unnecessary flags to wrc in generated makefiles.
[wine/multimedia.git] / dlls / commdlg / filedlgbrowser.c
blob98b4b9f489a93a2a3a4aca7bedd309bc81d58fab
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 <stdio.h>
23 #include <string.h>
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winnls.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "winreg.h"
34 #define NO_SHLWAPI_STREAM
35 #include "shlwapi.h"
36 #include "filedlgbrowser.h"
37 #include "cdlg.h"
38 #include "shlguid.h"
39 #include "wine/obj_serviceprovider.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
44 typedef struct
47 ICOM_VTABLE(IShellBrowser) * lpVtbl;
48 ICOM_VTABLE(ICommDlgBrowser) * lpVtblCommDlgBrowser;
49 ICOM_VTABLE(IServiceProvider)* lpVtblServiceProvider;
50 DWORD ref; /* Reference counter */
51 HWND hwndOwner; /* Owner dialog of the interface */
53 } IShellBrowserImpl;
55 /**************************************************************************
56 * vtable
58 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl;
59 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl;
60 static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl;
62 /**************************************************************************
63 * Local Prototypes
66 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
67 #if 0
68 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
69 #endif
71 /**************************************************************************
72 * External Prototypes
74 extern const char *FileOpenDlgInfosStr;
76 extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
77 extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
78 extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
79 extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
80 extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
82 extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
83 LPITEMIDLIST pidlCurrentFolder,
84 LPSTR lpstrMask);
86 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
87 extern BOOL FILEDLG95_OnOpen(HWND hwnd);
88 extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
92 * Helper functions
95 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
97 char lpstrPath[MAX_PATH];
98 if(SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath)) {
99 SetCurrentDirectoryA(lpstrPath);
100 TRACE("new current folder %s\n", lpstrPath);
104 /* copied from shell32 to avoid linking to it */
105 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
107 TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest,len,src,pidl);
109 switch (src->uType)
111 case STRRET_WSTR:
112 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
113 COMDLG32_SHFree(src->u.pOleStr);
114 break;
116 case STRRET_CSTR:
117 if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
118 ((LPWSTR)dest)[len-1] = 0;
119 break;
121 case STRRET_OFFSET:
122 if (pidl)
124 if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
125 -1, (LPWSTR)dest, len ))
126 ((LPWSTR)dest)[len-1] = 0;
128 break;
130 default:
131 FIXME("unknown type!\n");
132 if (len)
133 { *(LPWSTR)dest = '\0';
135 return(FALSE);
137 return S_OK;
141 * IShellBrowser
144 /**************************************************************************
145 * IShellBrowserImpl_Construct
147 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
149 IShellBrowserImpl *sb;
150 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
152 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
154 /* Initialisation of the member variables */
155 sb->ref=1;
156 sb->hwndOwner = hwndOwner;
158 /* Initialisation of the vTables */
159 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
160 sb->lpVtblCommDlgBrowser = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
161 sb->lpVtblServiceProvider = &IShellBrowserImpl_IServiceProvider_Vtbl;
162 SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
163 &fodInfos->ShellInfos.pidlAbsCurrent);
165 TRACE("%p\n", sb);
167 return (IShellBrowser *) sb;
170 /***************************************************************************
171 * IShellBrowserImpl_QueryInterface
173 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
174 REFIID riid,
175 LPVOID *ppvObj)
177 ICOM_THIS(IShellBrowserImpl, iface);
179 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
181 *ppvObj = NULL;
183 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
184 { *ppvObj = This;
186 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
187 { *ppvObj = (IOleWindow*)This;
190 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
191 { *ppvObj = (IShellBrowser*)This;
194 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
195 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblCommDlgBrowser);
198 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
199 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblServiceProvider);
202 if(*ppvObj)
203 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
204 return S_OK;
206 FIXME("Unknown interface requested\n");
207 return E_NOINTERFACE;
210 /**************************************************************************
211 * IShellBrowser::AddRef
213 ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
215 ICOM_THIS(IShellBrowserImpl, iface);
217 TRACE("(%p,%lu)\n", This, This->ref);
219 return ++(This->ref);
222 /**************************************************************************
223 * IShellBrowserImpl_Release
225 ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
227 ICOM_THIS(IShellBrowserImpl, iface);
229 TRACE("(%p,%lu)\n", This, This->ref);
231 if (!--(This->ref))
233 COMDLG32_SHFree(This);
234 TRACE("-- destroyed\n");
235 return 0;
237 return This->ref;
241 * IOleWindow
244 /**************************************************************************
245 * IShellBrowserImpl_GetWindow (IOleWindow)
247 * Inherited from IOleWindow::GetWindow
249 * See Windows documentation for more details
251 * Note : We will never be window less in the File Open dialog
254 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
255 HWND * phwnd)
257 ICOM_THIS(IShellBrowserImpl, iface);
259 TRACE("(%p)\n", This);
261 if(!This->hwndOwner)
262 return E_FAIL;
264 *phwnd = This->hwndOwner;
266 return (*phwnd) ? S_OK : E_UNEXPECTED;
270 /**************************************************************************
271 * IShellBrowserImpl_ContextSensitiveHelp
273 HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
274 BOOL fEnterMode)
276 ICOM_THIS(IShellBrowserImpl, iface);
278 TRACE("(%p)\n", This);
280 /* Feature not implemented */
281 return E_NOTIMPL;
285 * IShellBrowser
288 /**************************************************************************
289 * IShellBrowserImpl_BrowseObject
291 * See Windows documentation on IShellBrowser::BrowseObject for more details
293 * This function will override user specified flags and will always
294 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
296 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
297 LPCITEMIDLIST pidl,
298 UINT wFlags)
300 HRESULT hRes;
301 IShellFolder *psfTmp;
302 IShellView *psvTmp;
303 FileOpenDlgInfos *fodInfos;
304 LPITEMIDLIST pidlTmp;
305 HWND hwndView;
306 HWND hDlgWnd;
307 BOOL bViewHasFocus;
309 ICOM_THIS(IShellBrowserImpl, iface);
311 TRACE("(%p)(pidl=%p,flags=0x%08x(%s))\n", This, pidl, wFlags,
312 (wFlags & SBSP_RELATIVE) ? "SBSP_RELATIVE" :
313 (wFlags & SBSP_PARENT) ? "SBSP_PARENT" :
314 (wFlags & SBSP_ABSOLUTE) ? "SBSP_ABSOLUTE" : "SBPS_????");
316 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
318 /* Format the pidl according to its parameter's category */
319 if(wFlags & SBSP_RELATIVE)
322 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
323 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
324 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
326 ERR("bind to object failed\n");
327 return hRes;
329 /* create an absolute pidl */
330 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
331 (LPITEMIDLIST)pidl);
333 else if(wFlags & SBSP_PARENT)
335 /* Browse the parent folder (ignores the pidl) */
336 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
337 psfTmp = GetShellFolderFromPidl(pidlTmp);
340 else /* SBSP_ABSOLUTE is 0x0000 */
342 /* An absolute pidl (relative from the desktop) */
343 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
344 psfTmp = GetShellFolderFromPidl(pidlTmp);
347 if(!psfTmp)
349 ERR("could not browse to folder\n");
350 return E_FAIL;
353 /* If the pidl to browse to is equal to the actual pidl ...
354 do nothing and pretend you did it*/
355 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
357 IShellFolder_Release(psfTmp);
358 COMDLG32_SHFree(pidlTmp);
359 TRACE("keep current folder\n");
360 return NOERROR;
363 /* Release the current DataObject */
364 if (fodInfos->Shell.FOIDataObject)
366 IDataObject_Release(fodInfos->Shell.FOIDataObject);
367 fodInfos->Shell.FOIDataObject = NULL;
370 /* Create the associated view */
371 TRACE("create view object\n");
372 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
373 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
375 /* Check if listview has focus */
376 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
378 /* Get the foldersettings from the old view */
379 if(fodInfos->Shell.FOIShellView)
380 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
382 /* Release the old fodInfos->Shell.FOIShellView and update its value.
383 We have to update this early since ShellView_CreateViewWindow of native
384 shell32 calls OnStateChange and needs the correct view here.*/
385 if(fodInfos->Shell.FOIShellView)
387 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
388 IShellView_Release(fodInfos->Shell.FOIShellView);
390 fodInfos->Shell.FOIShellView = psvTmp;
392 /* Release old FOIShellFolder and update its value */
393 if (fodInfos->Shell.FOIShellFolder)
394 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
395 fodInfos->Shell.FOIShellFolder = psfTmp;
397 /* Release old pidlAbsCurrent and update its value */
398 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
399 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
401 COMDLG32_UpdateCurrentDir(fodInfos);
403 /* Create the window */
404 TRACE("create view window\n");
405 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
406 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
407 &fodInfos->ShellInfos.rectView, &hwndView))) goto error;
409 fodInfos->ShellInfos.hwndView = hwndView;
411 /* Select the new folder in the Look In combo box of the Open file dialog */
412 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
414 /* changes the tab order of the ListView to reflect the window's File Dialog */
415 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
416 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
418 /* Since we destroyed the old view if it had focus set focus to the newly created view */
419 if (bViewHasFocus)
420 SetFocus(fodInfos->ShellInfos.hwndView);
422 return hRes;
423 error:
424 ERR("Failed with error 0x%08lx\n", hRes);
425 return hRes;
428 /**************************************************************************
429 * IShellBrowserImpl_EnableModelessSB
431 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
432 BOOL fEnable)
435 ICOM_THIS(IShellBrowserImpl, iface);
437 TRACE("(%p)\n", This);
439 /* Feature not implemented */
440 return E_NOTIMPL;
443 /**************************************************************************
444 * IShellBrowserImpl_GetControlWindow
446 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
447 UINT id,
448 HWND *lphwnd)
451 ICOM_THIS(IShellBrowserImpl, iface);
453 TRACE("(%p)\n", This);
455 /* Feature not implemented */
456 return E_NOTIMPL;
458 /**************************************************************************
459 * IShellBrowserImpl_GetViewStateStream
461 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
462 DWORD grfMode,
463 LPSTREAM *ppStrm)
466 ICOM_THIS(IShellBrowserImpl, iface);
468 FIXME("(%p 0x%08lx %p)\n", This, grfMode, ppStrm);
470 /* Feature not implemented */
471 return E_NOTIMPL;
473 /**************************************************************************
474 * IShellBrowserImpl_InsertMenusSB
476 HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
477 HMENU hmenuShared,
478 LPOLEMENUGROUPWIDTHS lpMenuWidths)
481 ICOM_THIS(IShellBrowserImpl, iface);
483 TRACE("(%p)\n", This);
485 /* Feature not implemented */
486 return E_NOTIMPL;
488 /**************************************************************************
489 * IShellBrowserImpl_OnViewWindowActive
491 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
492 IShellView *ppshv)
495 ICOM_THIS(IShellBrowserImpl, iface);
497 TRACE("(%p)\n", This);
499 /* Feature not implemented */
500 return E_NOTIMPL;
502 /**************************************************************************
503 * IShellBrowserImpl_QueryActiveShellView
505 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
506 IShellView **ppshv)
509 ICOM_THIS(IShellBrowserImpl, iface);
511 FileOpenDlgInfos *fodInfos;
513 TRACE("(%p)\n", This);
515 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
517 if(!(*ppshv = fodInfos->Shell.FOIShellView))
519 return E_FAIL;
521 IShellView_AddRef(fodInfos->Shell.FOIShellView);
522 return NOERROR;
524 /**************************************************************************
525 * IShellBrowserImpl_RemoveMenusSB
527 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
528 HMENU hmenuShared)
531 ICOM_THIS(IShellBrowserImpl, iface);
533 TRACE("(%p)\n", This);
535 /* Feature not implemented */
536 return E_NOTIMPL;
538 /**************************************************************************
539 * IShellBrowserImpl_SendControlMsg
541 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
542 UINT id,
543 UINT uMsg,
544 WPARAM wParam,
545 LPARAM lParam,
546 LRESULT *pret)
549 ICOM_THIS(IShellBrowserImpl, iface);
550 LRESULT lres;
552 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
554 switch (id)
556 case FCW_TOOLBAR:
557 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
558 break;
559 default:
560 FIXME("ctrl id: %x\n", id);
561 return E_NOTIMPL;
563 if (pret) *pret = lres;
564 return S_OK;
566 /**************************************************************************
567 * IShellBrowserImpl_SetMenuSB
569 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
570 HMENU hmenuShared,
571 HOLEMENU holemenuReserved,
572 HWND hwndActiveObject)
575 ICOM_THIS(IShellBrowserImpl, iface);
577 TRACE("(%p)\n", This);
579 /* Feature not implemented */
580 return E_NOTIMPL;
582 /**************************************************************************
583 * IShellBrowserImpl_SetStatusTextSB
585 HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
586 LPCOLESTR lpszStatusText)
589 ICOM_THIS(IShellBrowserImpl, iface);
591 TRACE("(%p)\n", This);
593 /* Feature not implemented */
594 return E_NOTIMPL;
596 /**************************************************************************
597 * IShellBrowserImpl_SetToolbarItems
599 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
600 LPTBBUTTON lpButtons,
601 UINT nButtons,
602 UINT uFlags)
605 ICOM_THIS(IShellBrowserImpl, iface);
607 TRACE("(%p)\n", This);
609 /* Feature not implemented */
610 return E_NOTIMPL;
612 /**************************************************************************
613 * IShellBrowserImpl_TranslateAcceleratorSB
615 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
616 LPMSG lpmsg,
617 WORD wID)
620 ICOM_THIS(IShellBrowserImpl, iface);
622 TRACE("(%p)\n", This);
624 /* Feature not implemented */
625 return E_NOTIMPL;
628 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl =
630 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
631 /* IUnknown */
632 IShellBrowserImpl_QueryInterface,
633 IShellBrowserImpl_AddRef,
634 IShellBrowserImpl_Release,
635 /* IOleWindow */
636 IShellBrowserImpl_GetWindow,
637 IShellBrowserImpl_ContextSensitiveHelp,
638 /* IShellBrowser */
639 IShellBrowserImpl_InsertMenusSB,
640 IShellBrowserImpl_SetMenuSB,
641 IShellBrowserImpl_RemoveMenusSB,
642 IShellBrowserImpl_SetStatusTextSB,
643 IShellBrowserImpl_EnableModelessSB,
644 IShellBrowserImpl_TranslateAcceleratorSB,
645 IShellBrowserImpl_BrowseObject,
646 IShellBrowserImpl_GetViewStateStream,
647 IShellBrowserImpl_GetControlWindow,
648 IShellBrowserImpl_SendControlMsg,
649 IShellBrowserImpl_QueryActiveShellView,
650 IShellBrowserImpl_OnViewWindowActive,
651 IShellBrowserImpl_SetToolbarItems
657 * ICommDlgBrowser
660 /***************************************************************************
661 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
663 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
664 ICommDlgBrowser *iface,
665 REFIID riid,
666 LPVOID *ppvObj)
668 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
670 TRACE("(%p)\n", This);
672 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
675 /**************************************************************************
676 * IShellBrowserImpl_ICommDlgBrowser_AddRef
678 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
680 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
682 TRACE("(%p)\n", This);
684 return IShellBrowserImpl_AddRef(This);
687 /**************************************************************************
688 * IShellBrowserImpl_ICommDlgBrowser_Release
690 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
692 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
694 TRACE("(%p)\n", This);
696 return IShellBrowserImpl_Release(This);
698 /**************************************************************************
699 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
701 * Called when a user double-clicks in the view or presses the ENTER key
703 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
704 IShellView *ppshv)
706 LPITEMIDLIST pidl;
707 FileOpenDlgInfos *fodInfos;
709 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
711 TRACE("(%p)\n", This);
713 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
715 /* If the selected object is not a folder, send a IDOK command to parent window */
716 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
718 HRESULT hRes;
720 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
721 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
722 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
724 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
726 else
728 /* Tell the dialog that the user selected a file */
729 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
732 /* Free memory used by pidl */
733 COMDLG32_SHFree((LPVOID)pidl);
735 return hRes;
738 return E_FAIL;
741 /**************************************************************************
742 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
744 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
745 IShellView *ppshv,
746 ULONG uChange)
749 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
751 TRACE("(%p shv=%p)\n", This, ppshv);
753 switch (uChange)
755 case CDBOSC_SETFOCUS:
756 /* FIXME: Reset the default button.
757 This should be taken care of by defdlg. If control
758 other than button receives focus the default button
759 should be restored. */
760 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
762 break;
763 case CDBOSC_KILLFOCUS:
765 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
766 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
767 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
769 break;
770 case CDBOSC_SELCHANGE:
771 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
772 case CDBOSC_RENAME:
773 /* nothing to do */
774 break;
777 return NOERROR;
780 /**************************************************************************
781 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
783 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
784 IShellView * ppshv,
785 LPCITEMIDLIST pidl)
787 FileOpenDlgInfos *fodInfos;
788 ULONG ulAttr;
789 STRRET str;
790 WCHAR szPathW[MAX_PATH];
792 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
794 TRACE("(%p)\n", This);
796 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
798 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
799 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
801 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
802 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
803 return S_FALSE;
805 /* always include directories and links */
806 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
807 return S_OK;
809 /* Check if there is a mask to apply if not */
810 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
811 return S_OK;
813 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
815 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
817 if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
818 return S_OK;
821 return S_FALSE;
825 /**************************************************************************
826 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
828 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
830 FileOpenDlgInfos *fodInfos;
832 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
834 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
835 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
837 /* release old selections */
838 if (fodInfos->Shell.FOIDataObject)
839 IDataObject_Release(fodInfos->Shell.FOIDataObject);
841 /* get a new DataObject from the ShellView */
842 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
843 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
844 return E_FAIL;
846 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
848 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
849 return S_OK;
852 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl =
854 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
855 /* IUnknown */
856 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
857 IShellBrowserImpl_ICommDlgBrowser_AddRef,
858 IShellBrowserImpl_ICommDlgBrowser_Release,
859 /* ICommDlgBrowser */
860 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
861 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
862 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
869 * IServiceProvider
872 /***************************************************************************
873 * IShellBrowserImpl_IServiceProvider_QueryInterface
875 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
876 IServiceProvider *iface,
877 REFIID riid,
878 LPVOID *ppvObj)
880 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
882 FIXME("(%p)\n", This);
884 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
887 /**************************************************************************
888 * IShellBrowserImpl_IServiceProvider_AddRef
890 ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface)
892 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
894 FIXME("(%p)\n", This);
896 return IShellBrowserImpl_AddRef(This);
899 /**************************************************************************
900 * IShellBrowserImpl_IServiceProvider_Release
902 ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface)
904 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
906 FIXME("(%p)\n", This);
908 return IShellBrowserImpl_Release(This);
911 /**************************************************************************
912 * IShellBrowserImpl_IServiceProvider_Release
914 * NOTES
915 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
916 * riid = IShellBrowser) to call SendControlMsg ().
918 * FIXME
919 * this is a hack!
922 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
923 IServiceProvider * iface,
924 REFGUID guidService,
925 REFIID riid,
926 void** ppv)
928 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
930 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
932 *ppv = NULL;
933 if(guidService && IsEqualIID(guidService, &SID_STopLevelBrowser))
935 return IShellBrowserImpl_QueryInterface(This,riid,ppv);
937 FIXME("(%p) unknown interface requested\n", This);
938 return E_NOINTERFACE;
942 static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl =
944 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
945 /* IUnknown */
946 IShellBrowserImpl_IServiceProvider_QueryInterface,
947 IShellBrowserImpl_IServiceProvider_AddRef,
948 IShellBrowserImpl_IServiceProvider_Release,
949 /* IServiceProvider */
950 IShellBrowserImpl_IServiceProvider_QueryService