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 IShellBrowser IShellBrowser_iface
;
28 ICommDlgBrowser ICommDlgBrowser_iface
;
29 IServiceProvider IServiceProvider_iface
;
30 LONG ref
; /* Reference counter */
31 HWND hwndOwner
; /* Owner dialog of the interface */
35 static inline IShellBrowserImpl
*impl_from_IShellBrowser(IShellBrowser
*iface
)
37 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IShellBrowser_iface
);
40 static inline IShellBrowserImpl
*impl_from_ICommDlgBrowser( ICommDlgBrowser
*iface
)
42 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, ICommDlgBrowser_iface
);
45 static inline IShellBrowserImpl
*impl_from_IServiceProvider( IServiceProvider
*iface
)
47 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IServiceProvider_iface
);
50 /**************************************************************************
53 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
54 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
55 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
;
61 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
62 static void COMDLG32_DumpSBSPFlags(UINT uflags
)
64 if (TRACE_ON(commdlg
))
71 #define FE(x) { x, #x}
72 /* SBSP_DEFBROWSER == 0 */
76 /* SBSP_DEFMODE == 0 */
80 FE(SBSP_NOTRANSFERHIST
),
82 /* SBSP_ABSOLUTE == 0 */
85 FE(SBSP_NAVIGATEBACK
),
86 FE(SBSP_NAVIGATEFORWARD
),
87 FE(SBSP_ALLOW_AUTONAVIGATE
),
89 FE(SBSP_NOAUTOSELECT
),
90 FE(SBSP_WRITENOHISTORY
),
93 FE(SBSP_INITIATEDBYHLINKFRAME
),
96 TRACE("SBSP Flags: %08x =", uflags
);
97 for (i
= 0; i
< (sizeof(flags
) / sizeof(flags
[0])); i
++)
98 if (flags
[i
].mask
& uflags
)
99 TRACE("%s ", flags
[i
].name
);
104 static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos
*fodInfos
)
106 LPSHELLFOLDER psfDesktop
;
110 res
= SHGetDesktopFolder(&psfDesktop
);
114 res
= IShellFolder_GetDisplayNameOf(psfDesktop
, fodInfos
->ShellInfos
.pidlAbsCurrent
,
115 SHGDN_FORPARSING
, &strret
);
116 if (SUCCEEDED(res
)) {
117 WCHAR wszCurrentDir
[MAX_PATH
];
119 res
= StrRetToBufW(&strret
, fodInfos
->ShellInfos
.pidlAbsCurrent
, wszCurrentDir
, MAX_PATH
);
121 SetCurrentDirectoryW(wszCurrentDir
);
124 IShellFolder_Release(psfDesktop
);
127 /* copied from shell32 to avoid linking to it */
128 static BOOL
COMDLG32_StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, LPCITEMIDLIST pidl
)
130 TRACE("dest=%p len=0x%x strret=%p pidl=%p\n", dest
, len
, src
, pidl
);
135 lstrcpynW(dest
, src
->u
.pOleStr
, len
);
136 COMDLG32_SHFree(src
->u
.pOleStr
);
140 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, dest
, len
))
141 ((LPWSTR
)dest
)[len
-1] = 0;
147 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
,
149 ((LPWSTR
)dest
)[len
-1] = 0;
154 FIXME("unknown type!\n");
156 { *(LPWSTR
)dest
= '\0';
167 /**************************************************************************
168 * IShellBrowserImpl_Construct
170 IShellBrowser
* IShellBrowserImpl_Construct(HWND hwndOwner
)
172 FileOpenDlgInfos
*fodInfos
= get_filedlg_infoptr(hwndOwner
);
173 IShellBrowserImpl
*sb
;
175 sb
= COMDLG32_SHAlloc(sizeof(IShellBrowserImpl
));
177 /* Initialisation of the member variables */
179 sb
->hwndOwner
= hwndOwner
;
181 /* Initialisation of the vTables */
182 sb
->IShellBrowser_iface
.lpVtbl
= &IShellBrowserImpl_Vtbl
;
183 sb
->ICommDlgBrowser_iface
.lpVtbl
= &IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
184 sb
->IServiceProvider_iface
.lpVtbl
= &IShellBrowserImpl_IServiceProvider_Vtbl
;
185 SHGetSpecialFolderLocation(hwndOwner
, CSIDL_DESKTOP
,
186 &fodInfos
->ShellInfos
.pidlAbsCurrent
);
190 return &sb
->IShellBrowser_iface
;
193 /***************************************************************************
194 * IShellBrowserImpl_QueryInterface
196 static HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
, REFIID riid
, void **ppvObj
)
198 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
200 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppvObj
);
204 if(IsEqualIID(riid
, &IID_IUnknown
))
205 *ppvObj
= &This
->IShellBrowser_iface
;
206 else if(IsEqualIID(riid
, &IID_IOleWindow
))
207 *ppvObj
= &This
->IShellBrowser_iface
;
208 else if(IsEqualIID(riid
, &IID_IShellBrowser
))
209 *ppvObj
= &This
->IShellBrowser_iface
;
210 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
))
211 *ppvObj
= &This
->ICommDlgBrowser_iface
;
212 else if(IsEqualIID(riid
, &IID_IServiceProvider
))
213 *ppvObj
= &This
->IServiceProvider_iface
;
216 IUnknown_AddRef((IUnknown
*)*ppvObj
);
220 FIXME("unsupported interface, %s\n", debugstr_guid(riid
));
221 return E_NOINTERFACE
;
224 /**************************************************************************
225 * IShellBrowser::AddRef
227 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
229 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
230 ULONG ref
= InterlockedIncrement(&This
->ref
);
232 TRACE("(%p,%u)\n", This
, ref
- 1);
237 /**************************************************************************
238 * IShellBrowserImpl_Release
240 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
242 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
243 ULONG ref
= InterlockedDecrement(&This
->ref
);
245 TRACE("(%p,%u)\n", This
, ref
+ 1);
249 COMDLG32_SHFree(This
);
250 TRACE("-- destroyed\n");
259 /**************************************************************************
260 * IShellBrowserImpl_GetWindow (IOleWindow)
262 * Inherited from IOleWindow::GetWindow
264 * See Windows documentation for more details
266 * Note : We will never be window less in the File Open dialog
269 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
272 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
274 TRACE("(%p)\n", This
);
279 *phwnd
= This
->hwndOwner
;
281 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
285 /**************************************************************************
286 * IShellBrowserImpl_ContextSensitiveHelp
288 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
291 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
293 TRACE("(%p)\n", This
);
295 /* Feature not implemented */
303 /**************************************************************************
304 * IShellBrowserImpl_BrowseObject
306 * See Windows documentation on IShellBrowser::BrowseObject for more details
308 * This function will override user specified flags and will always
309 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
311 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
316 IShellFolder
*psfTmp
;
318 FileOpenDlgInfos
*fodInfos
;
319 LPITEMIDLIST pidlTmp
;
325 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
327 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This
, pidl
, wFlags
);
328 COMDLG32_DumpSBSPFlags(wFlags
);
330 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
332 /* Format the pidl according to its parameter's category */
333 if(wFlags
& SBSP_RELATIVE
)
336 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
337 if(FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
338 pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfTmp
)))
340 ERR("bind to object failed\n");
343 /* create an absolute pidl */
344 pidlTmp
= COMDLG32_PIDL_ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
, pidl
);
346 else if(wFlags
& SBSP_PARENT
)
348 /* Browse the parent folder (ignores the pidl) */
349 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
350 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
353 else /* SBSP_ABSOLUTE is 0x0000 */
355 /* An absolute pidl (relative from the desktop) */
356 pidlTmp
= COMDLG32_PIDL_ILClone(pidl
);
357 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
362 ERR("could not browse to folder\n");
366 /* If the pidl to browse to is equal to the actual pidl ...
367 do nothing and pretend you did it*/
368 if(COMDLG32_PIDL_ILIsEqual(pidlTmp
,fodInfos
->ShellInfos
.pidlAbsCurrent
))
370 IShellFolder_Release(psfTmp
);
371 COMDLG32_SHFree(pidlTmp
);
372 TRACE("keep current folder\n");
376 /* Release the current DataObject */
377 if (fodInfos
->Shell
.FOIDataObject
)
379 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
380 fodInfos
->Shell
.FOIDataObject
= NULL
;
383 /* Create the associated view */
384 TRACE("create view object\n");
385 if(FAILED(hRes
= IShellFolder_CreateViewObject(psfTmp
, fodInfos
->ShellInfos
.hwndOwner
,
386 &IID_IShellView
, (LPVOID
*)&psvTmp
))) goto error
;
388 /* Check if listview has focus */
389 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
391 /* Get the foldersettings from the old view */
392 if(fodInfos
->Shell
.FOIShellView
)
393 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
395 /* Release the old fodInfos->Shell.FOIShellView and update its value.
396 We have to update this early since ShellView_CreateViewWindow of native
397 shell32 calls OnStateChange and needs the correct view here.*/
398 if(fodInfos
->Shell
.FOIShellView
)
400 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
401 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
403 fodInfos
->Shell
.FOIShellView
= psvTmp
;
405 /* Release old FOIShellFolder and update its value */
406 if (fodInfos
->Shell
.FOIShellFolder
)
407 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
408 fodInfos
->Shell
.FOIShellFolder
= psfTmp
;
410 /* Release old pidlAbsCurrent and update its value */
411 COMDLG32_SHFree(fodInfos
->ShellInfos
.pidlAbsCurrent
);
412 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
414 COMDLG32_UpdateCurrentDir(fodInfos
);
416 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
417 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
419 /* Create the window */
420 TRACE("create view window\n");
421 if(FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
422 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
423 &rectView
, &hwndView
))) goto error
;
425 fodInfos
->ShellInfos
.hwndView
= hwndView
;
427 /* Set view window control id to 5002 */
428 SetWindowLongPtrW(hwndView
, GWLP_ID
, lst2
);
429 SendMessageW( hwndView
, WM_SETFONT
, SendMessageW( GetParent(hwndView
), WM_GETFONT
, 0, 0 ), FALSE
);
431 /* Select the new folder in the Look In combo box of the Open file dialog */
432 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
434 /* changes the tab order of the ListView to reflect the window's File Dialog */
435 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
436 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
438 /* Since we destroyed the old view if it had focus set focus to the newly created view */
440 SetFocus(fodInfos
->ShellInfos
.hwndView
);
444 ERR("Failed with error 0x%08x\n", hRes
);
448 /**************************************************************************
449 * IShellBrowserImpl_EnableModelessSB
451 static HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
455 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
457 TRACE("(%p)\n", This
);
459 /* Feature not implemented */
463 /**************************************************************************
464 * IShellBrowserImpl_GetControlWindow
466 static HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
471 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
473 TRACE("(%p)\n", This
);
475 /* Feature not implemented */
479 /**************************************************************************
480 * IShellBrowserImpl_GetViewStateStream
482 static HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
487 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
489 FIXME("(%p 0x%08x %p)\n", This
, grfMode
, ppStrm
);
491 /* Feature not implemented */
495 /**************************************************************************
496 * IShellBrowserImpl_InsertMenusSB
498 static HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
500 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
503 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
505 TRACE("(%p)\n", This
);
507 /* Feature not implemented */
511 /**************************************************************************
512 * IShellBrowserImpl_OnViewWindowActive
514 static HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
518 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
520 TRACE("(%p)\n", This
);
522 /* Feature not implemented */
526 /**************************************************************************
527 * IShellBrowserImpl_QueryActiveShellView
529 static HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
533 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
535 FileOpenDlgInfos
*fodInfos
;
537 TRACE("(%p)\n", This
);
539 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
541 if(!(*ppshv
= fodInfos
->Shell
.FOIShellView
))
545 IShellView_AddRef(fodInfos
->Shell
.FOIShellView
);
549 /**************************************************************************
550 * IShellBrowserImpl_RemoveMenusSB
552 static HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
556 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
558 TRACE("(%p)\n", This
);
560 /* Feature not implemented */
564 /**************************************************************************
565 * IShellBrowserImpl_SendControlMsg
567 static HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
575 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
578 TRACE("(%p)->(0x%08x 0x%08x 0x%08lx 0x%08lx %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
583 lres
= SendDlgItemMessageA( This
->hwndOwner
, IDC_TOOLBAR
, uMsg
, wParam
, lParam
);
586 FIXME("ctrl id: %x\n", id
);
589 if (pret
) *pret
= lres
;
593 /**************************************************************************
594 * IShellBrowserImpl_SetMenuSB
596 static HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
598 HOLEMENU holemenuReserved
,
599 HWND hwndActiveObject
)
602 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
604 TRACE("(%p)\n", This
);
606 /* Feature not implemented */
610 /**************************************************************************
611 * IShellBrowserImpl_SetStatusTextSB
613 static HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
614 LPCOLESTR lpszStatusText
)
617 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
619 TRACE("(%p)\n", This
);
621 /* Feature not implemented */
625 /**************************************************************************
626 * IShellBrowserImpl_SetToolbarItems
628 static HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
629 LPTBBUTTON lpButtons
,
634 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
636 TRACE("(%p)\n", This
);
638 /* Feature not implemented */
642 /**************************************************************************
643 * IShellBrowserImpl_TranslateAcceleratorSB
645 static HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
650 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
652 TRACE("(%p)\n", This
);
654 /* Feature not implemented */
658 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
661 IShellBrowserImpl_QueryInterface
,
662 IShellBrowserImpl_AddRef
,
663 IShellBrowserImpl_Release
,
665 IShellBrowserImpl_GetWindow
,
666 IShellBrowserImpl_ContextSensitiveHelp
,
668 IShellBrowserImpl_InsertMenusSB
,
669 IShellBrowserImpl_SetMenuSB
,
670 IShellBrowserImpl_RemoveMenusSB
,
671 IShellBrowserImpl_SetStatusTextSB
,
672 IShellBrowserImpl_EnableModelessSB
,
673 IShellBrowserImpl_TranslateAcceleratorSB
,
674 IShellBrowserImpl_BrowseObject
,
675 IShellBrowserImpl_GetViewStateStream
,
676 IShellBrowserImpl_GetControlWindow
,
677 IShellBrowserImpl_SendControlMsg
,
678 IShellBrowserImpl_QueryActiveShellView
,
679 IShellBrowserImpl_OnViewWindowActive
,
680 IShellBrowserImpl_SetToolbarItems
689 /***************************************************************************
690 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
692 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
693 ICommDlgBrowser
*iface
,
697 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
699 TRACE("(%p)\n", This
);
701 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
704 /**************************************************************************
705 * IShellBrowserImpl_ICommDlgBrowser_AddRef
707 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser
* iface
)
709 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
711 TRACE("(%p)\n", This
);
713 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
716 /**************************************************************************
717 * IShellBrowserImpl_ICommDlgBrowser_Release
719 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser
* iface
)
721 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
723 TRACE("(%p)\n", This
);
725 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
728 /**************************************************************************
729 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
731 * Called when a user double-clicks in the view or presses the ENTER key
733 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser
*iface
,
737 FileOpenDlgInfos
*fodInfos
;
739 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
741 TRACE("(%p)\n", This
);
743 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
745 /* If the selected object is not a folder, send an IDOK command to parent window */
746 if((pidl
= GetPidlFromDataObject(fodInfos
->Shell
.FOIDataObject
, 1)))
750 ULONG ulAttr
= SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
751 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, (LPCITEMIDLIST
*)&pidl
, &ulAttr
);
752 if (ulAttr
& (SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
) )
754 hRes
= IShellBrowser_BrowseObject(&This
->IShellBrowser_iface
,pidl
,SBSP_RELATIVE
);
755 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
756 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_FOLDERCHANGE
);
760 /* Tell the dialog that the user selected a file */
761 PostMessageA(This
->hwndOwner
, WM_COMMAND
, IDOK
, 0L);
765 /* Free memory used by pidl */
766 COMDLG32_SHFree(pidl
);
774 /**************************************************************************
775 * IShellBrowserImpl_OnSelChange
777 static HRESULT
IShellBrowserImpl_OnSelChange(IShellBrowserImpl
*This
, const IShellView
*ppshv
)
779 FileOpenDlgInfos
*fodInfos
;
781 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
782 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
784 /* release old selections */
785 if (fodInfos
->Shell
.FOIDataObject
)
786 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
788 /* get a new DataObject from the ShellView */
789 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
790 &IID_IDataObject
, (void**)&fodInfos
->Shell
.FOIDataObject
)))
793 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
795 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
796 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
800 /**************************************************************************
801 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
803 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
808 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
810 TRACE("(%p shv=%p)\n", This
, ppshv
);
814 case CDBOSC_SETFOCUS
:
815 /* FIXME: Reset the default button.
816 This should be taken care of by defdlg. If control
817 other than button receives focus the default button
818 should be restored. */
819 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
822 case CDBOSC_KILLFOCUS
:
824 FileOpenDlgInfos
*fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
825 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
828 LoadStringW(COMDLG32_hInstance
, IDS_SAVE_BUTTON
, szSave
, sizeof(szSave
)/sizeof(WCHAR
));
829 SetDlgItemTextW(fodInfos
->ShellInfos
.hwndOwner
, IDOK
, szSave
);
833 case CDBOSC_SELCHANGE
:
834 return IShellBrowserImpl_OnSelChange(This
, ppshv
);
843 /* send_includeitem_notification
845 * Sends a CDN_INCLUDEITEM notification for "pidl" to hwndParentDlg
847 static LRESULT
send_includeitem_notification(HWND hwndParentDlg
, LPCITEMIDLIST pidl
)
849 LRESULT hook_result
= 0;
850 FileOpenDlgInfos
*fodInfos
= get_filedlg_infoptr(hwndParentDlg
);
852 if(!fodInfos
) return 0;
854 if(fodInfos
->DlgInfos
.hwndCustomDlg
)
856 TRACE("call notify CDN_INCLUDEITEM for pidl=%p\n", pidl
);
857 if(fodInfos
->unicode
)
859 OFNOTIFYEXW ofnNotify
;
860 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
861 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
862 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
863 ofnNotify
.hdr
.idFrom
= 0;
864 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
865 ofnNotify
.lpOFN
= fodInfos
->ofnInfos
;
866 hook_result
= SendMessageW(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
870 OFNOTIFYEXA ofnNotify
;
871 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
872 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
873 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
874 ofnNotify
.hdr
.idFrom
= 0;
875 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
876 ofnNotify
.lpOFN
= (LPOPENFILENAMEA
)fodInfos
->ofnInfos
;
877 hook_result
= SendMessageA(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
880 TRACE("Retval: 0x%08lx\n", hook_result
);
884 /**************************************************************************
885 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
887 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
891 FileOpenDlgInfos
*fodInfos
;
894 WCHAR szPathW
[MAX_PATH
];
896 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
898 TRACE("(%p)\n", This
);
900 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
902 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
903 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
905 if( (ulAttr
& SFGAO_HIDDEN
) || /* hidden */
906 !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
909 /* always include directories and links */
910 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
913 /* if the application takes care of including the item we are done */
914 if(fodInfos
->ofnInfos
->Flags
& OFN_ENABLEINCLUDENOTIFY
&&
915 send_includeitem_notification(This
->hwndOwner
, pidl
))
918 /* Check if there is a mask to apply if not */
919 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !fodInfos
->ShellInfos
.lpstrCurrentFilter
[0])
922 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
924 if (COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
))
926 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
934 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
937 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
938 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
939 IShellBrowserImpl_ICommDlgBrowser_Release
,
940 /* ICommDlgBrowser */
941 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
942 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
943 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
953 /***************************************************************************
954 * IShellBrowserImpl_IServiceProvider_QueryInterface
956 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
957 IServiceProvider
*iface
,
961 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
963 FIXME("(%p)\n", This
);
965 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
968 /**************************************************************************
969 * IShellBrowserImpl_IServiceProvider_AddRef
971 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
973 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
975 FIXME("(%p)\n", This
);
977 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
980 /**************************************************************************
981 * IShellBrowserImpl_IServiceProvider_Release
983 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
985 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
987 FIXME("(%p)\n", This
);
989 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
992 /**************************************************************************
993 * IShellBrowserImpl_IServiceProvider_Release
996 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
997 * riid = IShellBrowser) to call SendControlMsg ().
1003 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
1004 IServiceProvider
* iface
,
1005 REFGUID guidService
,
1009 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1011 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
1014 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
1015 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppv
);
1017 FIXME("(%p) unknown interface requested\n", This
);
1018 return E_NOINTERFACE
;
1022 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
1025 IShellBrowserImpl_IServiceProvider_QueryInterface
,
1026 IShellBrowserImpl_IServiceProvider_AddRef
,
1027 IShellBrowserImpl_IServiceProvider_Release
,
1028 /* IServiceProvider */
1029 IShellBrowserImpl_IServiceProvider_QueryService