2 * Implementation of IShellBrowser for the File Open common dialog
4 * Copyright 1999 Francois Boisvert
5 * Copyright 1999, 2000 Juergen Schmied
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_NO_STATUS
24 #define COM_NO_WINDOWS_H
31 #define NONAMELESSUNION
32 #define NONAMELESSSTRUCT
42 #define NO_SHLWAPI_STREAM
44 #include <filedlgbrowser.h>
46 //#include "shlguid.h"
47 //#include "servprov.h"
48 #include <wine/debug.h>
50 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
55 IShellBrowser IShellBrowser_iface
;
56 ICommDlgBrowser ICommDlgBrowser_iface
;
57 IServiceProvider IServiceProvider_iface
;
58 LONG ref
; /* Reference counter */
59 HWND hwndOwner
; /* Owner dialog of the interface */
63 static inline IShellBrowserImpl
*impl_from_IShellBrowser(IShellBrowser
*iface
)
65 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IShellBrowser_iface
);
68 static inline IShellBrowserImpl
*impl_from_ICommDlgBrowser( ICommDlgBrowser
*iface
)
70 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, ICommDlgBrowser_iface
);
73 static inline IShellBrowserImpl
*impl_from_IServiceProvider( IServiceProvider
*iface
)
75 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IServiceProvider_iface
);
78 /**************************************************************************
81 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
82 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
83 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
;
89 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
90 static void COMDLG32_DumpSBSPFlags(UINT uflags
)
92 if (TRACE_ON(commdlg
))
99 #define FE(x) { x, #x}
100 /* SBSP_DEFBROWSER == 0 */
101 FE(SBSP_SAMEBROWSER
),
104 /* SBSP_DEFMODE == 0 */
106 FE(SBSP_EXPLOREMODE
),
108 FE(SBSP_NOTRANSFERHIST
),
110 /* SBSP_ABSOLUTE == 0 */
113 FE(SBSP_NAVIGATEBACK
),
114 FE(SBSP_NAVIGATEFORWARD
),
115 FE(SBSP_ALLOW_AUTONAVIGATE
),
117 FE(SBSP_NOAUTOSELECT
),
118 FE(SBSP_WRITENOHISTORY
),
121 FE(SBSP_INITIATEDBYHLINKFRAME
),
124 TRACE("SBSP Flags: %08x =", uflags
);
125 for (i
= 0; i
< (sizeof(flags
) / sizeof(flags
[0])); i
++)
126 if (flags
[i
].mask
& uflags
)
127 TRACE("%s ", flags
[i
].name
);
132 static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos
*fodInfos
)
134 LPSHELLFOLDER psfDesktop
;
138 res
= SHGetDesktopFolder(&psfDesktop
);
142 res
= IShellFolder_GetDisplayNameOf(psfDesktop
, fodInfos
->ShellInfos
.pidlAbsCurrent
,
143 SHGDN_FORPARSING
, &strret
);
144 if (SUCCEEDED(res
)) {
145 WCHAR wszCurrentDir
[MAX_PATH
];
147 res
= StrRetToBufW(&strret
, fodInfos
->ShellInfos
.pidlAbsCurrent
, wszCurrentDir
, MAX_PATH
);
149 SetCurrentDirectoryW(wszCurrentDir
);
152 IShellFolder_Release(psfDesktop
);
155 /* copied from shell32 to avoid linking to it */
156 static BOOL
COMDLG32_StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, LPCITEMIDLIST pidl
)
158 TRACE("dest=%p len=0x%x strret=%p pidl=%p\n", dest
, len
, src
, pidl
);
163 lstrcpynW(dest
, src
->u
.pOleStr
, len
);
164 COMDLG32_SHFree(src
->u
.pOleStr
);
168 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, dest
, len
))
169 ((LPWSTR
)dest
)[len
-1] = 0;
175 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
,
177 ((LPWSTR
)dest
)[len
-1] = 0;
182 FIXME("unknown type!\n");
184 { *(LPWSTR
)dest
= '\0';
195 /**************************************************************************
196 * IShellBrowserImpl_Construct
198 IShellBrowser
* IShellBrowserImpl_Construct(HWND hwndOwner
)
200 IShellBrowserImpl
*sb
;
201 FileOpenDlgInfos
*fodInfos
= GetPropA(hwndOwner
,FileOpenDlgInfosStr
);
203 sb
= COMDLG32_SHAlloc(sizeof(IShellBrowserImpl
));
205 /* Initialisation of the member variables */
207 sb
->hwndOwner
= hwndOwner
;
209 /* Initialisation of the vTables */
210 sb
->IShellBrowser_iface
.lpVtbl
= &IShellBrowserImpl_Vtbl
;
211 sb
->ICommDlgBrowser_iface
.lpVtbl
= &IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
212 sb
->IServiceProvider_iface
.lpVtbl
= &IShellBrowserImpl_IServiceProvider_Vtbl
;
213 SHGetSpecialFolderLocation(hwndOwner
, CSIDL_DESKTOP
,
214 &fodInfos
->ShellInfos
.pidlAbsCurrent
);
218 return &sb
->IShellBrowser_iface
;
221 /***************************************************************************
222 * IShellBrowserImpl_QueryInterface
224 static HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
228 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
230 TRACE("(%p)\n\t%s\n", This
, debugstr_guid(riid
));
234 if(IsEqualIID(riid
, &IID_IUnknown
))
235 *ppvObj
= &This
->IShellBrowser_iface
;
236 else if(IsEqualIID(riid
, &IID_IOleWindow
))
237 *ppvObj
= &This
->IShellBrowser_iface
;
238 else if(IsEqualIID(riid
, &IID_IShellBrowser
))
239 *ppvObj
= &This
->IShellBrowser_iface
;
240 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
))
241 *ppvObj
= &This
->ICommDlgBrowser_iface
;
242 else if(IsEqualIID(riid
, &IID_IServiceProvider
))
243 *ppvObj
= &This
->IServiceProvider_iface
;
246 IUnknown_AddRef((IUnknown
*)*ppvObj
);
250 FIXME("Unknown interface requested\n");
251 return E_NOINTERFACE
;
254 /**************************************************************************
255 * IShellBrowser::AddRef
257 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
259 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
260 ULONG ref
= InterlockedIncrement(&This
->ref
);
262 TRACE("(%p,%u)\n", This
, ref
- 1);
267 /**************************************************************************
268 * IShellBrowserImpl_Release
270 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
272 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
273 ULONG ref
= InterlockedDecrement(&This
->ref
);
275 TRACE("(%p,%u)\n", This
, ref
+ 1);
279 COMDLG32_SHFree(This
);
280 TRACE("-- destroyed\n");
290 /**************************************************************************
291 * IShellBrowserImpl_GetWindow (IOleWindow)
293 * Inherited from IOleWindow::GetWindow
295 * See Windows documentation for more details
297 * Note : We will never be window less in the File Open dialog
300 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
303 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
305 TRACE("(%p)\n", This
);
310 *phwnd
= This
->hwndOwner
;
312 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
316 /**************************************************************************
317 * IShellBrowserImpl_ContextSensitiveHelp
319 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
322 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
324 TRACE("(%p)\n", This
);
326 /* Feature not implemented */
334 /**************************************************************************
335 * IShellBrowserImpl_BrowseObject
337 * See Windows documentation on IShellBrowser::BrowseObject for more details
339 * This function will override user specified flags and will always
340 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
342 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
347 IShellFolder
*psfTmp
;
349 FileOpenDlgInfos
*fodInfos
;
350 LPITEMIDLIST pidlTmp
;
356 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
358 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This
, pidl
, wFlags
);
359 COMDLG32_DumpSBSPFlags(wFlags
);
361 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
363 /* Format the pidl according to its parameter's category */
364 if(wFlags
& SBSP_RELATIVE
)
367 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
368 if(FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
369 pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfTmp
)))
371 ERR("bind to object failed\n");
374 /* create an absolute pidl */
375 pidlTmp
= COMDLG32_PIDL_ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
, pidl
);
377 else if(wFlags
& SBSP_PARENT
)
379 /* Browse the parent folder (ignores the pidl) */
380 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
381 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
384 else /* SBSP_ABSOLUTE is 0x0000 */
386 /* An absolute pidl (relative from the desktop) */
387 pidlTmp
= COMDLG32_PIDL_ILClone(pidl
);
388 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
393 ERR("could not browse to folder\n");
397 /* If the pidl to browse to is equal to the actual pidl ...
398 do nothing and pretend you did it*/
399 if(COMDLG32_PIDL_ILIsEqual(pidlTmp
,fodInfos
->ShellInfos
.pidlAbsCurrent
))
401 IShellFolder_Release(psfTmp
);
402 COMDLG32_SHFree(pidlTmp
);
403 TRACE("keep current folder\n");
407 /* Release the current DataObject */
408 if (fodInfos
->Shell
.FOIDataObject
)
410 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
411 fodInfos
->Shell
.FOIDataObject
= NULL
;
414 /* Create the associated view */
415 TRACE("create view object\n");
416 if(FAILED(hRes
= IShellFolder_CreateViewObject(psfTmp
, fodInfos
->ShellInfos
.hwndOwner
,
417 &IID_IShellView
, (LPVOID
*)&psvTmp
))) goto error
;
419 /* Check if listview has focus */
420 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
422 /* Get the foldersettings from the old view */
423 if(fodInfos
->Shell
.FOIShellView
)
424 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
426 /* Release the old fodInfos->Shell.FOIShellView and update its value.
427 We have to update this early since ShellView_CreateViewWindow of native
428 shell32 calls OnStateChange and needs the correct view here.*/
429 if(fodInfos
->Shell
.FOIShellView
)
431 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
432 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
434 fodInfos
->Shell
.FOIShellView
= psvTmp
;
436 /* Release old FOIShellFolder and update its value */
437 if (fodInfos
->Shell
.FOIShellFolder
)
438 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
439 fodInfos
->Shell
.FOIShellFolder
= psfTmp
;
441 /* Release old pidlAbsCurrent and update its value */
442 COMDLG32_SHFree(fodInfos
->ShellInfos
.pidlAbsCurrent
);
443 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
445 COMDLG32_UpdateCurrentDir(fodInfos
);
447 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
448 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
450 /* Create the window */
451 TRACE("create view window\n");
452 if(FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
453 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
454 &rectView
, &hwndView
))) goto error
;
456 fodInfos
->ShellInfos
.hwndView
= hwndView
;
458 /* Set view window control id to 5002 */
459 SetWindowLongPtrW(hwndView
, GWLP_ID
, lst2
);
460 SendMessageW( hwndView
, WM_SETFONT
, SendMessageW( GetParent(hwndView
), WM_GETFONT
, 0, 0 ), FALSE
);
462 /* Select the new folder in the Look In combo box of the Open file dialog */
463 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
465 /* changes the tab order of the ListView to reflect the window's File Dialog */
466 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
467 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
469 /* Since we destroyed the old view if it had focus set focus to the newly created view */
471 SetFocus(fodInfos
->ShellInfos
.hwndView
);
475 ERR("Failed with error 0x%08x\n", hRes
);
479 /**************************************************************************
480 * IShellBrowserImpl_EnableModelessSB
482 static HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
486 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
488 TRACE("(%p)\n", This
);
490 /* Feature not implemented */
494 /**************************************************************************
495 * IShellBrowserImpl_GetControlWindow
497 static HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
502 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
504 TRACE("(%p)\n", This
);
506 /* Feature not implemented */
510 /**************************************************************************
511 * IShellBrowserImpl_GetViewStateStream
513 static HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
518 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
520 FIXME("(%p 0x%08x %p)\n", This
, grfMode
, ppStrm
);
522 /* Feature not implemented */
526 /**************************************************************************
527 * IShellBrowserImpl_InsertMenusSB
529 static HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
531 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
534 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
536 TRACE("(%p)\n", This
);
538 /* Feature not implemented */
542 /**************************************************************************
543 * IShellBrowserImpl_OnViewWindowActive
545 static HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
549 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
551 TRACE("(%p)\n", This
);
553 /* Feature not implemented */
557 /**************************************************************************
558 * IShellBrowserImpl_QueryActiveShellView
560 static HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
564 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
566 FileOpenDlgInfos
*fodInfos
;
568 TRACE("(%p)\n", This
);
570 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
572 if(!(*ppshv
= fodInfos
->Shell
.FOIShellView
))
576 IShellView_AddRef(fodInfos
->Shell
.FOIShellView
);
580 /**************************************************************************
581 * IShellBrowserImpl_RemoveMenusSB
583 static HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
587 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
589 TRACE("(%p)\n", This
);
591 /* Feature not implemented */
595 /**************************************************************************
596 * IShellBrowserImpl_SendControlMsg
598 static HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
606 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
609 TRACE("(%p)->(0x%08x 0x%08x 0x%08lx 0x%08lx %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
614 lres
= SendDlgItemMessageA( This
->hwndOwner
, IDC_TOOLBAR
, uMsg
, wParam
, lParam
);
617 FIXME("ctrl id: %x\n", id
);
620 if (pret
) *pret
= lres
;
624 /**************************************************************************
625 * IShellBrowserImpl_SetMenuSB
627 static HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
629 HOLEMENU holemenuReserved
,
630 HWND hwndActiveObject
)
633 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
635 TRACE("(%p)\n", This
);
637 /* Feature not implemented */
641 /**************************************************************************
642 * IShellBrowserImpl_SetStatusTextSB
644 static HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
645 LPCOLESTR lpszStatusText
)
648 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
650 TRACE("(%p)\n", This
);
652 /* Feature not implemented */
656 /**************************************************************************
657 * IShellBrowserImpl_SetToolbarItems
659 static HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
660 LPTBBUTTON lpButtons
,
665 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
667 TRACE("(%p)\n", This
);
669 /* Feature not implemented */
673 /**************************************************************************
674 * IShellBrowserImpl_TranslateAcceleratorSB
676 static HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
681 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
683 TRACE("(%p)\n", This
);
685 /* Feature not implemented */
689 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
692 IShellBrowserImpl_QueryInterface
,
693 IShellBrowserImpl_AddRef
,
694 IShellBrowserImpl_Release
,
696 IShellBrowserImpl_GetWindow
,
697 IShellBrowserImpl_ContextSensitiveHelp
,
699 IShellBrowserImpl_InsertMenusSB
,
700 IShellBrowserImpl_SetMenuSB
,
701 IShellBrowserImpl_RemoveMenusSB
,
702 IShellBrowserImpl_SetStatusTextSB
,
703 IShellBrowserImpl_EnableModelessSB
,
704 IShellBrowserImpl_TranslateAcceleratorSB
,
705 IShellBrowserImpl_BrowseObject
,
706 IShellBrowserImpl_GetViewStateStream
,
707 IShellBrowserImpl_GetControlWindow
,
708 IShellBrowserImpl_SendControlMsg
,
709 IShellBrowserImpl_QueryActiveShellView
,
710 IShellBrowserImpl_OnViewWindowActive
,
711 IShellBrowserImpl_SetToolbarItems
720 /***************************************************************************
721 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
723 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
724 ICommDlgBrowser
*iface
,
728 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
730 TRACE("(%p)\n", This
);
732 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
735 /**************************************************************************
736 * IShellBrowserImpl_ICommDlgBrowser_AddRef
738 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser
* iface
)
740 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
742 TRACE("(%p)\n", This
);
744 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
747 /**************************************************************************
748 * IShellBrowserImpl_ICommDlgBrowser_Release
750 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser
* iface
)
752 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
754 TRACE("(%p)\n", This
);
756 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
759 /**************************************************************************
760 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
762 * Called when a user double-clicks in the view or presses the ENTER key
764 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser
*iface
,
768 FileOpenDlgInfos
*fodInfos
;
770 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
772 TRACE("(%p)\n", This
);
774 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
776 /* If the selected object is not a folder, send an IDOK command to parent window */
777 if((pidl
= GetPidlFromDataObject(fodInfos
->Shell
.FOIDataObject
, 1)))
781 ULONG ulAttr
= SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
782 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, (LPCITEMIDLIST
*)&pidl
, &ulAttr
);
783 if (ulAttr
& (SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
) )
785 hRes
= IShellBrowser_BrowseObject(&This
->IShellBrowser_iface
,pidl
,SBSP_RELATIVE
);
786 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
787 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_FOLDERCHANGE
);
791 /* Tell the dialog that the user selected a file */
792 PostMessageA(This
->hwndOwner
, WM_COMMAND
, IDOK
, 0L);
796 /* Free memory used by pidl */
797 COMDLG32_SHFree(pidl
);
805 /**************************************************************************
806 * IShellBrowserImpl_OnSelChange
808 static HRESULT
IShellBrowserImpl_OnSelChange(IShellBrowserImpl
*This
, const IShellView
*ppshv
)
810 FileOpenDlgInfos
*fodInfos
;
812 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
813 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
815 /* release old selections */
816 if (fodInfos
->Shell
.FOIDataObject
)
817 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
819 /* get a new DataObject from the ShellView */
820 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
821 &IID_IDataObject
, (void**)&fodInfos
->Shell
.FOIDataObject
)))
824 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
826 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
827 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
831 /**************************************************************************
832 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
834 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
839 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
841 TRACE("(%p shv=%p)\n", This
, ppshv
);
845 case CDBOSC_SETFOCUS
:
846 /* FIXME: Reset the default button.
847 This should be taken care of by defdlg. If control
848 other than button receives focus the default button
849 should be restored. */
850 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
853 case CDBOSC_KILLFOCUS
:
855 FileOpenDlgInfos
*fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
856 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
859 LoadStringW(COMDLG32_hInstance
, IDS_SAVE_BUTTON
, szSave
, sizeof(szSave
)/sizeof(WCHAR
));
860 SetDlgItemTextW(fodInfos
->ShellInfos
.hwndOwner
, IDOK
, szSave
);
864 case CDBOSC_SELCHANGE
:
865 return IShellBrowserImpl_OnSelChange(This
, ppshv
);
874 /* send_includeitem_notification
876 * Sends a CDN_INCLUDEITEM notification for "pidl" to hwndParentDlg
878 static LRESULT
send_includeitem_notification(HWND hwndParentDlg
, LPCITEMIDLIST pidl
)
880 LRESULT hook_result
= 0;
881 FileOpenDlgInfos
*fodInfos
= GetPropA(hwndParentDlg
, FileOpenDlgInfosStr
);
883 if(!fodInfos
) return 0;
885 if(fodInfos
->DlgInfos
.hwndCustomDlg
)
887 TRACE("call notify CDN_INCLUDEITEM for pidl=%p\n", pidl
);
888 if(fodInfos
->unicode
)
890 OFNOTIFYEXW ofnNotify
;
891 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
892 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
893 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
894 ofnNotify
.hdr
.idFrom
= 0;
895 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
896 ofnNotify
.lpOFN
= fodInfos
->ofnInfos
;
897 hook_result
= SendMessageW(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
901 OFNOTIFYEXA ofnNotify
;
902 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
903 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
904 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
905 ofnNotify
.hdr
.idFrom
= 0;
906 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
907 ofnNotify
.lpOFN
= (LPOPENFILENAMEA
)fodInfos
->ofnInfos
;
908 hook_result
= SendMessageA(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
911 TRACE("Retval: 0x%08lx\n", hook_result
);
915 /**************************************************************************
916 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
918 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
922 FileOpenDlgInfos
*fodInfos
;
925 WCHAR szPathW
[MAX_PATH
];
927 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
929 TRACE("(%p)\n", This
);
931 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
933 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
934 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
936 if( (ulAttr
& SFGAO_HIDDEN
) || /* hidden */
937 !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
940 /* always include directories and links */
941 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
944 /* if the application takes care of including the item we are done */
945 if(fodInfos
->ofnInfos
->Flags
& OFN_ENABLEINCLUDENOTIFY
&&
946 send_includeitem_notification(This
->hwndOwner
, pidl
))
949 /* Check if there is a mask to apply if not */
950 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !lstrlenW(fodInfos
->ShellInfos
.lpstrCurrentFilter
))
953 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
955 if (COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
))
957 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
965 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
968 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
969 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
970 IShellBrowserImpl_ICommDlgBrowser_Release
,
971 /* ICommDlgBrowser */
972 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
973 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
974 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
984 /***************************************************************************
985 * IShellBrowserImpl_IServiceProvider_QueryInterface
987 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
988 IServiceProvider
*iface
,
992 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
994 FIXME("(%p)\n", This
);
996 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
999 /**************************************************************************
1000 * IShellBrowserImpl_IServiceProvider_AddRef
1002 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
1004 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1006 FIXME("(%p)\n", This
);
1008 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
1011 /**************************************************************************
1012 * IShellBrowserImpl_IServiceProvider_Release
1014 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
1016 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1018 FIXME("(%p)\n", This
);
1020 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
1023 /**************************************************************************
1024 * IShellBrowserImpl_IServiceProvider_Release
1027 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
1028 * riid = IShellBrowser) to call SendControlMsg ().
1034 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
1035 IServiceProvider
* iface
,
1036 REFGUID guidService
,
1040 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1042 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
1045 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
1046 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppv
);
1048 FIXME("(%p) unknown interface requested\n", This
);
1049 return E_NOINTERFACE
;
1053 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
1056 IShellBrowserImpl_IServiceProvider_QueryInterface
,
1057 IShellBrowserImpl_IServiceProvider_AddRef
,
1058 IShellBrowserImpl_IServiceProvider_Release
,
1059 /* IServiceProvider */
1060 IShellBrowserImpl_IServiceProvider_QueryService