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 FileOpenDlgInfos
*fodInfos
= get_filedlg_infoptr(hwndOwner
);
195 IShellBrowserImpl
*sb
;
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
, REFIID riid
, void **ppvObj
)
220 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
222 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppvObj
);
226 if(IsEqualIID(riid
, &IID_IUnknown
))
227 *ppvObj
= &This
->IShellBrowser_iface
;
228 else if(IsEqualIID(riid
, &IID_IOleWindow
))
229 *ppvObj
= &This
->IShellBrowser_iface
;
230 else if(IsEqualIID(riid
, &IID_IShellBrowser
))
231 *ppvObj
= &This
->IShellBrowser_iface
;
232 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
))
233 *ppvObj
= &This
->ICommDlgBrowser_iface
;
234 else if(IsEqualIID(riid
, &IID_IServiceProvider
))
235 *ppvObj
= &This
->IServiceProvider_iface
;
238 IUnknown_AddRef((IUnknown
*)*ppvObj
);
242 FIXME("unsupported interface, %s\n", debugstr_guid(riid
));
243 return E_NOINTERFACE
;
246 /**************************************************************************
247 * IShellBrowser::AddRef
249 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
251 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
252 ULONG ref
= InterlockedIncrement(&This
->ref
);
254 TRACE("(%p,%u)\n", This
, ref
- 1);
259 /**************************************************************************
260 * IShellBrowserImpl_Release
262 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
264 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
265 ULONG ref
= InterlockedDecrement(&This
->ref
);
267 TRACE("(%p,%u)\n", This
, ref
+ 1);
271 COMDLG32_SHFree(This
);
272 TRACE("-- destroyed\n");
281 /**************************************************************************
282 * IShellBrowserImpl_GetWindow (IOleWindow)
284 * Inherited from IOleWindow::GetWindow
286 * See Windows documentation for more details
288 * Note : We will never be window less in the File Open dialog
291 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
294 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
296 TRACE("(%p)\n", This
);
301 *phwnd
= This
->hwndOwner
;
303 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
307 /**************************************************************************
308 * IShellBrowserImpl_ContextSensitiveHelp
310 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
313 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
315 TRACE("(%p)\n", This
);
317 /* Feature not implemented */
325 /**************************************************************************
326 * IShellBrowserImpl_BrowseObject
328 * See Windows documentation on IShellBrowser::BrowseObject for more details
330 * This function will override user specified flags and will always
331 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
333 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
338 IShellFolder
*psfTmp
;
340 FileOpenDlgInfos
*fodInfos
;
341 LPITEMIDLIST pidlTmp
;
347 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
349 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This
, pidl
, wFlags
);
350 COMDLG32_DumpSBSPFlags(wFlags
);
352 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
354 /* Format the pidl according to its parameter's category */
355 if(wFlags
& SBSP_RELATIVE
)
358 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
359 if(FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
360 pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfTmp
)))
362 ERR("bind to object failed\n");
365 /* create an absolute pidl */
366 pidlTmp
= COMDLG32_PIDL_ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
, pidl
);
368 else if(wFlags
& SBSP_PARENT
)
370 /* Browse the parent folder (ignores the pidl) */
371 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
372 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
375 else /* SBSP_ABSOLUTE is 0x0000 */
377 /* An absolute pidl (relative from the desktop) */
378 pidlTmp
= COMDLG32_PIDL_ILClone(pidl
);
379 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
384 ERR("could not browse to folder\n");
388 /* If the pidl to browse to is equal to the actual pidl ...
389 do nothing and pretend you did it*/
390 if(COMDLG32_PIDL_ILIsEqual(pidlTmp
,fodInfos
->ShellInfos
.pidlAbsCurrent
))
392 IShellFolder_Release(psfTmp
);
393 COMDLG32_SHFree(pidlTmp
);
394 TRACE("keep current folder\n");
398 /* Release the current DataObject */
399 if (fodInfos
->Shell
.FOIDataObject
)
401 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
402 fodInfos
->Shell
.FOIDataObject
= NULL
;
405 /* Create the associated view */
406 TRACE("create view object\n");
407 if(FAILED(hRes
= IShellFolder_CreateViewObject(psfTmp
, fodInfos
->ShellInfos
.hwndOwner
,
408 &IID_IShellView
, (LPVOID
*)&psvTmp
))) goto error
;
410 /* Check if listview has focus */
411 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
413 /* Get the foldersettings from the old view */
414 if(fodInfos
->Shell
.FOIShellView
)
415 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
417 /* Release the old fodInfos->Shell.FOIShellView and update its value.
418 We have to update this early since ShellView_CreateViewWindow of native
419 shell32 calls OnStateChange and needs the correct view here.*/
420 if(fodInfos
->Shell
.FOIShellView
)
422 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
423 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
425 fodInfos
->Shell
.FOIShellView
= psvTmp
;
427 /* Release old FOIShellFolder and update its value */
428 if (fodInfos
->Shell
.FOIShellFolder
)
429 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
430 fodInfos
->Shell
.FOIShellFolder
= psfTmp
;
432 /* Release old pidlAbsCurrent and update its value */
433 COMDLG32_SHFree(fodInfos
->ShellInfos
.pidlAbsCurrent
);
434 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
436 COMDLG32_UpdateCurrentDir(fodInfos
);
438 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
439 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
441 /* Create the window */
442 TRACE("create view window\n");
443 if(FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
444 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
445 &rectView
, &hwndView
))) goto error
;
447 fodInfos
->ShellInfos
.hwndView
= hwndView
;
449 /* Set view window control id to 5002 */
450 SetWindowLongPtrW(hwndView
, GWLP_ID
, lst2
);
451 SendMessageW( hwndView
, WM_SETFONT
, SendMessageW( GetParent(hwndView
), WM_GETFONT
, 0, 0 ), FALSE
);
453 /* Select the new folder in the Look In combo box of the Open file dialog */
454 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
456 /* changes the tab order of the ListView to reflect the window's File Dialog */
457 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
458 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
460 /* Since we destroyed the old view if it had focus set focus to the newly created view */
462 SetFocus(fodInfos
->ShellInfos
.hwndView
);
466 ERR("Failed with error 0x%08x\n", hRes
);
470 /**************************************************************************
471 * IShellBrowserImpl_EnableModelessSB
473 static HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
477 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
479 TRACE("(%p)\n", This
);
481 /* Feature not implemented */
485 /**************************************************************************
486 * IShellBrowserImpl_GetControlWindow
488 static HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
493 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
495 TRACE("(%p)\n", This
);
497 /* Feature not implemented */
501 /**************************************************************************
502 * IShellBrowserImpl_GetViewStateStream
504 static HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
509 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
511 FIXME("(%p 0x%08x %p)\n", This
, grfMode
, ppStrm
);
513 /* Feature not implemented */
517 /**************************************************************************
518 * IShellBrowserImpl_InsertMenusSB
520 static HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
522 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
525 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
527 TRACE("(%p)\n", This
);
529 /* Feature not implemented */
533 /**************************************************************************
534 * IShellBrowserImpl_OnViewWindowActive
536 static HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
540 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
542 TRACE("(%p)\n", This
);
544 /* Feature not implemented */
548 /**************************************************************************
549 * IShellBrowserImpl_QueryActiveShellView
551 static HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
555 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
557 FileOpenDlgInfos
*fodInfos
;
559 TRACE("(%p)\n", This
);
561 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
563 if(!(*ppshv
= fodInfos
->Shell
.FOIShellView
))
567 IShellView_AddRef(fodInfos
->Shell
.FOIShellView
);
571 /**************************************************************************
572 * IShellBrowserImpl_RemoveMenusSB
574 static HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
578 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
580 TRACE("(%p)\n", This
);
582 /* Feature not implemented */
586 /**************************************************************************
587 * IShellBrowserImpl_SendControlMsg
589 static HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
597 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
600 TRACE("(%p)->(0x%08x 0x%08x 0x%08lx 0x%08lx %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
605 lres
= SendDlgItemMessageA( This
->hwndOwner
, IDC_TOOLBAR
, uMsg
, wParam
, lParam
);
608 FIXME("ctrl id: %x\n", id
);
611 if (pret
) *pret
= lres
;
615 /**************************************************************************
616 * IShellBrowserImpl_SetMenuSB
618 static HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
620 HOLEMENU holemenuReserved
,
621 HWND hwndActiveObject
)
624 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
626 TRACE("(%p)\n", This
);
628 /* Feature not implemented */
632 /**************************************************************************
633 * IShellBrowserImpl_SetStatusTextSB
635 static HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
636 LPCOLESTR lpszStatusText
)
639 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
641 TRACE("(%p)\n", This
);
643 /* Feature not implemented */
647 /**************************************************************************
648 * IShellBrowserImpl_SetToolbarItems
650 static HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
651 LPTBBUTTON lpButtons
,
656 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
658 TRACE("(%p)\n", This
);
660 /* Feature not implemented */
664 /**************************************************************************
665 * IShellBrowserImpl_TranslateAcceleratorSB
667 static HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
672 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
674 TRACE("(%p)\n", This
);
676 /* Feature not implemented */
680 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
683 IShellBrowserImpl_QueryInterface
,
684 IShellBrowserImpl_AddRef
,
685 IShellBrowserImpl_Release
,
687 IShellBrowserImpl_GetWindow
,
688 IShellBrowserImpl_ContextSensitiveHelp
,
690 IShellBrowserImpl_InsertMenusSB
,
691 IShellBrowserImpl_SetMenuSB
,
692 IShellBrowserImpl_RemoveMenusSB
,
693 IShellBrowserImpl_SetStatusTextSB
,
694 IShellBrowserImpl_EnableModelessSB
,
695 IShellBrowserImpl_TranslateAcceleratorSB
,
696 IShellBrowserImpl_BrowseObject
,
697 IShellBrowserImpl_GetViewStateStream
,
698 IShellBrowserImpl_GetControlWindow
,
699 IShellBrowserImpl_SendControlMsg
,
700 IShellBrowserImpl_QueryActiveShellView
,
701 IShellBrowserImpl_OnViewWindowActive
,
702 IShellBrowserImpl_SetToolbarItems
711 /***************************************************************************
712 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
714 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
715 ICommDlgBrowser
*iface
,
719 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
721 TRACE("(%p)\n", This
);
723 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
726 /**************************************************************************
727 * IShellBrowserImpl_ICommDlgBrowser_AddRef
729 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser
* iface
)
731 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
733 TRACE("(%p)\n", This
);
735 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
738 /**************************************************************************
739 * IShellBrowserImpl_ICommDlgBrowser_Release
741 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser
* iface
)
743 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
745 TRACE("(%p)\n", This
);
747 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
750 /**************************************************************************
751 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
753 * Called when a user double-clicks in the view or presses the ENTER key
755 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser
*iface
,
759 FileOpenDlgInfos
*fodInfos
;
761 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
763 TRACE("(%p)\n", This
);
765 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
767 /* If the selected object is not a folder, send an IDOK command to parent window */
768 if((pidl
= GetPidlFromDataObject(fodInfos
->Shell
.FOIDataObject
, 1)))
772 ULONG ulAttr
= SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
773 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, (LPCITEMIDLIST
*)&pidl
, &ulAttr
);
774 if (ulAttr
& (SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
) )
776 hRes
= IShellBrowser_BrowseObject(&This
->IShellBrowser_iface
,pidl
,SBSP_RELATIVE
);
777 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
778 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_FOLDERCHANGE
);
782 /* Tell the dialog that the user selected a file */
783 PostMessageA(This
->hwndOwner
, WM_COMMAND
, IDOK
, 0L);
787 /* Free memory used by pidl */
788 COMDLG32_SHFree(pidl
);
796 /**************************************************************************
797 * IShellBrowserImpl_OnSelChange
799 static HRESULT
IShellBrowserImpl_OnSelChange(IShellBrowserImpl
*This
, const IShellView
*ppshv
)
801 FileOpenDlgInfos
*fodInfos
;
803 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
804 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
806 /* release old selections */
807 if (fodInfos
->Shell
.FOIDataObject
)
808 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
810 /* get a new DataObject from the ShellView */
811 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
812 &IID_IDataObject
, (void**)&fodInfos
->Shell
.FOIDataObject
)))
815 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
817 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
818 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
822 /**************************************************************************
823 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
825 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
830 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
832 TRACE("(%p shv=%p)\n", This
, ppshv
);
836 case CDBOSC_SETFOCUS
:
837 /* FIXME: Reset the default button.
838 This should be taken care of by defdlg. If control
839 other than button receives focus the default button
840 should be restored. */
841 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
844 case CDBOSC_KILLFOCUS
:
846 FileOpenDlgInfos
*fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
847 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
850 LoadStringW(COMDLG32_hInstance
, IDS_SAVE_BUTTON
, szSave
, sizeof(szSave
)/sizeof(WCHAR
));
851 SetDlgItemTextW(fodInfos
->ShellInfos
.hwndOwner
, IDOK
, szSave
);
855 case CDBOSC_SELCHANGE
:
856 return IShellBrowserImpl_OnSelChange(This
, ppshv
);
865 /* send_includeitem_notification
867 * Sends a CDN_INCLUDEITEM notification for "pidl" to hwndParentDlg
869 static LRESULT
send_includeitem_notification(HWND hwndParentDlg
, LPCITEMIDLIST pidl
)
871 LRESULT hook_result
= 0;
872 FileOpenDlgInfos
*fodInfos
= get_filedlg_infoptr(hwndParentDlg
);
874 if(!fodInfos
) return 0;
876 if(fodInfos
->DlgInfos
.hwndCustomDlg
)
878 TRACE("call notify CDN_INCLUDEITEM for pidl=%p\n", pidl
);
879 if(fodInfos
->unicode
)
881 OFNOTIFYEXW ofnNotify
;
882 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
883 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
884 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
885 ofnNotify
.hdr
.idFrom
= 0;
886 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
887 ofnNotify
.lpOFN
= fodInfos
->ofnInfos
;
888 hook_result
= SendMessageW(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
892 OFNOTIFYEXA ofnNotify
;
893 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
894 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
895 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
896 ofnNotify
.hdr
.idFrom
= 0;
897 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
898 ofnNotify
.lpOFN
= (LPOPENFILENAMEA
)fodInfos
->ofnInfos
;
899 hook_result
= SendMessageA(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
902 TRACE("Retval: 0x%08lx\n", hook_result
);
906 /**************************************************************************
907 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
909 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
913 FileOpenDlgInfos
*fodInfos
;
916 WCHAR szPathW
[MAX_PATH
];
918 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
920 TRACE("(%p)\n", This
);
922 fodInfos
= get_filedlg_infoptr(This
->hwndOwner
);
924 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
925 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
927 if( (ulAttr
& SFGAO_HIDDEN
) || /* hidden */
928 !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
931 /* always include directories and links */
932 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
935 /* if the application takes care of including the item we are done */
936 if(fodInfos
->ofnInfos
->Flags
& OFN_ENABLEINCLUDENOTIFY
&&
937 send_includeitem_notification(This
->hwndOwner
, pidl
))
940 /* Check if there is a mask to apply if not */
941 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !fodInfos
->ShellInfos
.lpstrCurrentFilter
[0])
944 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
946 if (COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
))
948 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
956 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
959 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
960 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
961 IShellBrowserImpl_ICommDlgBrowser_Release
,
962 /* ICommDlgBrowser */
963 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
964 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
965 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
975 /***************************************************************************
976 * IShellBrowserImpl_IServiceProvider_QueryInterface
978 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
979 IServiceProvider
*iface
,
983 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
985 FIXME("(%p)\n", This
);
987 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
990 /**************************************************************************
991 * IShellBrowserImpl_IServiceProvider_AddRef
993 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
995 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
997 FIXME("(%p)\n", This
);
999 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
1002 /**************************************************************************
1003 * IShellBrowserImpl_IServiceProvider_Release
1005 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
1007 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1009 FIXME("(%p)\n", This
);
1011 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
1014 /**************************************************************************
1015 * IShellBrowserImpl_IServiceProvider_Release
1018 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
1019 * riid = IShellBrowser) to call SendControlMsg ().
1025 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
1026 IServiceProvider
* iface
,
1027 REFGUID guidService
,
1031 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1033 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
1036 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
1037 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppv
);
1039 FIXME("(%p) unknown interface requested\n", This
);
1040 return E_NOINTERFACE
;
1044 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
1047 IShellBrowserImpl_IServiceProvider_QueryInterface
,
1048 IShellBrowserImpl_IServiceProvider_AddRef
,
1049 IShellBrowserImpl_IServiceProvider_Release
,
1050 /* IServiceProvider */
1051 IShellBrowserImpl_IServiceProvider_QueryService