Update comments, cleanup warning messages.
[wine/multimedia.git] / dlls / commdlg / filedlgbrowser.c
blob452132c563a52dff671002782e3ff31b4ee8db03
1 /*
2 * Implementation of IShellBrowser for the File Open common dialog
3 *
5 */
7 #include <stdio.h>
9 #include "windef.h"
10 #include "wingdi.h"
11 #include "winuser.h"
12 #include "wine/winestring.h"
13 #include "heap.h"
14 #include "debugtools.h"
16 #define INITGUID
17 #include "initguid.h"
18 #include "unknwn.h"
19 #include "filedlgbrowser.h"
20 #include "cdlg.h"
21 #include "shlguid.h"
22 #include "wine/obj_serviceprovider.h"
24 DEFAULT_DEBUG_CHANNEL(commdlg);
26 typedef struct
29 ICOM_VTABLE(IShellBrowser) * lpVtbl;
30 ICOM_VTABLE(ICommDlgBrowser) * lpVtblCommDlgBrowser;
31 ICOM_VTABLE(IServiceProvider)* lpVtblServiceProvider;
32 DWORD ref; /* Reference counter */
33 HWND hwndOwner; /* Owner dialog of the interface */
35 } IShellBrowserImpl;
37 /**************************************************************************
38 * vtable
40 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl;
41 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl;
42 static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl;
44 /**************************************************************************
45 * Local Prototypes
48 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
49 #if 0
50 LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
51 #endif
53 /**************************************************************************
54 * External Prototypes
56 extern const char *FileOpenDlgInfosStr;
58 extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
59 extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
60 extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
61 extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
62 extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
64 extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
65 LPITEMIDLIST pidlCurrentFolder,
66 LPSTR lpstrMask);
68 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
69 extern BOOL FILEDLG95_OnOpen(HWND hwnd);
70 extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
74 * Helper functions
77 /* copied from shell32 to avoid linking to it */
78 static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
80 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
82 switch (src->uType)
84 case STRRET_WSTR:
85 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
86 COMDLG32_SHFree(src->u.pOleStr);
87 break;
89 case STRRET_CSTRA:
90 lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len);
91 break;
93 case STRRET_OFFSETA:
94 if (pidl)
96 lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
98 break;
100 default:
101 FIXME("unknown type!\n");
102 if (len)
103 { *(LPSTR)dest = '\0';
105 return(FALSE);
107 return S_OK;
111 * IShellBrowser
114 /**************************************************************************
115 * IShellBrowserImpl_Construct
117 IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
119 IShellBrowserImpl *sb;
120 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
122 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
124 /* Initialisation of the member variables */
125 sb->ref=1;
126 sb->hwndOwner = hwndOwner;
128 /* Initialisation of the vTables */
129 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
130 sb->lpVtblCommDlgBrowser = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
131 sb->lpVtblServiceProvider = &IShellBrowserImpl_IServiceProvider_Vtbl;
132 COMDLG32_SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
133 &fodInfos->ShellInfos.pidlAbsCurrent);
135 TRACE("%p\n", sb);
137 return (IShellBrowser *) sb;
140 /***************************************************************************
141 * IShellBrowserImpl_QueryInterface
143 HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
144 REFIID riid,
145 LPVOID *ppvObj)
147 ICOM_THIS(IShellBrowserImpl, iface);
149 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
151 *ppvObj = NULL;
153 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
154 { *ppvObj = This;
156 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
157 { *ppvObj = (IOleWindow*)This;
160 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
161 { *ppvObj = (IShellBrowser*)This;
164 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
165 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblCommDlgBrowser);
168 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
169 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblServiceProvider);
172 if(*ppvObj)
173 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
174 return S_OK;
176 FIXME("Unknown interface requested\n");
177 return E_NOINTERFACE;
180 /**************************************************************************
181 * IShellBrowser::AddRef
183 ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
185 ICOM_THIS(IShellBrowserImpl, iface);
187 TRACE("(%p)\n", This);
189 return ++(This->ref);
192 /**************************************************************************
193 * IShellBrowserImpl_Release
195 ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
197 ICOM_THIS(IShellBrowserImpl, iface);
199 TRACE("(%p)\n", This);
201 if (!--(This->ref))
203 HeapFree(GetProcessHeap(),0, This);
204 return 0;
206 return This->ref;
210 * IOleWindow
213 /**************************************************************************
214 * IShellBrowserImpl_GetWindow (IOleWindow)
216 * Inherited from IOleWindow::GetWindow
218 * See Windows documentation for more details
220 * Note : We will never be window less in the File Open dialog
223 HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
224 HWND * phwnd)
226 ICOM_THIS(IShellBrowserImpl, iface);
228 TRACE("(%p)\n", This);
230 if(!This->hwndOwner)
231 return E_FAIL;
233 *phwnd = This->hwndOwner;
235 return (*phwnd) ? S_OK : E_UNEXPECTED;
239 /**************************************************************************
240 * IShellBrowserImpl_ContextSensitiveHelp
242 HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
243 BOOL fEnterMode)
245 ICOM_THIS(IShellBrowserImpl, iface);
247 TRACE("(%p)\n", This);
249 /* Feature not implemented */
250 return E_NOTIMPL;
254 * IShellBrowser
257 /**************************************************************************
258 * IShellBrowserImpl_BrowseObject
260 * See Windows documentation on IShellBrowser::BrowseObject for more details
262 * This function will override user specified flags and will always
263 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
265 HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
266 LPCITEMIDLIST pidl,
267 UINT wFlags)
269 HRESULT hRes;
270 IShellFolder *psfTmp;
271 IShellView *psvTmp;
272 FileOpenDlgInfos *fodInfos;
273 LPITEMIDLIST pidlTmp;
274 HWND hwndView;
275 HWND hDlgWnd;
276 BOOL bViewHasFocus;
278 ICOM_THIS(IShellBrowserImpl, iface);
280 TRACE("(%p)(%p,0x%08x)\n", This, pidl, wFlags);
282 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
284 /* Format the pidl according to its parameter's category */
285 if(wFlags & SBSP_RELATIVE)
288 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
289 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
290 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
292 ERR("bind to object failed\n");
293 return hRes;
295 /* create an absolute pidl */
296 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
297 (LPITEMIDLIST)pidl);
299 else if(wFlags & SBSP_PARENT)
301 /* Browse the parent folder (ignores the pidl) */
302 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
303 psfTmp = GetShellFolderFromPidl(pidlTmp);
306 else /* SBSP_ABSOLUTE is 0x0000 */
308 /* An absolute pidl (relative from the desktop) */
309 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
310 psfTmp = GetShellFolderFromPidl(pidlTmp);
313 if(!psfTmp)
315 ERR("could not browse to folder\n");
316 return E_FAIL;
319 /* If the pidl to browse to is equal to the actual pidl ...
320 do nothing and pretend you did it*/
321 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
323 IShellFolder_Release(psfTmp);
324 COMDLG32_SHFree(pidlTmp);
325 TRACE("keep current folder\n");
326 return NOERROR;
329 /* Release the current DataObject */
330 if (fodInfos->Shell.FOIDataObject)
332 IDataObject_Release(fodInfos->Shell.FOIDataObject);
333 fodInfos->Shell.FOIDataObject = NULL;
336 /* Create the associated view */
337 TRACE("create view object\n");
338 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
339 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
341 /* Check if listview has focus */
342 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
344 /* Get the foldersettings from the old view */
345 if(fodInfos->Shell.FOIShellView)
346 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
348 /* Release the old fodInfos->Shell.FOIShellView and update its value.
349 We have to update this early since ShellView_CreateViewWindow of native
350 shell32 calls OnStateChange and needs the correct view here.*/
351 if(fodInfos->Shell.FOIShellView)
353 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
354 IShellView_Release(fodInfos->Shell.FOIShellView);
356 fodInfos->Shell.FOIShellView = psvTmp;
358 /* Release old FOIShellFolder and update its value */
359 if (fodInfos->Shell.FOIShellFolder)
360 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
361 fodInfos->Shell.FOIShellFolder = psfTmp;
363 /* Release old pidlAbsCurrent and update its value */
364 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
365 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
367 /* Create the window */
368 TRACE("create view window\n");
369 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
370 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
371 &fodInfos->ShellInfos.rectView, &hwndView))) goto error;
373 fodInfos->ShellInfos.hwndView = hwndView;
375 /* Select the new folder in the Look In combo box of the Open file dialog */
376 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
378 /* changes the tab order of the ListView to reflect the window's File Dialog */
379 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
380 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
382 /* Since we destroyed the old view if it had focus set focus to the newly created view */
383 if (bViewHasFocus)
384 SetFocus(fodInfos->ShellInfos.hwndView);
386 return hRes;
387 error:
388 ERR("Failed with error 0x%08lx\n", hRes);
389 return hRes;
392 /**************************************************************************
393 * IShellBrowserImpl_EnableModelessSB
395 HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
396 BOOL fEnable)
399 ICOM_THIS(IShellBrowserImpl, iface);
401 TRACE("(%p)\n", This);
403 /* Feature not implemented */
404 return E_NOTIMPL;
407 /**************************************************************************
408 * IShellBrowserImpl_GetControlWindow
410 HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
411 UINT id,
412 HWND *lphwnd)
415 ICOM_THIS(IShellBrowserImpl, iface);
417 TRACE("(%p)\n", This);
419 /* Feature not implemented */
420 return E_NOTIMPL;
422 /**************************************************************************
423 * IShellBrowserImpl_GetViewStateStream
425 HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
426 DWORD grfMode,
427 LPSTREAM *ppStrm)
430 ICOM_THIS(IShellBrowserImpl, iface);
432 FIXME("(%p 0x%08lx %p)\n", This, grfMode, ppStrm);
434 /* Feature not implemented */
435 return E_NOTIMPL;
437 /**************************************************************************
438 * IShellBrowserImpl_InsertMenusSB
440 HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
441 HMENU hmenuShared,
442 LPOLEMENUGROUPWIDTHS lpMenuWidths)
445 ICOM_THIS(IShellBrowserImpl, iface);
447 TRACE("(%p)\n", This);
449 /* Feature not implemented */
450 return E_NOTIMPL;
452 /**************************************************************************
453 * IShellBrowserImpl_OnViewWindowActive
455 HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
456 IShellView *ppshv)
459 ICOM_THIS(IShellBrowserImpl, iface);
461 TRACE("(%p)\n", This);
463 /* Feature not implemented */
464 return E_NOTIMPL;
466 /**************************************************************************
467 * IShellBrowserImpl_QueryActiveShellView
469 HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
470 IShellView **ppshv)
473 ICOM_THIS(IShellBrowserImpl, iface);
475 FileOpenDlgInfos *fodInfos;
477 TRACE("(%p)\n", This);
479 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
481 if(!(*ppshv = fodInfos->Shell.FOIShellView))
483 return E_FAIL;
485 IShellView_AddRef(fodInfos->Shell.FOIShellView);
486 return NOERROR;
488 /**************************************************************************
489 * IShellBrowserImpl_RemoveMenusSB
491 HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
492 HMENU hmenuShared)
495 ICOM_THIS(IShellBrowserImpl, iface);
497 TRACE("(%p)\n", This);
499 /* Feature not implemented */
500 return E_NOTIMPL;
502 /**************************************************************************
503 * IShellBrowserImpl_SendControlMsg
505 HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
506 UINT id,
507 UINT uMsg,
508 WPARAM wParam,
509 LPARAM lParam,
510 LRESULT *pret)
513 ICOM_THIS(IShellBrowserImpl, iface);
514 LRESULT lres;
516 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
518 switch (id)
520 case FCW_TOOLBAR:
521 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
522 break;
523 default:
524 FIXME("ctrl id: %x\n", id);
525 return E_NOTIMPL;
527 if (pret) *pret = lres;
528 return S_OK;
530 /**************************************************************************
531 * IShellBrowserImpl_SetMenuSB
533 HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
534 HMENU hmenuShared,
535 HOLEMENU holemenuReserved,
536 HWND hwndActiveObject)
539 ICOM_THIS(IShellBrowserImpl, iface);
541 TRACE("(%p)\n", This);
543 /* Feature not implemented */
544 return E_NOTIMPL;
546 /**************************************************************************
547 * IShellBrowserImpl_SetStatusTextSB
549 HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
550 LPCOLESTR lpszStatusText)
553 ICOM_THIS(IShellBrowserImpl, iface);
555 TRACE("(%p)\n", This);
557 /* Feature not implemented */
558 return E_NOTIMPL;
560 /**************************************************************************
561 * IShellBrowserImpl_SetToolbarItems
563 HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
564 LPTBBUTTON lpButtons,
565 UINT nButtons,
566 UINT uFlags)
569 ICOM_THIS(IShellBrowserImpl, iface);
571 TRACE("(%p)\n", This);
573 /* Feature not implemented */
574 return E_NOTIMPL;
576 /**************************************************************************
577 * IShellBrowserImpl_TranslateAcceleratorSB
579 HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
580 LPMSG lpmsg,
581 WORD wID)
584 ICOM_THIS(IShellBrowserImpl, iface);
586 TRACE("(%p)\n", This);
588 /* Feature not implemented */
589 return E_NOTIMPL;
592 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl =
594 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
595 /* IUnknown */
596 IShellBrowserImpl_QueryInterface,
597 IShellBrowserImpl_AddRef,
598 IShellBrowserImpl_Release,
599 /* IOleWindow */
600 IShellBrowserImpl_GetWindow,
601 IShellBrowserImpl_ContextSensitiveHelp,
602 /* IShellBrowser */
603 IShellBrowserImpl_InsertMenusSB,
604 IShellBrowserImpl_SetMenuSB,
605 IShellBrowserImpl_RemoveMenusSB,
606 IShellBrowserImpl_SetStatusTextSB,
607 IShellBrowserImpl_EnableModelessSB,
608 IShellBrowserImpl_TranslateAcceleratorSB,
609 IShellBrowserImpl_BrowseObject,
610 IShellBrowserImpl_GetViewStateStream,
611 IShellBrowserImpl_GetControlWindow,
612 IShellBrowserImpl_SendControlMsg,
613 IShellBrowserImpl_QueryActiveShellView,
614 IShellBrowserImpl_OnViewWindowActive,
615 IShellBrowserImpl_SetToolbarItems
621 * ICommDlgBrowser
624 /***************************************************************************
625 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
627 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
628 ICommDlgBrowser *iface,
629 REFIID riid,
630 LPVOID *ppvObj)
632 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
634 TRACE("(%p)\n", This);
636 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
639 /**************************************************************************
640 * IShellBrowserImpl_ICommDlgBrowser_AddRef
642 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
644 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
646 TRACE("(%p)\n", This);
648 return IShellBrowserImpl_AddRef(This);
651 /**************************************************************************
652 * IShellBrowserImpl_ICommDlgBrowser_Release
654 ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
656 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
658 TRACE("(%p)\n", This);
660 return IShellBrowserImpl_Release(This);
662 /**************************************************************************
663 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
665 * Called when a user double-clicks in the view or presses the ENTER key
667 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
668 IShellView *ppshv)
670 LPITEMIDLIST pidl;
671 FileOpenDlgInfos *fodInfos;
673 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
675 TRACE("(%p)\n", This);
677 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
679 /* If the selected object is not a folder, send a IDOK command to parent window */
680 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
682 HRESULT hRes;
684 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
685 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
686 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
688 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
690 else
692 /* Tell the dialog that the user selected a file */
693 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
696 /* Free memory used by pidl */
697 COMDLG32_SHFree((LPVOID)pidl);
699 return hRes;
702 return E_FAIL;
705 /**************************************************************************
706 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
708 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
709 IShellView *ppshv,
710 ULONG uChange)
713 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
715 TRACE("(%p shv=%p)\n", This, ppshv);
717 switch (uChange)
719 case CDBOSC_SETFOCUS:
720 /* FIXME: Reset the default button.
721 This should be taken care of by defdlg. If control
722 other than button receives focus the default button
723 should be restored. */
724 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
726 break;
727 case CDBOSC_KILLFOCUS:
729 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
730 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
731 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
733 break;
734 case CDBOSC_SELCHANGE:
735 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
736 case CDBOSC_RENAME:
737 /* nothing to do */
738 break;
741 return NOERROR;
744 /**************************************************************************
745 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
747 HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
748 IShellView * ppshv,
749 LPCITEMIDLIST pidl)
751 FileOpenDlgInfos *fodInfos;
752 ULONG ulAttr;
753 STRRET str;
754 WCHAR szPathW[MAX_PATH];
756 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
758 TRACE("(%p)\n", This);
760 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
762 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
763 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
765 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
766 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
767 return S_FALSE;
769 /* always include directorys and links */
770 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
771 return S_OK;
773 /* Check if there is a mask to apply if not */
774 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
775 return S_OK;
777 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
779 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
781 if (COMDLG32_PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
782 return S_OK;
785 return S_FALSE;
789 /**************************************************************************
790 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
792 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
794 FileOpenDlgInfos *fodInfos;
796 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
798 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
799 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
801 /* release old selections */
802 if (fodInfos->Shell.FOIDataObject)
803 IDataObject_Release(fodInfos->Shell.FOIDataObject);
805 /* get a new DataObject from the ShellView */
806 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
807 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
808 return E_FAIL;
810 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
812 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
813 return S_OK;
816 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl =
818 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
819 /* IUnknown */
820 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
821 IShellBrowserImpl_ICommDlgBrowser_AddRef,
822 IShellBrowserImpl_ICommDlgBrowser_Release,
823 /* ICommDlgBrowser */
824 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
825 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
826 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
833 * IServiceProvider
836 /***************************************************************************
837 * IShellBrowserImpl_IServiceProvider_QueryInterface
839 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
840 IServiceProvider *iface,
841 REFIID riid,
842 LPVOID *ppvObj)
844 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
846 FIXME("(%p)\n", This);
848 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
851 /**************************************************************************
852 * IShellBrowserImpl_IServiceProvider_AddRef
854 ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface)
856 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
858 FIXME("(%p)\n", This);
860 return IShellBrowserImpl_AddRef(This);
863 /**************************************************************************
864 * IShellBrowserImpl_IServiceProvider_Release
866 ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface)
868 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
870 FIXME("(%p)\n", This);
872 return IShellBrowserImpl_Release(This);
875 /**************************************************************************
876 * IShellBrowserImpl_IServiceProvider_Release
878 * NOTES
879 * the w2k shellview asks for
880 * guidService = SID_STopLevelBrowser
881 * riid = IShellBrowser
883 * FIXME
884 * this is a hack!
887 HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
888 IServiceProvider * iface,
889 REFGUID guidService,
890 REFIID riid,
891 void** ppv)
893 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
895 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
897 *ppv = NULL;
898 if(guidService && IsEqualIID(guidService, &SID_STopLevelBrowser))
900 return IShellBrowserImpl_QueryInterface(This,riid,ppv);
902 FIXME("(%p) unknown interface requested\n", This);
903 return E_NOINTERFACE;
907 static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl =
909 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
910 /* IUnknown */
911 IShellBrowserImpl_IServiceProvider_QueryInterface,
912 IShellBrowserImpl_IServiceProvider_AddRef,
913 IShellBrowserImpl_IServiceProvider_Release,
914 /* IServiceProvider */
915 IShellBrowserImpl_IServiceProvider_QueryService