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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
37 #define NO_SHLWAPI_STREAM
39 #include "filedlgbrowser.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
50 IShellBrowserVtbl
* lpVtbl
;
51 ICommDlgBrowserVtbl
* lpVtblCommDlgBrowser
;
52 IServiceProviderVtbl
* lpVtblServiceProvider
;
53 DWORD ref
; /* Reference counter */
54 HWND hwndOwner
; /* Owner dialog of the interface */
58 /**************************************************************************
61 static IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
62 static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
63 static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
;
65 /**************************************************************************
69 HRESULT
IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser
*iface
, IShellView
*ppshv
);
71 LPITEMIDLIST
GetSelectedPidl(IShellView
*ppshv
);
74 /**************************************************************************
77 extern const char *FileOpenDlgInfosStr
;
79 extern HRESULT
GetName(LPSHELLFOLDER lpsf
, LPITEMIDLIST pidl
,DWORD dwFlags
,LPSTR lpstrFileName
);
80 extern HRESULT
GetFileName(HWND hwnd
, LPITEMIDLIST pidl
, LPSTR lpstrFileName
);
81 extern IShellFolder
* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs
);
82 extern LPITEMIDLIST
GetParentPidl(LPITEMIDLIST pidl
);
83 extern LPITEMIDLIST
GetPidlFromName(IShellFolder
*psf
,LPCSTR lpcstrFileName
);
85 extern BOOL
FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd
,
86 LPITEMIDLIST pidlCurrentFolder
,
89 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd
,LPITEMIDLIST pidl
);
90 extern BOOL
FILEDLG95_OnOpen(HWND hwnd
);
91 extern HRESULT
SendCustomDlgNotificationMessage(HWND hwndParentDlg
, UINT uCode
);
98 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
99 static void COMDLG32_DumpSBSPFlags(UINT uflags
)
101 if (TRACE_ON(commdlg
))
104 static const struct {
108 #define FE(x) { x, #x}
109 /* SBSP_DEFBROWSER == 0 */
110 FE(SBSP_SAMEBROWSER
),
113 /* SBSP_DEFMODE == 0 */
115 FE(SBSP_EXPLOREMODE
),
117 FE(SBSP_NOTRANSFERHIST
),
119 /* SBSP_ABSOLUTE == 0 */
122 FE(SBSP_NAVIGATEBACK
),
123 FE(SBSP_NAVIGATEFORWARD
),
124 FE(SBSP_ALLOW_AUTONAVIGATE
),
126 FE(SBSP_NOAUTOSELECT
),
127 FE(SBSP_WRITENOHISTORY
),
130 FE(SBSP_INITIATEDBYHLINKFRAME
),
133 DPRINTF("SBSP Flags: %08x =", uflags
);
134 for (i
= 0; i
< (sizeof(flags
) / sizeof(flags
[0])); i
++)
135 if (flags
[i
].mask
& uflags
)
136 DPRINTF("%s ", flags
[i
].name
);
141 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos
*fodInfos
)
143 char lpstrPath
[MAX_PATH
];
144 if(SHGetPathFromIDListA(fodInfos
->ShellInfos
.pidlAbsCurrent
,lpstrPath
)) {
145 SetCurrentDirectoryA(lpstrPath
);
146 TRACE("new current folder %s\n", lpstrPath
);
150 /* copied from shell32 to avoid linking to it */
151 static HRESULT
COMDLG32_StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, LPCITEMIDLIST pidl
)
153 TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest
,len
,src
,pidl
);
158 lstrcpynW((LPWSTR
)dest
, src
->u
.pOleStr
, len
);
159 COMDLG32_SHFree(src
->u
.pOleStr
);
163 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, (LPWSTR
)dest
, len
))
164 ((LPWSTR
)dest
)[len
-1] = 0;
170 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
,
171 -1, (LPWSTR
)dest
, len
))
172 ((LPWSTR
)dest
)[len
-1] = 0;
177 FIXME("unknown type!\n");
179 { *(LPWSTR
)dest
= '\0';
190 /**************************************************************************
191 * IShellBrowserImpl_Construct
193 IShellBrowser
* IShellBrowserImpl_Construct(HWND hwndOwner
)
195 IShellBrowserImpl
*sb
;
196 FileOpenDlgInfos
*fodInfos
= (FileOpenDlgInfos
*) GetPropA(hwndOwner
,FileOpenDlgInfosStr
);
198 sb
=(IShellBrowserImpl
*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl
));
200 /* Initialisation of the member variables */
202 sb
->hwndOwner
= hwndOwner
;
204 /* Initialisation of the vTables */
205 sb
->lpVtbl
= &IShellBrowserImpl_Vtbl
;
206 sb
->lpVtblCommDlgBrowser
= &IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
207 sb
->lpVtblServiceProvider
= &IShellBrowserImpl_IServiceProvider_Vtbl
;
208 SHGetSpecialFolderLocation(hwndOwner
, CSIDL_DESKTOP
,
209 &fodInfos
->ShellInfos
.pidlAbsCurrent
);
213 return (IShellBrowser
*) sb
;
216 /***************************************************************************
217 * IShellBrowserImpl_QueryInterface
219 HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
223 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
225 TRACE("(%p)\n\t%s\n", This
, debugstr_guid(riid
));
229 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
232 else if(IsEqualIID(riid
, &IID_IOleWindow
)) /*IOleWindow*/
233 { *ppvObj
= (IOleWindow
*)This
;
236 else if(IsEqualIID(riid
, &IID_IShellBrowser
)) /*IShellBrowser*/
237 { *ppvObj
= (IShellBrowser
*)This
;
240 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
)) /*ICommDlgBrowser*/
241 { *ppvObj
= (ICommDlgBrowser
*) &(This
->lpVtblCommDlgBrowser
);
244 else if(IsEqualIID(riid
, &IID_IServiceProvider
)) /* IServiceProvider */
245 { *ppvObj
= (ICommDlgBrowser
*) &(This
->lpVtblServiceProvider
);
249 { IUnknown_AddRef( (IShellBrowser
*) *ppvObj
);
252 FIXME("Unknown interface requested\n");
253 return E_NOINTERFACE
;
256 /**************************************************************************
257 * IShellBrowser::AddRef
259 ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
261 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
262 ULONG ref
= InterlockedIncrement(&This
->ref
);
264 TRACE("(%p,%lu)\n", This
, ref
- 1);
269 /**************************************************************************
270 * IShellBrowserImpl_Release
272 ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
274 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
275 ULONG ref
= InterlockedDecrement(&This
->ref
);
277 TRACE("(%p,%lu)\n", This
, ref
+ 1);
281 COMDLG32_SHFree(This
);
282 TRACE("-- destroyed\n");
292 /**************************************************************************
293 * IShellBrowserImpl_GetWindow (IOleWindow)
295 * Inherited from IOleWindow::GetWindow
297 * See Windows documentation for more details
299 * Note : We will never be window less in the File Open dialog
302 HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
305 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
307 TRACE("(%p)\n", This
);
312 *phwnd
= This
->hwndOwner
;
314 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
318 /**************************************************************************
319 * IShellBrowserImpl_ContextSensitiveHelp
321 HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
324 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
326 TRACE("(%p)\n", This
);
328 /* Feature not implemented */
336 /**************************************************************************
337 * IShellBrowserImpl_BrowseObject
339 * See Windows documentation on IShellBrowser::BrowseObject for more details
341 * This function will override user specified flags and will always
342 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
344 HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
349 IShellFolder
*psfTmp
;
351 FileOpenDlgInfos
*fodInfos
;
352 LPITEMIDLIST pidlTmp
;
358 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
360 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This
, pidl
, wFlags
);
361 COMDLG32_DumpSBSPFlags(wFlags
);
363 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
365 /* Format the pidl according to its parameter's category */
366 if(wFlags
& SBSP_RELATIVE
)
369 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
370 if(FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
371 pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfTmp
)))
373 ERR("bind to object failed\n");
376 /* create an absolute pidl */
377 pidlTmp
= COMDLG32_PIDL_ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
,
380 else if(wFlags
& SBSP_PARENT
)
382 /* Browse the parent folder (ignores the pidl) */
383 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
384 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
387 else /* SBSP_ABSOLUTE is 0x0000 */
389 /* An absolute pidl (relative from the desktop) */
390 pidlTmp
= COMDLG32_PIDL_ILClone((LPITEMIDLIST
)pidl
);
391 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
396 ERR("could not browse to folder\n");
400 /* If the pidl to browse to is equal to the actual pidl ...
401 do nothing and pretend you did it*/
402 if(COMDLG32_PIDL_ILIsEqual(pidlTmp
,fodInfos
->ShellInfos
.pidlAbsCurrent
))
404 IShellFolder_Release(psfTmp
);
405 COMDLG32_SHFree(pidlTmp
);
406 TRACE("keep current folder\n");
410 /* Release the current DataObject */
411 if (fodInfos
->Shell
.FOIDataObject
)
413 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
414 fodInfos
->Shell
.FOIDataObject
= NULL
;
417 /* Create the associated view */
418 TRACE("create view object\n");
419 if(FAILED(hRes
= IShellFolder_CreateViewObject(psfTmp
, fodInfos
->ShellInfos
.hwndOwner
,
420 &IID_IShellView
, (LPVOID
*)&psvTmp
))) goto error
;
422 /* Check if listview has focus */
423 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
425 /* Get the foldersettings from the old view */
426 if(fodInfos
->Shell
.FOIShellView
)
427 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
429 /* Release the old fodInfos->Shell.FOIShellView and update its value.
430 We have to update this early since ShellView_CreateViewWindow of native
431 shell32 calls OnStateChange and needs the correct view here.*/
432 if(fodInfos
->Shell
.FOIShellView
)
434 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
435 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
437 fodInfos
->Shell
.FOIShellView
= psvTmp
;
439 /* Release old FOIShellFolder and update its value */
440 if (fodInfos
->Shell
.FOIShellFolder
)
441 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
442 fodInfos
->Shell
.FOIShellFolder
= psfTmp
;
444 /* Release old pidlAbsCurrent and update its value */
445 COMDLG32_SHFree((LPVOID
)fodInfos
->ShellInfos
.pidlAbsCurrent
);
446 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
448 COMDLG32_UpdateCurrentDir(fodInfos
);
450 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
451 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
453 /* Create the window */
454 TRACE("create view window\n");
455 if(FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
456 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
457 &rectView
, &hwndView
))) goto error
;
459 fodInfos
->ShellInfos
.hwndView
= hwndView
;
461 /* Select the new folder in the Look In combo box of the Open file dialog */
462 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
464 /* changes the tab order of the ListView to reflect the window's File Dialog */
465 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
466 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
468 /* Since we destroyed the old view if it had focus set focus to the newly created view */
470 SetFocus(fodInfos
->ShellInfos
.hwndView
);
474 ERR("Failed with error 0x%08lx\n", hRes
);
478 /**************************************************************************
479 * IShellBrowserImpl_EnableModelessSB
481 HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
485 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
487 TRACE("(%p)\n", This
);
489 /* Feature not implemented */
493 /**************************************************************************
494 * IShellBrowserImpl_GetControlWindow
496 HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
501 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
503 TRACE("(%p)\n", This
);
505 /* Feature not implemented */
508 /**************************************************************************
509 * IShellBrowserImpl_GetViewStateStream
511 HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
516 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
518 FIXME("(%p 0x%08lx %p)\n", This
, grfMode
, ppStrm
);
520 /* Feature not implemented */
523 /**************************************************************************
524 * IShellBrowserImpl_InsertMenusSB
526 HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
528 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
531 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
533 TRACE("(%p)\n", This
);
535 /* Feature not implemented */
538 /**************************************************************************
539 * IShellBrowserImpl_OnViewWindowActive
541 HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
545 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
547 TRACE("(%p)\n", This
);
549 /* Feature not implemented */
552 /**************************************************************************
553 * IShellBrowserImpl_QueryActiveShellView
555 HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
559 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
561 FileOpenDlgInfos
*fodInfos
;
563 TRACE("(%p)\n", This
);
565 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
567 if(!(*ppshv
= fodInfos
->Shell
.FOIShellView
))
571 IShellView_AddRef(fodInfos
->Shell
.FOIShellView
);
574 /**************************************************************************
575 * IShellBrowserImpl_RemoveMenusSB
577 HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
581 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
583 TRACE("(%p)\n", This
);
585 /* Feature not implemented */
588 /**************************************************************************
589 * IShellBrowserImpl_SendControlMsg
591 HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
599 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
602 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
607 lres
= SendDlgItemMessageA( This
->hwndOwner
, IDC_TOOLBAR
, uMsg
, wParam
, lParam
);
610 FIXME("ctrl id: %x\n", id
);
613 if (pret
) *pret
= lres
;
616 /**************************************************************************
617 * IShellBrowserImpl_SetMenuSB
619 HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
621 HOLEMENU holemenuReserved
,
622 HWND hwndActiveObject
)
625 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
627 TRACE("(%p)\n", This
);
629 /* Feature not implemented */
632 /**************************************************************************
633 * IShellBrowserImpl_SetStatusTextSB
635 HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
636 LPCOLESTR lpszStatusText
)
639 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
641 TRACE("(%p)\n", This
);
643 /* Feature not implemented */
646 /**************************************************************************
647 * IShellBrowserImpl_SetToolbarItems
649 HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
650 LPTBBUTTON lpButtons
,
655 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
657 TRACE("(%p)\n", This
);
659 /* Feature not implemented */
662 /**************************************************************************
663 * IShellBrowserImpl_TranslateAcceleratorSB
665 HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
670 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
672 TRACE("(%p)\n", This
);
674 /* Feature not implemented */
678 static IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
681 IShellBrowserImpl_QueryInterface
,
682 IShellBrowserImpl_AddRef
,
683 IShellBrowserImpl_Release
,
685 IShellBrowserImpl_GetWindow
,
686 IShellBrowserImpl_ContextSensitiveHelp
,
688 IShellBrowserImpl_InsertMenusSB
,
689 IShellBrowserImpl_SetMenuSB
,
690 IShellBrowserImpl_RemoveMenusSB
,
691 IShellBrowserImpl_SetStatusTextSB
,
692 IShellBrowserImpl_EnableModelessSB
,
693 IShellBrowserImpl_TranslateAcceleratorSB
,
694 IShellBrowserImpl_BrowseObject
,
695 IShellBrowserImpl_GetViewStateStream
,
696 IShellBrowserImpl_GetControlWindow
,
697 IShellBrowserImpl_SendControlMsg
,
698 IShellBrowserImpl_QueryActiveShellView
,
699 IShellBrowserImpl_OnViewWindowActive
,
700 IShellBrowserImpl_SetToolbarItems
709 /***************************************************************************
710 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
712 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
713 ICommDlgBrowser
*iface
,
717 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser
,iface
);
719 TRACE("(%p)\n", This
);
721 return IShellBrowserImpl_QueryInterface(This
,riid
,ppvObj
);
724 /**************************************************************************
725 * IShellBrowserImpl_ICommDlgBrowser_AddRef
727 ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser
* iface
)
729 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser
,iface
);
731 TRACE("(%p)\n", This
);
733 return IShellBrowserImpl_AddRef(This
);
736 /**************************************************************************
737 * IShellBrowserImpl_ICommDlgBrowser_Release
739 ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser
* iface
)
741 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser
,iface
);
743 TRACE("(%p)\n", This
);
745 return IShellBrowserImpl_Release(This
);
747 /**************************************************************************
748 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
750 * Called when a user double-clicks in the view or presses the ENTER key
752 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser
*iface
,
756 FileOpenDlgInfos
*fodInfos
;
758 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
760 TRACE("(%p)\n", This
);
762 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
764 /* If the selected object is not a folder, send an IDOK command to parent window */
765 if((pidl
= GetPidlFromDataObject(fodInfos
->Shell
.FOIDataObject
, 1)))
769 ULONG ulAttr
= SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
770 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, (LPCITEMIDLIST
*)&pidl
, &ulAttr
);
771 if (ulAttr
& (SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
) )
773 hRes
= IShellBrowser_BrowseObject((IShellBrowser
*)This
,pidl
,SBSP_RELATIVE
);
774 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_FOLDERCHANGE
);
778 /* Tell the dialog that the user selected a file */
779 hRes
= PostMessageA(This
->hwndOwner
, WM_COMMAND
, IDOK
, 0L);
782 /* Free memory used by pidl */
783 COMDLG32_SHFree((LPVOID
)pidl
);
791 /**************************************************************************
792 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
794 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
799 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
801 TRACE("(%p shv=%p)\n", This
, ppshv
);
805 case CDBOSC_SETFOCUS
:
806 /* FIXME: Reset the default button.
807 This should be taken care of by defdlg. If control
808 other than button receives focus the default button
809 should be restored. */
810 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
813 case CDBOSC_KILLFOCUS
:
815 FileOpenDlgInfos
*fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
816 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
817 SetDlgItemTextA(fodInfos
->ShellInfos
.hwndOwner
,IDOK
,"&Save");
820 case CDBOSC_SELCHANGE
:
821 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface
,ppshv
);
830 /**************************************************************************
831 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
833 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
837 FileOpenDlgInfos
*fodInfos
;
840 WCHAR szPathW
[MAX_PATH
];
842 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
844 TRACE("(%p)\n", This
);
846 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
848 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
849 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
851 if( (ulAttr
& SFGAO_HIDDEN
) /* hidden */
852 | !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
855 /* always include directories and links */
856 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
859 /* Check if there is a mask to apply if not */
860 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !lstrlenW(fodInfos
->ShellInfos
.lpstrCurrentFilter
))
863 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
865 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
)))
867 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
875 /**************************************************************************
876 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
878 HRESULT
IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser
*iface
, IShellView
*ppshv
)
880 FileOpenDlgInfos
*fodInfos
;
882 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
884 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
885 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
887 /* release old selections */
888 if (fodInfos
->Shell
.FOIDataObject
)
889 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
891 /* get a new DataObject from the ShellView */
892 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
893 &IID_IDataObject
, (LPVOID
*)&fodInfos
->Shell
.FOIDataObject
)))
896 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
898 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
902 static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
905 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
906 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
907 IShellBrowserImpl_ICommDlgBrowser_Release
,
908 /* ICommDlgBrowser */
909 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
910 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
911 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
921 /***************************************************************************
922 * IShellBrowserImpl_IServiceProvider_QueryInterface
924 HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
925 IServiceProvider
*iface
,
929 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
931 FIXME("(%p)\n", This
);
933 return IShellBrowserImpl_QueryInterface(This
,riid
,ppvObj
);
936 /**************************************************************************
937 * IShellBrowserImpl_IServiceProvider_AddRef
939 ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
941 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
943 FIXME("(%p)\n", This
);
945 return IShellBrowserImpl_AddRef(This
);
948 /**************************************************************************
949 * IShellBrowserImpl_IServiceProvider_Release
951 ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
953 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
955 FIXME("(%p)\n", This
);
957 return IShellBrowserImpl_Release(This
);
960 /**************************************************************************
961 * IShellBrowserImpl_IServiceProvider_Release
964 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
965 * riid = IShellBrowser) to call SendControlMsg ().
971 HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
972 IServiceProvider
* iface
,
977 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
979 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
982 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
984 return IShellBrowserImpl_QueryInterface(This
,riid
,ppv
);
986 FIXME("(%p) unknown interface requested\n", This
);
987 return E_NOINTERFACE
;
991 static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
994 IShellBrowserImpl_IServiceProvider_QueryInterface
,
995 IShellBrowserImpl_IServiceProvider_AddRef
,
996 IShellBrowserImpl_IServiceProvider_Release
,
997 /* IServiceProvider */
998 IShellBrowserImpl_IServiceProvider_QueryService