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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_NO_STATUS
24 #define COM_NO_WINDOWS_H
31 #define NONAMELESSUNION
32 #define NONAMELESSSTRUCT
42 #define NO_SHLWAPI_STREAM
44 #include <filedlgbrowser.h>
46 //#include "shlguid.h"
47 //#include "servprov.h"
48 #include <wine/debug.h>
50 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
55 IShellBrowser IShellBrowser_iface
;
56 ICommDlgBrowser ICommDlgBrowser_iface
;
57 IServiceProvider IServiceProvider_iface
;
58 LONG ref
; /* Reference counter */
59 HWND hwndOwner
; /* Owner dialog of the interface */
63 static inline IShellBrowserImpl
*impl_from_IShellBrowser(IShellBrowser
*iface
)
65 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IShellBrowser_iface
);
68 static inline IShellBrowserImpl
*impl_from_ICommDlgBrowser( ICommDlgBrowser
*iface
)
70 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, ICommDlgBrowser_iface
);
73 static inline IShellBrowserImpl
*impl_from_IServiceProvider( IServiceProvider
*iface
)
75 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IServiceProvider_iface
);
78 /**************************************************************************
81 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
82 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
83 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
;
89 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
90 static void COMDLG32_DumpSBSPFlags(UINT uflags
)
92 if (TRACE_ON(commdlg
))
99 #define FE(x) { x, #x}
100 /* SBSP_DEFBROWSER == 0 */
101 FE(SBSP_SAMEBROWSER
),
104 /* SBSP_DEFMODE == 0 */
106 FE(SBSP_EXPLOREMODE
),
108 FE(SBSP_NOTRANSFERHIST
),
110 /* SBSP_ABSOLUTE == 0 */
113 FE(SBSP_NAVIGATEBACK
),
114 FE(SBSP_NAVIGATEFORWARD
),
115 FE(SBSP_ALLOW_AUTONAVIGATE
),
117 FE(SBSP_NOAUTOSELECT
),
118 FE(SBSP_WRITENOHISTORY
),
121 FE(SBSP_INITIATEDBYHLINKFRAME
),
124 TRACE("SBSP Flags: %08x =", uflags
);
125 for (i
= 0; i
< (sizeof(flags
) / sizeof(flags
[0])); i
++)
126 if (flags
[i
].mask
& uflags
)
127 TRACE("%s ", flags
[i
].name
);
132 static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos
*fodInfos
)
134 LPSHELLFOLDER psfDesktop
;
138 res
= SHGetDesktopFolder(&psfDesktop
);
142 res
= IShellFolder_GetDisplayNameOf(psfDesktop
, fodInfos
->ShellInfos
.pidlAbsCurrent
,
143 SHGDN_FORPARSING
, &strret
);
144 if (SUCCEEDED(res
)) {
145 WCHAR wszCurrentDir
[MAX_PATH
];
147 res
= StrRetToBufW(&strret
, fodInfos
->ShellInfos
.pidlAbsCurrent
, wszCurrentDir
, MAX_PATH
);
149 SetCurrentDirectoryW(wszCurrentDir
);
152 IShellFolder_Release(psfDesktop
);
155 /* copied from shell32 to avoid linking to it */
156 static BOOL
COMDLG32_StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, LPCITEMIDLIST pidl
)
158 TRACE("dest=%p len=0x%x strret=%p pidl=%p stub\n",dest
,len
,src
,pidl
);
163 lstrcpynW(dest
, src
->u
.pOleStr
, len
);
164 COMDLG32_SHFree(src
->u
.pOleStr
);
168 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, dest
, len
))
169 ((LPWSTR
)dest
)[len
-1] = 0;
175 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
,
177 ((LPWSTR
)dest
)[len
-1] = 0;
182 FIXME("unknown type!\n");
184 { *(LPWSTR
)dest
= '\0';
195 /**************************************************************************
196 * IShellBrowserImpl_Construct
198 IShellBrowser
* IShellBrowserImpl_Construct(HWND hwndOwner
)
200 IShellBrowserImpl
*sb
;
201 FileOpenDlgInfos
*fodInfos
= GetPropA(hwndOwner
,FileOpenDlgInfosStr
);
203 sb
= COMDLG32_SHAlloc(sizeof(IShellBrowserImpl
));
205 /* Initialisation of the member variables */
207 sb
->hwndOwner
= hwndOwner
;
209 /* Initialisation of the vTables */
210 sb
->IShellBrowser_iface
.lpVtbl
= &IShellBrowserImpl_Vtbl
;
211 sb
->ICommDlgBrowser_iface
.lpVtbl
= &IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
212 sb
->IServiceProvider_iface
.lpVtbl
= &IShellBrowserImpl_IServiceProvider_Vtbl
;
213 SHGetSpecialFolderLocation(hwndOwner
, CSIDL_DESKTOP
,
214 &fodInfos
->ShellInfos
.pidlAbsCurrent
);
218 return &sb
->IShellBrowser_iface
;
221 /***************************************************************************
222 * IShellBrowserImpl_QueryInterface
224 static HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
228 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
230 TRACE("(%p)\n\t%s\n", This
, debugstr_guid(riid
));
234 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
237 else if(IsEqualIID(riid
, &IID_IOleWindow
)) /*IOleWindow*/
241 else if(IsEqualIID(riid
, &IID_IShellBrowser
)) /*IShellBrowser*/
245 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
)) /*ICommDlgBrowser*/
246 *ppvObj
= &This
->ICommDlgBrowser_iface
;
247 else if(IsEqualIID(riid
, &IID_IServiceProvider
)) /* IServiceProvider */
248 *ppvObj
= &This
->IServiceProvider_iface
;
251 { IUnknown_AddRef( (IShellBrowser
*) *ppvObj
);
254 FIXME("Unknown interface requested\n");
255 return E_NOINTERFACE
;
258 /**************************************************************************
259 * IShellBrowser::AddRef
261 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
263 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
264 ULONG ref
= InterlockedIncrement(&This
->ref
);
266 TRACE("(%p,%u)\n", This
, ref
- 1);
271 /**************************************************************************
272 * IShellBrowserImpl_Release
274 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
276 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
277 ULONG ref
= InterlockedDecrement(&This
->ref
);
279 TRACE("(%p,%u)\n", This
, ref
+ 1);
283 COMDLG32_SHFree(This
);
284 TRACE("-- destroyed\n");
294 /**************************************************************************
295 * IShellBrowserImpl_GetWindow (IOleWindow)
297 * Inherited from IOleWindow::GetWindow
299 * See Windows documentation for more details
301 * Note : We will never be window less in the File Open dialog
304 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
307 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
309 TRACE("(%p)\n", This
);
314 *phwnd
= This
->hwndOwner
;
316 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
320 /**************************************************************************
321 * IShellBrowserImpl_ContextSensitiveHelp
323 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
326 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
328 TRACE("(%p)\n", This
);
330 /* Feature not implemented */
338 /**************************************************************************
339 * IShellBrowserImpl_BrowseObject
341 * See Windows documentation on IShellBrowser::BrowseObject for more details
343 * This function will override user specified flags and will always
344 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
346 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
351 IShellFolder
*psfTmp
;
353 FileOpenDlgInfos
*fodInfos
;
354 LPITEMIDLIST pidlTmp
;
360 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
362 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This
, pidl
, wFlags
);
363 COMDLG32_DumpSBSPFlags(wFlags
);
365 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
367 /* Format the pidl according to its parameter's category */
368 if(wFlags
& SBSP_RELATIVE
)
371 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
372 if(FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
373 pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfTmp
)))
375 ERR("bind to object failed\n");
378 /* create an absolute pidl */
379 pidlTmp
= COMDLG32_PIDL_ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
, pidl
);
381 else if(wFlags
& SBSP_PARENT
)
383 /* Browse the parent folder (ignores the pidl) */
384 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
385 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
388 else /* SBSP_ABSOLUTE is 0x0000 */
390 /* An absolute pidl (relative from the desktop) */
391 pidlTmp
= COMDLG32_PIDL_ILClone(pidl
);
392 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
397 ERR("could not browse to folder\n");
401 /* If the pidl to browse to is equal to the actual pidl ...
402 do nothing and pretend you did it*/
403 if(COMDLG32_PIDL_ILIsEqual(pidlTmp
,fodInfos
->ShellInfos
.pidlAbsCurrent
))
405 IShellFolder_Release(psfTmp
);
406 COMDLG32_SHFree(pidlTmp
);
407 TRACE("keep current folder\n");
411 /* Release the current DataObject */
412 if (fodInfos
->Shell
.FOIDataObject
)
414 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
415 fodInfos
->Shell
.FOIDataObject
= NULL
;
418 /* Create the associated view */
419 TRACE("create view object\n");
420 if(FAILED(hRes
= IShellFolder_CreateViewObject(psfTmp
, fodInfos
->ShellInfos
.hwndOwner
,
421 &IID_IShellView
, (LPVOID
*)&psvTmp
))) goto error
;
423 /* Check if listview has focus */
424 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
426 /* Get the foldersettings from the old view */
427 if(fodInfos
->Shell
.FOIShellView
)
428 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
430 /* Release the old fodInfos->Shell.FOIShellView and update its value.
431 We have to update this early since ShellView_CreateViewWindow of native
432 shell32 calls OnStateChange and needs the correct view here.*/
433 if(fodInfos
->Shell
.FOIShellView
)
435 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
436 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
438 fodInfos
->Shell
.FOIShellView
= psvTmp
;
440 /* Release old FOIShellFolder and update its value */
441 if (fodInfos
->Shell
.FOIShellFolder
)
442 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
443 fodInfos
->Shell
.FOIShellFolder
= psfTmp
;
445 /* Release old pidlAbsCurrent and update its value */
446 COMDLG32_SHFree(fodInfos
->ShellInfos
.pidlAbsCurrent
);
447 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
449 COMDLG32_UpdateCurrentDir(fodInfos
);
451 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
452 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
454 /* Create the window */
455 TRACE("create view window\n");
456 if(FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
457 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
458 &rectView
, &hwndView
))) goto error
;
460 fodInfos
->ShellInfos
.hwndView
= hwndView
;
462 /* Set view window control id to 5002 */
463 SetWindowLongPtrW(hwndView
, GWLP_ID
, lst2
);
465 /* Select the new folder in the Look In combo box of the Open file dialog */
466 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
468 /* changes the tab order of the ListView to reflect the window's File Dialog */
469 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
470 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
472 /* Since we destroyed the old view if it had focus set focus to the newly created view */
474 SetFocus(fodInfos
->ShellInfos
.hwndView
);
478 ERR("Failed with error 0x%08x\n", hRes
);
482 /**************************************************************************
483 * IShellBrowserImpl_EnableModelessSB
485 static HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
489 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
491 TRACE("(%p)\n", This
);
493 /* Feature not implemented */
497 /**************************************************************************
498 * IShellBrowserImpl_GetControlWindow
500 static HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
505 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
507 TRACE("(%p)\n", This
);
509 /* Feature not implemented */
513 /**************************************************************************
514 * IShellBrowserImpl_GetViewStateStream
516 static HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
521 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
523 FIXME("(%p 0x%08x %p)\n", This
, grfMode
, ppStrm
);
525 /* Feature not implemented */
529 /**************************************************************************
530 * IShellBrowserImpl_InsertMenusSB
532 static HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
534 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
537 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
539 TRACE("(%p)\n", This
);
541 /* Feature not implemented */
545 /**************************************************************************
546 * IShellBrowserImpl_OnViewWindowActive
548 static HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
552 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
554 TRACE("(%p)\n", This
);
556 /* Feature not implemented */
560 /**************************************************************************
561 * IShellBrowserImpl_QueryActiveShellView
563 static HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
567 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
569 FileOpenDlgInfos
*fodInfos
;
571 TRACE("(%p)\n", This
);
573 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
575 if(!(*ppshv
= fodInfos
->Shell
.FOIShellView
))
579 IShellView_AddRef(fodInfos
->Shell
.FOIShellView
);
583 /**************************************************************************
584 * IShellBrowserImpl_RemoveMenusSB
586 static HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
590 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
592 TRACE("(%p)\n", This
);
594 /* Feature not implemented */
598 /**************************************************************************
599 * IShellBrowserImpl_SendControlMsg
601 static HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
609 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
612 TRACE("(%p)->(0x%08x 0x%08x 0x%08lx 0x%08lx %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
617 lres
= SendDlgItemMessageA( This
->hwndOwner
, IDC_TOOLBAR
, uMsg
, wParam
, lParam
);
620 FIXME("ctrl id: %x\n", id
);
623 if (pret
) *pret
= lres
;
627 /**************************************************************************
628 * IShellBrowserImpl_SetMenuSB
630 static HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
632 HOLEMENU holemenuReserved
,
633 HWND hwndActiveObject
)
636 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
638 TRACE("(%p)\n", This
);
640 /* Feature not implemented */
644 /**************************************************************************
645 * IShellBrowserImpl_SetStatusTextSB
647 static HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
648 LPCOLESTR lpszStatusText
)
651 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
653 TRACE("(%p)\n", This
);
655 /* Feature not implemented */
659 /**************************************************************************
660 * IShellBrowserImpl_SetToolbarItems
662 static HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
663 LPTBBUTTON lpButtons
,
668 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
670 TRACE("(%p)\n", This
);
672 /* Feature not implemented */
676 /**************************************************************************
677 * IShellBrowserImpl_TranslateAcceleratorSB
679 static HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
684 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
686 TRACE("(%p)\n", This
);
688 /* Feature not implemented */
692 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
695 IShellBrowserImpl_QueryInterface
,
696 IShellBrowserImpl_AddRef
,
697 IShellBrowserImpl_Release
,
699 IShellBrowserImpl_GetWindow
,
700 IShellBrowserImpl_ContextSensitiveHelp
,
702 IShellBrowserImpl_InsertMenusSB
,
703 IShellBrowserImpl_SetMenuSB
,
704 IShellBrowserImpl_RemoveMenusSB
,
705 IShellBrowserImpl_SetStatusTextSB
,
706 IShellBrowserImpl_EnableModelessSB
,
707 IShellBrowserImpl_TranslateAcceleratorSB
,
708 IShellBrowserImpl_BrowseObject
,
709 IShellBrowserImpl_GetViewStateStream
,
710 IShellBrowserImpl_GetControlWindow
,
711 IShellBrowserImpl_SendControlMsg
,
712 IShellBrowserImpl_QueryActiveShellView
,
713 IShellBrowserImpl_OnViewWindowActive
,
714 IShellBrowserImpl_SetToolbarItems
723 /***************************************************************************
724 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
726 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
727 ICommDlgBrowser
*iface
,
731 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
733 TRACE("(%p)\n", This
);
735 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
738 /**************************************************************************
739 * IShellBrowserImpl_ICommDlgBrowser_AddRef
741 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser
* iface
)
743 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
745 TRACE("(%p)\n", This
);
747 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
750 /**************************************************************************
751 * IShellBrowserImpl_ICommDlgBrowser_Release
753 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser
* iface
)
755 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
757 TRACE("(%p)\n", This
);
759 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
762 /**************************************************************************
763 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
765 * Called when a user double-clicks in the view or presses the ENTER key
767 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser
*iface
,
771 FileOpenDlgInfos
*fodInfos
;
773 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
775 TRACE("(%p)\n", This
);
777 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
779 /* If the selected object is not a folder, send an IDOK command to parent window */
780 if((pidl
= GetPidlFromDataObject(fodInfos
->Shell
.FOIDataObject
, 1)))
784 ULONG ulAttr
= SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
785 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, (LPCITEMIDLIST
*)&pidl
, &ulAttr
);
786 if (ulAttr
& (SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
) )
788 hRes
= IShellBrowser_BrowseObject(&This
->IShellBrowser_iface
,pidl
,SBSP_RELATIVE
);
789 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
790 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_FOLDERCHANGE
);
794 /* Tell the dialog that the user selected a file */
795 PostMessageA(This
->hwndOwner
, WM_COMMAND
, IDOK
, 0L);
799 /* Free memory used by pidl */
800 COMDLG32_SHFree(pidl
);
808 /**************************************************************************
809 * IShellBrowserImpl_OnSelChange
811 static HRESULT
IShellBrowserImpl_OnSelChange(IShellBrowserImpl
*This
, const IShellView
*ppshv
)
813 FileOpenDlgInfos
*fodInfos
;
815 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
816 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
818 /* release old selections */
819 if (fodInfos
->Shell
.FOIDataObject
)
820 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
822 /* get a new DataObject from the ShellView */
823 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
824 &IID_IDataObject
, (void**)&fodInfos
->Shell
.FOIDataObject
)))
827 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
829 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
830 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
834 /**************************************************************************
835 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
837 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
842 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
844 TRACE("(%p shv=%p)\n", This
, ppshv
);
848 case CDBOSC_SETFOCUS
:
849 /* FIXME: Reset the default button.
850 This should be taken care of by defdlg. If control
851 other than button receives focus the default button
852 should be restored. */
853 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
856 case CDBOSC_KILLFOCUS
:
858 FileOpenDlgInfos
*fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
859 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
862 LoadStringW(COMDLG32_hInstance
, IDS_SAVE_BUTTON
, szSave
, sizeof(szSave
)/sizeof(WCHAR
));
863 SetDlgItemTextW(fodInfos
->ShellInfos
.hwndOwner
, IDOK
, szSave
);
867 case CDBOSC_SELCHANGE
:
868 return IShellBrowserImpl_OnSelChange(This
, ppshv
);
877 /* send_includeitem_notification
879 * Sends a CDN_INCLUDEITEM notification for "pidl" to hwndParentDlg
881 static LRESULT
send_includeitem_notification(HWND hwndParentDlg
, LPCITEMIDLIST pidl
)
883 LRESULT hook_result
= 0;
884 FileOpenDlgInfos
*fodInfos
= GetPropA(hwndParentDlg
, FileOpenDlgInfosStr
);
886 if(!fodInfos
) return 0;
888 if(fodInfos
->DlgInfos
.hwndCustomDlg
)
890 TRACE("call notify CDN_INCLUDEITEM for pidl=%p\n", pidl
);
891 if(fodInfos
->unicode
)
893 OFNOTIFYEXW ofnNotify
;
894 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
895 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
896 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
897 ofnNotify
.hdr
.idFrom
= 0;
898 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
899 ofnNotify
.lpOFN
= fodInfos
->ofnInfos
;
900 hook_result
= SendMessageW(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
904 OFNOTIFYEXA ofnNotify
;
905 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
906 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
907 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
908 ofnNotify
.hdr
.idFrom
= 0;
909 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
910 ofnNotify
.lpOFN
= (LPOPENFILENAMEA
)fodInfos
->ofnInfos
;
911 hook_result
= SendMessageA(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
914 TRACE("Retval: 0x%08lx\n", hook_result
);
918 /**************************************************************************
919 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
921 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
925 FileOpenDlgInfos
*fodInfos
;
928 WCHAR szPathW
[MAX_PATH
];
930 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
932 TRACE("(%p)\n", This
);
934 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
936 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
937 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
939 if( (ulAttr
& SFGAO_HIDDEN
) || /* hidden */
940 !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
943 /* always include directories and links */
944 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
947 /* if the application takes care of including the item we are done */
948 if(fodInfos
->ofnInfos
->Flags
& OFN_ENABLEINCLUDENOTIFY
&&
949 send_includeitem_notification(This
->hwndOwner
, pidl
))
952 /* Check if there is a mask to apply if not */
953 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !lstrlenW(fodInfos
->ShellInfos
.lpstrCurrentFilter
))
956 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
958 if (COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
))
960 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
968 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
971 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
972 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
973 IShellBrowserImpl_ICommDlgBrowser_Release
,
974 /* ICommDlgBrowser */
975 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
976 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
977 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
987 /***************************************************************************
988 * IShellBrowserImpl_IServiceProvider_QueryInterface
990 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
991 IServiceProvider
*iface
,
995 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
997 FIXME("(%p)\n", This
);
999 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
1002 /**************************************************************************
1003 * IShellBrowserImpl_IServiceProvider_AddRef
1005 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
1007 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1009 FIXME("(%p)\n", This
);
1011 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
1014 /**************************************************************************
1015 * IShellBrowserImpl_IServiceProvider_Release
1017 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
1019 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1021 FIXME("(%p)\n", This
);
1023 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
1026 /**************************************************************************
1027 * IShellBrowserImpl_IServiceProvider_Release
1030 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
1031 * riid = IShellBrowser) to call SendControlMsg ().
1037 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
1038 IServiceProvider
* iface
,
1039 REFGUID guidService
,
1043 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1045 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
1048 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
1049 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppv
);
1051 FIXME("(%p) unknown interface requested\n", This
);
1052 return E_NOINTERFACE
;
1056 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
1059 IShellBrowserImpl_IServiceProvider_QueryInterface
,
1060 IShellBrowserImpl_IServiceProvider_AddRef
,
1061 IShellBrowserImpl_IServiceProvider_Release
,
1062 /* IServiceProvider */
1063 IShellBrowserImpl_IServiceProvider_QueryService