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
27 #define NONAMELESSUNION
36 #define NO_SHLWAPI_STREAM
38 #include "filedlgbrowser.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
49 IShellBrowser IShellBrowser_iface
;
50 ICommDlgBrowser ICommDlgBrowser_iface
;
51 IServiceProvider IServiceProvider_iface
;
52 LONG ref
; /* Reference counter */
53 HWND hwndOwner
; /* Owner dialog of the interface */
57 static inline IShellBrowserImpl
*impl_from_IShellBrowser(IShellBrowser
*iface
)
59 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IShellBrowser_iface
);
62 static inline IShellBrowserImpl
*impl_from_ICommDlgBrowser( ICommDlgBrowser
*iface
)
64 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, ICommDlgBrowser_iface
);
67 static inline IShellBrowserImpl
*impl_from_IServiceProvider( IServiceProvider
*iface
)
69 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IServiceProvider_iface
);
72 /**************************************************************************
75 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
76 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
77 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
;
83 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
84 static void COMDLG32_DumpSBSPFlags(UINT uflags
)
86 if (TRACE_ON(commdlg
))
93 #define FE(x) { x, #x}
94 /* SBSP_DEFBROWSER == 0 */
98 /* SBSP_DEFMODE == 0 */
100 FE(SBSP_EXPLOREMODE
),
102 FE(SBSP_NOTRANSFERHIST
),
104 /* SBSP_ABSOLUTE == 0 */
107 FE(SBSP_NAVIGATEBACK
),
108 FE(SBSP_NAVIGATEFORWARD
),
109 FE(SBSP_ALLOW_AUTONAVIGATE
),
111 FE(SBSP_NOAUTOSELECT
),
112 FE(SBSP_WRITENOHISTORY
),
115 FE(SBSP_INITIATEDBYHLINKFRAME
),
118 TRACE("SBSP Flags: %08x =", uflags
);
119 for (i
= 0; i
< (sizeof(flags
) / sizeof(flags
[0])); i
++)
120 if (flags
[i
].mask
& uflags
)
121 TRACE("%s ", flags
[i
].name
);
126 static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos
*fodInfos
)
128 LPSHELLFOLDER psfDesktop
;
132 res
= SHGetDesktopFolder(&psfDesktop
);
136 res
= IShellFolder_GetDisplayNameOf(psfDesktop
, fodInfos
->ShellInfos
.pidlAbsCurrent
,
137 SHGDN_FORPARSING
, &strret
);
138 if (SUCCEEDED(res
)) {
139 WCHAR wszCurrentDir
[MAX_PATH
];
141 res
= StrRetToBufW(&strret
, fodInfos
->ShellInfos
.pidlAbsCurrent
, wszCurrentDir
, MAX_PATH
);
143 SetCurrentDirectoryW(wszCurrentDir
);
146 IShellFolder_Release(psfDesktop
);
149 /* copied from shell32 to avoid linking to it */
150 static BOOL
COMDLG32_StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, LPCITEMIDLIST pidl
)
152 TRACE("dest=%p len=0x%x strret=%p pidl=%p\n", dest
, len
, src
, pidl
);
157 lstrcpynW(dest
, src
->u
.pOleStr
, len
);
158 COMDLG32_SHFree(src
->u
.pOleStr
);
162 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, dest
, len
))
163 ((LPWSTR
)dest
)[len
-1] = 0;
169 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
,
171 ((LPWSTR
)dest
)[len
-1] = 0;
176 FIXME("unknown type!\n");
178 { *(LPWSTR
)dest
= '\0';
189 /**************************************************************************
190 * IShellBrowserImpl_Construct
192 IShellBrowser
* IShellBrowserImpl_Construct(HWND hwndOwner
)
194 IShellBrowserImpl
*sb
;
195 FileOpenDlgInfos
*fodInfos
= GetPropA(hwndOwner
,FileOpenDlgInfosStr
);
197 sb
= COMDLG32_SHAlloc(sizeof(IShellBrowserImpl
));
199 /* Initialisation of the member variables */
201 sb
->hwndOwner
= hwndOwner
;
203 /* Initialisation of the vTables */
204 sb
->IShellBrowser_iface
.lpVtbl
= &IShellBrowserImpl_Vtbl
;
205 sb
->ICommDlgBrowser_iface
.lpVtbl
= &IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
206 sb
->IServiceProvider_iface
.lpVtbl
= &IShellBrowserImpl_IServiceProvider_Vtbl
;
207 SHGetSpecialFolderLocation(hwndOwner
, CSIDL_DESKTOP
,
208 &fodInfos
->ShellInfos
.pidlAbsCurrent
);
212 return &sb
->IShellBrowser_iface
;
215 /***************************************************************************
216 * IShellBrowserImpl_QueryInterface
218 static HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
222 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
224 TRACE("(%p)\n\t%s\n", This
, debugstr_guid(riid
));
228 if(IsEqualIID(riid
, &IID_IUnknown
))
229 *ppvObj
= &This
->IShellBrowser_iface
;
230 else if(IsEqualIID(riid
, &IID_IOleWindow
))
231 *ppvObj
= &This
->IShellBrowser_iface
;
232 else if(IsEqualIID(riid
, &IID_IShellBrowser
))
233 *ppvObj
= &This
->IShellBrowser_iface
;
234 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
))
235 *ppvObj
= &This
->ICommDlgBrowser_iface
;
236 else if(IsEqualIID(riid
, &IID_IServiceProvider
))
237 *ppvObj
= &This
->IServiceProvider_iface
;
240 IUnknown_AddRef((IUnknown
*)*ppvObj
);
244 FIXME("Unknown interface requested\n");
245 return E_NOINTERFACE
;
248 /**************************************************************************
249 * IShellBrowser::AddRef
251 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
253 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
254 ULONG ref
= InterlockedIncrement(&This
->ref
);
256 TRACE("(%p,%u)\n", This
, ref
- 1);
261 /**************************************************************************
262 * IShellBrowserImpl_Release
264 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
266 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
267 ULONG ref
= InterlockedDecrement(&This
->ref
);
269 TRACE("(%p,%u)\n", This
, ref
+ 1);
273 COMDLG32_SHFree(This
);
274 TRACE("-- destroyed\n");
284 /**************************************************************************
285 * IShellBrowserImpl_GetWindow (IOleWindow)
287 * Inherited from IOleWindow::GetWindow
289 * See Windows documentation for more details
291 * Note : We will never be window less in the File Open dialog
294 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
297 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
299 TRACE("(%p)\n", This
);
304 *phwnd
= This
->hwndOwner
;
306 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
310 /**************************************************************************
311 * IShellBrowserImpl_ContextSensitiveHelp
313 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
316 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
318 TRACE("(%p)\n", This
);
320 /* Feature not implemented */
328 /**************************************************************************
329 * IShellBrowserImpl_BrowseObject
331 * See Windows documentation on IShellBrowser::BrowseObject for more details
333 * This function will override user specified flags and will always
334 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
336 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
341 IShellFolder
*psfTmp
;
343 FileOpenDlgInfos
*fodInfos
;
344 LPITEMIDLIST pidlTmp
;
350 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
352 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This
, pidl
, wFlags
);
353 COMDLG32_DumpSBSPFlags(wFlags
);
355 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
357 /* Format the pidl according to its parameter's category */
358 if(wFlags
& SBSP_RELATIVE
)
361 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
362 if(FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
363 pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfTmp
)))
365 ERR("bind to object failed\n");
368 /* create an absolute pidl */
369 pidlTmp
= COMDLG32_PIDL_ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
, pidl
);
371 else if(wFlags
& SBSP_PARENT
)
373 /* Browse the parent folder (ignores the pidl) */
374 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
375 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
378 else /* SBSP_ABSOLUTE is 0x0000 */
380 /* An absolute pidl (relative from the desktop) */
381 pidlTmp
= COMDLG32_PIDL_ILClone(pidl
);
382 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
387 ERR("could not browse to folder\n");
391 /* If the pidl to browse to is equal to the actual pidl ...
392 do nothing and pretend you did it*/
393 if(COMDLG32_PIDL_ILIsEqual(pidlTmp
,fodInfos
->ShellInfos
.pidlAbsCurrent
))
395 IShellFolder_Release(psfTmp
);
396 COMDLG32_SHFree(pidlTmp
);
397 TRACE("keep current folder\n");
401 /* Release the current DataObject */
402 if (fodInfos
->Shell
.FOIDataObject
)
404 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
405 fodInfos
->Shell
.FOIDataObject
= NULL
;
408 /* Create the associated view */
409 TRACE("create view object\n");
410 if(FAILED(hRes
= IShellFolder_CreateViewObject(psfTmp
, fodInfos
->ShellInfos
.hwndOwner
,
411 &IID_IShellView
, (LPVOID
*)&psvTmp
))) goto error
;
413 /* Check if listview has focus */
414 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
416 /* Get the foldersettings from the old view */
417 if(fodInfos
->Shell
.FOIShellView
)
418 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
420 /* Release the old fodInfos->Shell.FOIShellView and update its value.
421 We have to update this early since ShellView_CreateViewWindow of native
422 shell32 calls OnStateChange and needs the correct view here.*/
423 if(fodInfos
->Shell
.FOIShellView
)
425 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
426 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
428 fodInfos
->Shell
.FOIShellView
= psvTmp
;
430 /* Release old FOIShellFolder and update its value */
431 if (fodInfos
->Shell
.FOIShellFolder
)
432 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
433 fodInfos
->Shell
.FOIShellFolder
= psfTmp
;
435 /* Release old pidlAbsCurrent and update its value */
436 COMDLG32_SHFree(fodInfos
->ShellInfos
.pidlAbsCurrent
);
437 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
439 COMDLG32_UpdateCurrentDir(fodInfos
);
441 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
442 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
444 /* Create the window */
445 TRACE("create view window\n");
446 if(FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
447 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
448 &rectView
, &hwndView
))) goto error
;
450 fodInfos
->ShellInfos
.hwndView
= hwndView
;
452 /* Set view window control id to 5002 */
453 SetWindowLongPtrW(hwndView
, GWLP_ID
, lst2
);
454 SendMessageW( hwndView
, WM_SETFONT
, SendMessageW( GetParent(hwndView
), WM_GETFONT
, 0, 0 ), FALSE
);
456 /* Select the new folder in the Look In combo box of the Open file dialog */
457 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
459 /* changes the tab order of the ListView to reflect the window's File Dialog */
460 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
461 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
463 /* Since we destroyed the old view if it had focus set focus to the newly created view */
465 SetFocus(fodInfos
->ShellInfos
.hwndView
);
469 ERR("Failed with error 0x%08x\n", hRes
);
473 /**************************************************************************
474 * IShellBrowserImpl_EnableModelessSB
476 static HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
480 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
482 TRACE("(%p)\n", This
);
484 /* Feature not implemented */
488 /**************************************************************************
489 * IShellBrowserImpl_GetControlWindow
491 static HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
496 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
498 TRACE("(%p)\n", This
);
500 /* Feature not implemented */
504 /**************************************************************************
505 * IShellBrowserImpl_GetViewStateStream
507 static HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
512 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
514 FIXME("(%p 0x%08x %p)\n", This
, grfMode
, ppStrm
);
516 /* Feature not implemented */
520 /**************************************************************************
521 * IShellBrowserImpl_InsertMenusSB
523 static HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
525 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
528 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
530 TRACE("(%p)\n", This
);
532 /* Feature not implemented */
536 /**************************************************************************
537 * IShellBrowserImpl_OnViewWindowActive
539 static HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
543 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
545 TRACE("(%p)\n", This
);
547 /* Feature not implemented */
551 /**************************************************************************
552 * IShellBrowserImpl_QueryActiveShellView
554 static HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
558 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
560 FileOpenDlgInfos
*fodInfos
;
562 TRACE("(%p)\n", This
);
564 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
566 if(!(*ppshv
= fodInfos
->Shell
.FOIShellView
))
570 IShellView_AddRef(fodInfos
->Shell
.FOIShellView
);
574 /**************************************************************************
575 * IShellBrowserImpl_RemoveMenusSB
577 static HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
581 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
583 TRACE("(%p)\n", This
);
585 /* Feature not implemented */
589 /**************************************************************************
590 * IShellBrowserImpl_SendControlMsg
592 static HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
600 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
603 TRACE("(%p)->(0x%08x 0x%08x 0x%08lx 0x%08lx %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
608 lres
= SendDlgItemMessageA( This
->hwndOwner
, IDC_TOOLBAR
, uMsg
, wParam
, lParam
);
611 FIXME("ctrl id: %x\n", id
);
614 if (pret
) *pret
= lres
;
618 /**************************************************************************
619 * IShellBrowserImpl_SetMenuSB
621 static HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
623 HOLEMENU holemenuReserved
,
624 HWND hwndActiveObject
)
627 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
629 TRACE("(%p)\n", This
);
631 /* Feature not implemented */
635 /**************************************************************************
636 * IShellBrowserImpl_SetStatusTextSB
638 static HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
639 LPCOLESTR lpszStatusText
)
642 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
644 TRACE("(%p)\n", This
);
646 /* Feature not implemented */
650 /**************************************************************************
651 * IShellBrowserImpl_SetToolbarItems
653 static HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
654 LPTBBUTTON lpButtons
,
659 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
661 TRACE("(%p)\n", This
);
663 /* Feature not implemented */
667 /**************************************************************************
668 * IShellBrowserImpl_TranslateAcceleratorSB
670 static HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
675 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
677 TRACE("(%p)\n", This
);
679 /* Feature not implemented */
683 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
686 IShellBrowserImpl_QueryInterface
,
687 IShellBrowserImpl_AddRef
,
688 IShellBrowserImpl_Release
,
690 IShellBrowserImpl_GetWindow
,
691 IShellBrowserImpl_ContextSensitiveHelp
,
693 IShellBrowserImpl_InsertMenusSB
,
694 IShellBrowserImpl_SetMenuSB
,
695 IShellBrowserImpl_RemoveMenusSB
,
696 IShellBrowserImpl_SetStatusTextSB
,
697 IShellBrowserImpl_EnableModelessSB
,
698 IShellBrowserImpl_TranslateAcceleratorSB
,
699 IShellBrowserImpl_BrowseObject
,
700 IShellBrowserImpl_GetViewStateStream
,
701 IShellBrowserImpl_GetControlWindow
,
702 IShellBrowserImpl_SendControlMsg
,
703 IShellBrowserImpl_QueryActiveShellView
,
704 IShellBrowserImpl_OnViewWindowActive
,
705 IShellBrowserImpl_SetToolbarItems
714 /***************************************************************************
715 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
717 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
718 ICommDlgBrowser
*iface
,
722 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
724 TRACE("(%p)\n", This
);
726 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
729 /**************************************************************************
730 * IShellBrowserImpl_ICommDlgBrowser_AddRef
732 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser
* iface
)
734 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
736 TRACE("(%p)\n", This
);
738 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
741 /**************************************************************************
742 * IShellBrowserImpl_ICommDlgBrowser_Release
744 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser
* iface
)
746 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
748 TRACE("(%p)\n", This
);
750 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
753 /**************************************************************************
754 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
756 * Called when a user double-clicks in the view or presses the ENTER key
758 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser
*iface
,
762 FileOpenDlgInfos
*fodInfos
;
764 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
766 TRACE("(%p)\n", This
);
768 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
770 /* If the selected object is not a folder, send an IDOK command to parent window */
771 if((pidl
= GetPidlFromDataObject(fodInfos
->Shell
.FOIDataObject
, 1)))
775 ULONG ulAttr
= SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
776 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, (LPCITEMIDLIST
*)&pidl
, &ulAttr
);
777 if (ulAttr
& (SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
) )
779 hRes
= IShellBrowser_BrowseObject(&This
->IShellBrowser_iface
,pidl
,SBSP_RELATIVE
);
780 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
781 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_FOLDERCHANGE
);
785 /* Tell the dialog that the user selected a file */
786 PostMessageA(This
->hwndOwner
, WM_COMMAND
, IDOK
, 0L);
790 /* Free memory used by pidl */
791 COMDLG32_SHFree(pidl
);
799 /**************************************************************************
800 * IShellBrowserImpl_OnSelChange
802 static HRESULT
IShellBrowserImpl_OnSelChange(IShellBrowserImpl
*This
, const IShellView
*ppshv
)
804 FileOpenDlgInfos
*fodInfos
;
806 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
807 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
809 /* release old selections */
810 if (fodInfos
->Shell
.FOIDataObject
)
811 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
813 /* get a new DataObject from the ShellView */
814 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
815 &IID_IDataObject
, (void**)&fodInfos
->Shell
.FOIDataObject
)))
818 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
820 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
821 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
825 /**************************************************************************
826 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
828 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
833 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
835 TRACE("(%p shv=%p)\n", This
, ppshv
);
839 case CDBOSC_SETFOCUS
:
840 /* FIXME: Reset the default button.
841 This should be taken care of by defdlg. If control
842 other than button receives focus the default button
843 should be restored. */
844 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
847 case CDBOSC_KILLFOCUS
:
849 FileOpenDlgInfos
*fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
850 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
853 LoadStringW(COMDLG32_hInstance
, IDS_SAVE_BUTTON
, szSave
, sizeof(szSave
)/sizeof(WCHAR
));
854 SetDlgItemTextW(fodInfos
->ShellInfos
.hwndOwner
, IDOK
, szSave
);
858 case CDBOSC_SELCHANGE
:
859 return IShellBrowserImpl_OnSelChange(This
, ppshv
);
868 /* send_includeitem_notification
870 * Sends a CDN_INCLUDEITEM notification for "pidl" to hwndParentDlg
872 static LRESULT
send_includeitem_notification(HWND hwndParentDlg
, LPCITEMIDLIST pidl
)
874 LRESULT hook_result
= 0;
875 FileOpenDlgInfos
*fodInfos
= GetPropA(hwndParentDlg
, FileOpenDlgInfosStr
);
877 if(!fodInfos
) return 0;
879 if(fodInfos
->DlgInfos
.hwndCustomDlg
)
881 TRACE("call notify CDN_INCLUDEITEM for pidl=%p\n", pidl
);
882 if(fodInfos
->unicode
)
884 OFNOTIFYEXW ofnNotify
;
885 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
886 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
887 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
888 ofnNotify
.hdr
.idFrom
= 0;
889 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
890 ofnNotify
.lpOFN
= fodInfos
->ofnInfos
;
891 hook_result
= SendMessageW(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
895 OFNOTIFYEXA ofnNotify
;
896 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
897 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
898 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
899 ofnNotify
.hdr
.idFrom
= 0;
900 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
901 ofnNotify
.lpOFN
= (LPOPENFILENAMEA
)fodInfos
->ofnInfos
;
902 hook_result
= SendMessageA(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
905 TRACE("Retval: 0x%08lx\n", hook_result
);
909 /**************************************************************************
910 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
912 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
916 FileOpenDlgInfos
*fodInfos
;
919 WCHAR szPathW
[MAX_PATH
];
921 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
923 TRACE("(%p)\n", This
);
925 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
927 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
928 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
930 if( (ulAttr
& SFGAO_HIDDEN
) || /* hidden */
931 !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
934 /* always include directories and links */
935 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
938 /* if the application takes care of including the item we are done */
939 if(fodInfos
->ofnInfos
->Flags
& OFN_ENABLEINCLUDENOTIFY
&&
940 send_includeitem_notification(This
->hwndOwner
, pidl
))
943 /* Check if there is a mask to apply if not */
944 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !fodInfos
->ShellInfos
.lpstrCurrentFilter
[0])
947 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
949 if (COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
))
951 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
959 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
962 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
963 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
964 IShellBrowserImpl_ICommDlgBrowser_Release
,
965 /* ICommDlgBrowser */
966 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
967 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
968 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
978 /***************************************************************************
979 * IShellBrowserImpl_IServiceProvider_QueryInterface
981 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
982 IServiceProvider
*iface
,
986 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
988 FIXME("(%p)\n", This
);
990 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
993 /**************************************************************************
994 * IShellBrowserImpl_IServiceProvider_AddRef
996 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
998 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1000 FIXME("(%p)\n", This
);
1002 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
1005 /**************************************************************************
1006 * IShellBrowserImpl_IServiceProvider_Release
1008 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
1010 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1012 FIXME("(%p)\n", This
);
1014 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
1017 /**************************************************************************
1018 * IShellBrowserImpl_IServiceProvider_Release
1021 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
1022 * riid = IShellBrowser) to call SendControlMsg ().
1028 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
1029 IServiceProvider
* iface
,
1030 REFGUID guidService
,
1034 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1036 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
1039 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
1040 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppv
);
1042 FIXME("(%p) unknown interface requested\n", This
);
1043 return E_NOINTERFACE
;
1047 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
1050 IShellBrowserImpl_IServiceProvider_QueryInterface
,
1051 IShellBrowserImpl_IServiceProvider_AddRef
,
1052 IShellBrowserImpl_IServiceProvider_Release
,
1053 /* IServiceProvider */
1054 IShellBrowserImpl_IServiceProvider_QueryService