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
34 #define NO_SHLWAPI_STREAM
36 #include "filedlgbrowser.h"
40 #include "wine/debug.h"
41 #include "wine/heap.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
48 IShellBrowser IShellBrowser_iface
;
49 ICommDlgBrowser ICommDlgBrowser_iface
;
50 IServiceProvider IServiceProvider_iface
;
51 LONG ref
; /* Reference counter */
52 HWND hwndOwner
; /* Owner dialog of the interface */
56 static inline IShellBrowserImpl
*impl_from_IShellBrowser(IShellBrowser
*iface
)
58 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IShellBrowser_iface
);
61 static inline IShellBrowserImpl
*impl_from_ICommDlgBrowser( ICommDlgBrowser
*iface
)
63 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, ICommDlgBrowser_iface
);
66 static inline IShellBrowserImpl
*impl_from_IServiceProvider( IServiceProvider
*iface
)
68 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IServiceProvider_iface
);
71 /**************************************************************************
74 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
75 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
76 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
;
82 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
83 static void COMDLG32_DumpSBSPFlags(UINT uflags
)
85 if (TRACE_ON(commdlg
))
92 #define FE(x) { x, #x}
93 /* SBSP_DEFBROWSER == 0 */
97 /* SBSP_DEFMODE == 0 */
101 FE(SBSP_NOTRANSFERHIST
),
103 /* SBSP_ABSOLUTE == 0 */
106 FE(SBSP_NAVIGATEBACK
),
107 FE(SBSP_NAVIGATEFORWARD
),
108 FE(SBSP_ALLOW_AUTONAVIGATE
),
110 FE(SBSP_NOAUTOSELECT
),
111 FE(SBSP_WRITENOHISTORY
),
114 FE(SBSP_INITIATEDBYHLINKFRAME
),
117 TRACE("SBSP Flags: %08x =", uflags
);
118 for (i
= 0; i
< ARRAY_SIZE(flags
); i
++)
119 if (flags
[i
].mask
& uflags
)
120 TRACE("%s ", flags
[i
].name
);
125 static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos
*fodInfos
)
127 LPSHELLFOLDER psfDesktop
;
131 res
= SHGetDesktopFolder(&psfDesktop
);
135 res
= IShellFolder_GetDisplayNameOf(psfDesktop
, fodInfos
->ShellInfos
.pidlAbsCurrent
,
136 SHGDN_FORPARSING
, &strret
);
137 if (SUCCEEDED(res
)) {
138 WCHAR wszCurrentDir
[MAX_PATH
];
140 res
= StrRetToBufW(&strret
, fodInfos
->ShellInfos
.pidlAbsCurrent
, wszCurrentDir
, MAX_PATH
);
142 SetCurrentDirectoryW(wszCurrentDir
);
145 IShellFolder_Release(psfDesktop
);
148 /* copied from shell32 to avoid linking to it */
149 static BOOL
COMDLG32_StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, LPCITEMIDLIST pidl
)
151 TRACE("dest=%p len=0x%lx strret=%p pidl=%p\n", dest
, len
, src
, pidl
);
156 lstrcpynW(dest
, src
->pOleStr
, len
);
157 CoTaskMemFree(src
->pOleStr
);
161 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, src
->cStr
, -1, dest
, len
))
162 ((LPWSTR
)dest
)[len
-1] = 0;
168 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->uOffset
,
170 ((LPWSTR
)dest
)[len
-1] = 0;
175 FIXME("unknown type!\n");
177 { *(LPWSTR
)dest
= '\0';
188 /**************************************************************************
189 * IShellBrowserImpl_Construct
191 IShellBrowser
* IShellBrowserImpl_Construct(HWND hwndOwner
)
193 FileOpenDlgInfos
*fodInfos
= get_filedlg_infoptr(hwndOwner
);
194 IShellBrowserImpl
*sb
;
196 sb
= heap_alloc(sizeof(*sb
));
198 /* Initialisation of the member variables */
200 sb
->hwndOwner
= hwndOwner
;
202 /* Initialisation of the vTables */
203 sb
->IShellBrowser_iface
.lpVtbl
= &IShellBrowserImpl_Vtbl
;
204 sb
->ICommDlgBrowser_iface
.lpVtbl
= &IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
205 sb
->IServiceProvider_iface
.lpVtbl
= &IShellBrowserImpl_IServiceProvider_Vtbl
;
206 SHGetSpecialFolderLocation(hwndOwner
, CSIDL_DESKTOP
,
207 &fodInfos
->ShellInfos
.pidlAbsCurrent
);
211 return &sb
->IShellBrowser_iface
;
214 /***************************************************************************
215 * IShellBrowserImpl_QueryInterface
217 static HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
, REFIID riid
, void **ppvObj
)
219 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
221 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppvObj
);
225 if(IsEqualIID(riid
, &IID_IUnknown
))
226 *ppvObj
= &This
->IShellBrowser_iface
;
227 else if(IsEqualIID(riid
, &IID_IOleWindow
))
228 *ppvObj
= &This
->IShellBrowser_iface
;
229 else if(IsEqualIID(riid
, &IID_IShellBrowser
))
230 *ppvObj
= &This
->IShellBrowser_iface
;
231 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
))
232 *ppvObj
= &This
->ICommDlgBrowser_iface
;
233 else if(IsEqualIID(riid
, &IID_IServiceProvider
))
234 *ppvObj
= &This
->IServiceProvider_iface
;
237 IUnknown_AddRef((IUnknown
*)*ppvObj
);
241 FIXME("unsupported interface, %s\n", debugstr_guid(riid
));
242 return E_NOINTERFACE
;
245 /**************************************************************************
246 * IShellBrowser::AddRef
248 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
250 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
251 ULONG ref
= InterlockedIncrement(&This
->ref
);
253 TRACE("(%p,%lu)\n", This
, ref
- 1);
258 /**************************************************************************
259 * IShellBrowserImpl_Release
261 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
263 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
264 ULONG ref
= InterlockedDecrement(&This
->ref
);
266 TRACE("(%p,%lu)\n", This
, ref
+ 1);
278 /**************************************************************************
279 * IShellBrowserImpl_GetWindow (IOleWindow)
281 * Inherited from IOleWindow::GetWindow
283 * See Windows documentation for more details
285 * Note : We will never be window less in the File Open dialog
288 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
291 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
293 TRACE("(%p)\n", This
);
298 *phwnd
= This
->hwndOwner
;
300 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
304 /**************************************************************************
305 * IShellBrowserImpl_ContextSensitiveHelp
307 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
310 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
312 TRACE("(%p)\n", This
);
314 /* Feature not implemented */
322 /**************************************************************************
323 * IShellBrowserImpl_BrowseObject
325 * See Windows documentation on IShellBrowser::BrowseObject for more details
327 * This function will override user specified flags and will always
328 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
330 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
335 IShellFolder
*folder
;
337 FileOpenDlgInfos
*fodInfos
;
338 LPITEMIDLIST pidlTmp
;
344 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
346 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This
, pidl
, wFlags
);
347 COMDLG32_DumpSBSPFlags(wFlags
);
349 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
351 /* Format the pidl according to its parameter's category */
352 if(wFlags
& SBSP_RELATIVE
)
355 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
356 if (FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
357 pidl
, NULL
, &IID_IShellFolder
, (void **)&folder
)))
359 ERR("bind to object failed\n");
362 /* create an absolute pidl */
363 pidlTmp
= ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
, pidl
);
365 else if(wFlags
& SBSP_PARENT
)
367 /* Browse the parent folder (ignores the pidl) */
368 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
369 folder
= GetShellFolderFromPidl(pidlTmp
);
371 else /* SBSP_ABSOLUTE is 0x0000 */
373 /* An absolute pidl (relative from the desktop) */
374 pidlTmp
= ILClone(pidl
);
375 folder
= GetShellFolderFromPidl(pidlTmp
);
380 ERR("could not browse to folder\n");
385 /* If the pidl to browse to is equal to the actual pidl ...
386 do nothing and pretend you did it*/
387 if (ILIsEqual(pidlTmp
, fodInfos
->ShellInfos
.pidlAbsCurrent
))
389 IShellFolder_Release(folder
);
391 TRACE("keep current folder\n");
395 /* Release the current DataObject */
396 if (fodInfos
->Shell
.FOIDataObject
)
398 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
399 fodInfos
->Shell
.FOIDataObject
= NULL
;
402 /* Create the associated view */
403 TRACE("create view object\n");
404 if (FAILED(hRes
= IShellFolder_CreateViewObject(folder
, fodInfos
->ShellInfos
.hwndOwner
,
405 &IID_IShellView
, (void **)&psvTmp
)))
407 IShellFolder_Release(folder
);
412 /* Check if listview has focus */
413 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
415 /* Get the foldersettings from the old view */
416 if(fodInfos
->Shell
.FOIShellView
)
417 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
419 /* Release the old fodInfos->Shell.FOIShellView and update its value.
420 We have to update this early since ShellView_CreateViewWindow of native
421 shell32 calls OnStateChange and needs the correct view here.*/
422 if(fodInfos
->Shell
.FOIShellView
)
424 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
425 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
427 fodInfos
->Shell
.FOIShellView
= psvTmp
;
429 /* Release old FOIShellFolder and update its value */
430 if (fodInfos
->Shell
.FOIShellFolder
)
431 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
432 fodInfos
->Shell
.FOIShellFolder
= folder
;
434 /* Release old pidlAbsCurrent and update its value */
435 ILFree(fodInfos
->ShellInfos
.pidlAbsCurrent
);
436 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
438 COMDLG32_UpdateCurrentDir(fodInfos
);
440 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
441 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
443 /* Create the window */
444 TRACE("create view window\n");
445 if (FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
446 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
447 &rectView
, &hwndView
)))
449 WARN("Failed to create view window, hr %#lx.\n", hRes
);
453 fodInfos
->ShellInfos
.hwndView
= hwndView
;
455 /* Set view window control id to 5002 */
456 SetWindowLongPtrW(hwndView
, GWLP_ID
, lst2
);
457 SendMessageW( hwndView
, WM_SETFONT
, SendMessageW( GetParent(hwndView
), WM_GETFONT
, 0, 0 ), FALSE
);
459 /* Select the new folder in the Look In combo box of the Open file dialog */
460 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
462 /* changes the tab order of the ListView to reflect the window's File Dialog */
463 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
464 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
466 /* Since we destroyed the old view if it had focus set focus to the newly created view */
468 SetFocus(fodInfos
->ShellInfos
.hwndView
);
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%08lx %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
= get_filedlg_infoptr(This
->hwndOwner
);
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%08Ix 0x%08Ix %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
= get_filedlg_infoptr(This
->hwndOwner
);
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);
798 /**************************************************************************
799 * IShellBrowserImpl_OnSelChange
801 static HRESULT
IShellBrowserImpl_OnSelChange(IShellBrowserImpl
*This
, const IShellView
*ppshv
)
803 FileOpenDlgInfos
*fodInfos
;
805 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
806 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
808 /* release old selections */
809 if (fodInfos
->Shell
.FOIDataObject
)
810 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
812 /* get a new DataObject from the ShellView */
813 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
814 &IID_IDataObject
, (void**)&fodInfos
->Shell
.FOIDataObject
)))
817 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
819 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
820 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
824 /**************************************************************************
825 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
827 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
832 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
834 TRACE("(%p shv=%p)\n", This
, ppshv
);
838 case CDBOSC_SETFOCUS
:
839 /* FIXME: Reset the default button.
840 This should be taken care of by defdlg. If control
841 other than button receives focus the default button
842 should be restored. */
843 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
846 case CDBOSC_KILLFOCUS
:
848 FileOpenDlgInfos
*fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
849 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
852 LoadStringW(COMDLG32_hInstance
, IDS_SAVE_BUTTON
, szSave
, ARRAY_SIZE(szSave
));
853 SetDlgItemTextW(fodInfos
->ShellInfos
.hwndOwner
, IDOK
, szSave
);
857 case CDBOSC_SELCHANGE
:
858 return IShellBrowserImpl_OnSelChange(This
, ppshv
);
867 /* send_includeitem_notification
869 * Sends a CDN_INCLUDEITEM notification for "pidl" to hwndParentDlg
871 static LRESULT
send_includeitem_notification(HWND hwndParentDlg
, LPCITEMIDLIST pidl
)
873 LRESULT hook_result
= 0;
874 FileOpenDlgInfos
*fodInfos
= get_filedlg_infoptr(hwndParentDlg
);
876 if(!fodInfos
) return 0;
878 if(fodInfos
->DlgInfos
.hwndCustomDlg
)
880 TRACE("call notify CDN_INCLUDEITEM for pidl=%p\n", pidl
);
881 if(fodInfos
->unicode
)
883 OFNOTIFYEXW ofnNotify
;
884 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
885 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
886 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
887 ofnNotify
.hdr
.idFrom
= 0;
888 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
889 ofnNotify
.lpOFN
= fodInfos
->ofnInfos
;
890 hook_result
= SendMessageW(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
894 OFNOTIFYEXA ofnNotify
;
895 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
896 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
897 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
898 ofnNotify
.hdr
.idFrom
= 0;
899 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
900 ofnNotify
.lpOFN
= (LPOPENFILENAMEA
)fodInfos
->ofnInfos
;
901 hook_result
= SendMessageA(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
904 TRACE("Retval: 0x%08Ix\n", hook_result
);
908 /**************************************************************************
909 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
911 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
915 FileOpenDlgInfos
*fodInfos
;
918 WCHAR szPathW
[MAX_PATH
];
920 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
922 TRACE("(%p)\n", This
);
924 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
926 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
927 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
929 if( (ulAttr
& SFGAO_HIDDEN
) || /* hidden */
930 !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
933 /* always include directories and links */
934 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
937 /* if the application takes care of including the item we are done */
938 if(fodInfos
->ofnInfos
->Flags
& OFN_ENABLEINCLUDENOTIFY
&&
939 send_includeitem_notification(This
->hwndOwner
, pidl
))
942 /* Check if there is a mask to apply if not */
943 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !fodInfos
->ShellInfos
.lpstrCurrentFilter
[0])
946 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
948 if (COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
))
950 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
958 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
961 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
962 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
963 IShellBrowserImpl_ICommDlgBrowser_Release
,
964 /* ICommDlgBrowser */
965 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
966 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
967 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
977 /***************************************************************************
978 * IShellBrowserImpl_IServiceProvider_QueryInterface
980 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
981 IServiceProvider
*iface
,
985 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
987 FIXME("(%p)\n", This
);
989 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
992 /**************************************************************************
993 * IShellBrowserImpl_IServiceProvider_AddRef
995 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
997 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
999 FIXME("(%p)\n", This
);
1001 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
1004 /**************************************************************************
1005 * IShellBrowserImpl_IServiceProvider_Release
1007 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
1009 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1011 FIXME("(%p)\n", This
);
1013 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
1016 /**************************************************************************
1017 * IShellBrowserImpl_IServiceProvider_Release
1020 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
1021 * riid = IShellBrowser) to call SendControlMsg ().
1027 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
1028 IServiceProvider
* iface
,
1029 REFGUID guidService
,
1033 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1035 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
1038 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
1039 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppv
);
1041 FIXME("(%p) unknown interface requested\n", This
);
1042 return E_NOINTERFACE
;
1046 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
1049 IShellBrowserImpl_IServiceProvider_QueryInterface
,
1050 IShellBrowserImpl_IServiceProvider_AddRef
,
1051 IShellBrowserImpl_IServiceProvider_Release
,
1052 /* IServiceProvider */
1053 IShellBrowserImpl_IServiceProvider_QueryService