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
24 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
29 const IShellBrowserVtbl
*lpVtbl
;
30 const ICommDlgBrowserVtbl
*lpVtblCommDlgBrowser
;
31 const IServiceProviderVtbl
*lpVtblServiceProvider
;
32 LONG ref
; /* Reference counter */
33 HWND hwndOwner
; /* Owner dialog of the interface */
37 static inline IShellBrowserImpl
*impl_from_ICommDlgBrowser( ICommDlgBrowser
*iface
)
39 return (IShellBrowserImpl
*)((char*)iface
- FIELD_OFFSET(IShellBrowserImpl
, lpVtblCommDlgBrowser
));
42 static inline IShellBrowserImpl
*impl_from_IServiceProvider( IServiceProvider
*iface
)
44 return (IShellBrowserImpl
*)((char*)iface
- FIELD_OFFSET(IShellBrowserImpl
, lpVtblServiceProvider
));
47 /**************************************************************************
50 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
51 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
52 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
;
54 /**************************************************************************
58 static HRESULT
IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser
*iface
, IShellView
*ppshv
);
60 /**************************************************************************
63 extern const char *FileOpenDlgInfosStr
;
65 extern IShellFolder
* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs
);
66 extern LPITEMIDLIST
GetParentPidl(LPITEMIDLIST pidl
);
67 extern LPITEMIDLIST
GetPidlFromName(IShellFolder
*psf
,LPCSTR lpcstrFileName
);
69 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd
,LPITEMIDLIST pidl
);
70 extern LRESULT
SendCustomDlgNotificationMessage(HWND hwndParentDlg
, UINT uCode
);
77 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
78 static void COMDLG32_DumpSBSPFlags(UINT uflags
)
80 if (TRACE_ON(commdlg
))
87 #define FE(x) { x, #x}
88 /* SBSP_DEFBROWSER == 0 */
92 /* SBSP_DEFMODE == 0 */
96 FE(SBSP_NOTRANSFERHIST
),
98 /* SBSP_ABSOLUTE == 0 */
101 FE(SBSP_NAVIGATEBACK
),
102 FE(SBSP_NAVIGATEFORWARD
),
103 FE(SBSP_ALLOW_AUTONAVIGATE
),
105 FE(SBSP_NOAUTOSELECT
),
106 FE(SBSP_WRITENOHISTORY
),
109 FE(SBSP_INITIATEDBYHLINKFRAME
),
112 DPRINTF("SBSP Flags: %08x =", uflags
);
113 for (i
= 0; i
< (sizeof(flags
) / sizeof(flags
[0])); i
++)
114 if (flags
[i
].mask
& uflags
)
115 DPRINTF("%s ", flags
[i
].name
);
120 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos
*fodInfos
)
122 LPSHELLFOLDER psfDesktop
;
126 res
= SHGetDesktopFolder(&psfDesktop
);
130 res
= IShellFolder_GetDisplayNameOf(psfDesktop
, fodInfos
->ShellInfos
.pidlAbsCurrent
,
131 SHGDN_FORPARSING
, &strret
);
132 if (SUCCEEDED(res
)) {
133 WCHAR wszCurrentDir
[MAX_PATH
];
135 res
= StrRetToBufW(&strret
, fodInfos
->ShellInfos
.pidlAbsCurrent
, wszCurrentDir
, MAX_PATH
);
137 SetCurrentDirectoryW(wszCurrentDir
);
140 IShellFolder_Release(psfDesktop
);
143 /* copied from shell32 to avoid linking to it */
144 static HRESULT
COMDLG32_StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, LPCITEMIDLIST pidl
)
146 TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest
,len
,src
,pidl
);
151 lstrcpynW((LPWSTR
)dest
, src
->u
.pOleStr
, len
);
152 COMDLG32_SHFree(src
->u
.pOleStr
);
156 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, (LPWSTR
)dest
, len
))
157 ((LPWSTR
)dest
)[len
-1] = 0;
163 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
,
164 -1, (LPWSTR
)dest
, len
))
165 ((LPWSTR
)dest
)[len
-1] = 0;
170 FIXME("unknown type!\n");
172 { *(LPWSTR
)dest
= '\0';
183 /**************************************************************************
184 * IShellBrowserImpl_Construct
186 IShellBrowser
* IShellBrowserImpl_Construct(HWND hwndOwner
)
188 IShellBrowserImpl
*sb
;
189 FileOpenDlgInfos
*fodInfos
= (FileOpenDlgInfos
*) GetPropA(hwndOwner
,FileOpenDlgInfosStr
);
191 sb
=(IShellBrowserImpl
*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl
));
193 /* Initialisation of the member variables */
195 sb
->hwndOwner
= hwndOwner
;
197 /* Initialisation of the vTables */
198 sb
->lpVtbl
= &IShellBrowserImpl_Vtbl
;
199 sb
->lpVtblCommDlgBrowser
= &IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
200 sb
->lpVtblServiceProvider
= &IShellBrowserImpl_IServiceProvider_Vtbl
;
201 SHGetSpecialFolderLocation(hwndOwner
, CSIDL_DESKTOP
,
202 &fodInfos
->ShellInfos
.pidlAbsCurrent
);
206 return (IShellBrowser
*) sb
;
209 /***************************************************************************
210 * IShellBrowserImpl_QueryInterface
212 static HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
216 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
218 TRACE("(%p)\n\t%s\n", This
, debugstr_guid(riid
));
222 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
225 else if(IsEqualIID(riid
, &IID_IOleWindow
)) /*IOleWindow*/
226 { *ppvObj
= (IOleWindow
*)This
;
229 else if(IsEqualIID(riid
, &IID_IShellBrowser
)) /*IShellBrowser*/
230 { *ppvObj
= (IShellBrowser
*)This
;
233 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
)) /*ICommDlgBrowser*/
234 { *ppvObj
= (ICommDlgBrowser
*) &(This
->lpVtblCommDlgBrowser
);
237 else if(IsEqualIID(riid
, &IID_IServiceProvider
)) /* IServiceProvider */
238 { *ppvObj
= (ICommDlgBrowser
*) &(This
->lpVtblServiceProvider
);
242 { IUnknown_AddRef( (IShellBrowser
*) *ppvObj
);
245 FIXME("Unknown interface requested\n");
246 return E_NOINTERFACE
;
249 /**************************************************************************
250 * IShellBrowser::AddRef
252 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
254 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
255 ULONG ref
= InterlockedIncrement(&This
->ref
);
257 TRACE("(%p,%lu)\n", This
, ref
- 1);
262 /**************************************************************************
263 * IShellBrowserImpl_Release
265 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
267 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
268 ULONG ref
= InterlockedDecrement(&This
->ref
);
270 TRACE("(%p,%lu)\n", This
, ref
+ 1);
274 COMDLG32_SHFree(This
);
275 TRACE("-- destroyed\n");
285 /**************************************************************************
286 * IShellBrowserImpl_GetWindow (IOleWindow)
288 * Inherited from IOleWindow::GetWindow
290 * See Windows documentation for more details
292 * Note : We will never be window less in the File Open dialog
295 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
298 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
300 TRACE("(%p)\n", This
);
305 *phwnd
= This
->hwndOwner
;
307 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
311 /**************************************************************************
312 * IShellBrowserImpl_ContextSensitiveHelp
314 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
317 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
319 TRACE("(%p)\n", This
);
321 /* Feature not implemented */
329 /**************************************************************************
330 * IShellBrowserImpl_BrowseObject
332 * See Windows documentation on IShellBrowser::BrowseObject for more details
334 * This function will override user specified flags and will always
335 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
337 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
342 IShellFolder
*psfTmp
;
344 FileOpenDlgInfos
*fodInfos
;
345 LPITEMIDLIST pidlTmp
;
351 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
353 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This
, pidl
, wFlags
);
354 COMDLG32_DumpSBSPFlags(wFlags
);
356 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
358 /* Format the pidl according to its parameter's category */
359 if(wFlags
& SBSP_RELATIVE
)
362 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
363 if(FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
364 pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfTmp
)))
366 ERR("bind to object failed\n");
369 /* create an absolute pidl */
370 pidlTmp
= COMDLG32_PIDL_ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
,
373 else if(wFlags
& SBSP_PARENT
)
375 /* Browse the parent folder (ignores the pidl) */
376 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
377 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
380 else /* SBSP_ABSOLUTE is 0x0000 */
382 /* An absolute pidl (relative from the desktop) */
383 pidlTmp
= COMDLG32_PIDL_ILClone((LPITEMIDLIST
)pidl
);
384 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
389 ERR("could not browse to folder\n");
393 /* If the pidl to browse to is equal to the actual pidl ...
394 do nothing and pretend you did it*/
395 if(COMDLG32_PIDL_ILIsEqual(pidlTmp
,fodInfos
->ShellInfos
.pidlAbsCurrent
))
397 IShellFolder_Release(psfTmp
);
398 COMDLG32_SHFree(pidlTmp
);
399 TRACE("keep current folder\n");
403 /* Release the current DataObject */
404 if (fodInfos
->Shell
.FOIDataObject
)
406 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
407 fodInfos
->Shell
.FOIDataObject
= NULL
;
410 /* Create the associated view */
411 TRACE("create view object\n");
412 if(FAILED(hRes
= IShellFolder_CreateViewObject(psfTmp
, fodInfos
->ShellInfos
.hwndOwner
,
413 &IID_IShellView
, (LPVOID
*)&psvTmp
))) goto error
;
415 /* Check if listview has focus */
416 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
418 /* Get the foldersettings from the old view */
419 if(fodInfos
->Shell
.FOIShellView
)
420 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
422 /* Release the old fodInfos->Shell.FOIShellView and update its value.
423 We have to update this early since ShellView_CreateViewWindow of native
424 shell32 calls OnStateChange and needs the correct view here.*/
425 if(fodInfos
->Shell
.FOIShellView
)
427 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
428 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
430 fodInfos
->Shell
.FOIShellView
= psvTmp
;
432 /* Release old FOIShellFolder and update its value */
433 if (fodInfos
->Shell
.FOIShellFolder
)
434 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
435 fodInfos
->Shell
.FOIShellFolder
= psfTmp
;
437 /* Release old pidlAbsCurrent and update its value */
438 COMDLG32_SHFree((LPVOID
)fodInfos
->ShellInfos
.pidlAbsCurrent
);
439 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
441 COMDLG32_UpdateCurrentDir(fodInfos
);
443 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
444 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
446 /* Create the window */
447 TRACE("create view window\n");
448 if(FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
449 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
450 &rectView
, &hwndView
))) goto error
;
452 fodInfos
->ShellInfos
.hwndView
= hwndView
;
454 /* Set view window control id to 5002 */
455 SetWindowLongPtrW(hwndView
, GWLP_ID
, lst2
);
457 /* Select the new folder in the Look In combo box of the Open file dialog */
458 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
460 /* changes the tab order of the ListView to reflect the window's File Dialog */
461 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
462 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
464 /* Since we destroyed the old view if it had focus set focus to the newly created view */
466 SetFocus(fodInfos
->ShellInfos
.hwndView
);
470 ERR("Failed with error 0x%08lx\n", hRes
);
474 /**************************************************************************
475 * IShellBrowserImpl_EnableModelessSB
477 static HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
481 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
483 TRACE("(%p)\n", This
);
485 /* Feature not implemented */
489 /**************************************************************************
490 * IShellBrowserImpl_GetControlWindow
492 static HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
497 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
499 TRACE("(%p)\n", This
);
501 /* Feature not implemented */
505 /**************************************************************************
506 * IShellBrowserImpl_GetViewStateStream
508 static HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
513 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
515 FIXME("(%p 0x%08lx %p)\n", This
, grfMode
, ppStrm
);
517 /* Feature not implemented */
521 /**************************************************************************
522 * IShellBrowserImpl_InsertMenusSB
524 static HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
526 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
529 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
531 TRACE("(%p)\n", This
);
533 /* Feature not implemented */
537 /**************************************************************************
538 * IShellBrowserImpl_OnViewWindowActive
540 static HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
544 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
546 TRACE("(%p)\n", This
);
548 /* Feature not implemented */
552 /**************************************************************************
553 * IShellBrowserImpl_QueryActiveShellView
555 static 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
);
575 /**************************************************************************
576 * IShellBrowserImpl_RemoveMenusSB
578 static HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
582 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
584 TRACE("(%p)\n", This
);
586 /* Feature not implemented */
590 /**************************************************************************
591 * IShellBrowserImpl_SendControlMsg
593 static HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
601 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
604 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
609 lres
= SendDlgItemMessageA( This
->hwndOwner
, IDC_TOOLBAR
, uMsg
, wParam
, lParam
);
612 FIXME("ctrl id: %x\n", id
);
615 if (pret
) *pret
= lres
;
619 /**************************************************************************
620 * IShellBrowserImpl_SetMenuSB
622 static HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
624 HOLEMENU holemenuReserved
,
625 HWND hwndActiveObject
)
628 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
630 TRACE("(%p)\n", This
);
632 /* Feature not implemented */
636 /**************************************************************************
637 * IShellBrowserImpl_SetStatusTextSB
639 static HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
640 LPCOLESTR lpszStatusText
)
643 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
645 TRACE("(%p)\n", This
);
647 /* Feature not implemented */
651 /**************************************************************************
652 * IShellBrowserImpl_SetToolbarItems
654 static HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
655 LPTBBUTTON lpButtons
,
660 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
662 TRACE("(%p)\n", This
);
664 /* Feature not implemented */
668 /**************************************************************************
669 * IShellBrowserImpl_TranslateAcceleratorSB
671 static HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
676 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
678 TRACE("(%p)\n", This
);
680 /* Feature not implemented */
684 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
687 IShellBrowserImpl_QueryInterface
,
688 IShellBrowserImpl_AddRef
,
689 IShellBrowserImpl_Release
,
691 IShellBrowserImpl_GetWindow
,
692 IShellBrowserImpl_ContextSensitiveHelp
,
694 IShellBrowserImpl_InsertMenusSB
,
695 IShellBrowserImpl_SetMenuSB
,
696 IShellBrowserImpl_RemoveMenusSB
,
697 IShellBrowserImpl_SetStatusTextSB
,
698 IShellBrowserImpl_EnableModelessSB
,
699 IShellBrowserImpl_TranslateAcceleratorSB
,
700 IShellBrowserImpl_BrowseObject
,
701 IShellBrowserImpl_GetViewStateStream
,
702 IShellBrowserImpl_GetControlWindow
,
703 IShellBrowserImpl_SendControlMsg
,
704 IShellBrowserImpl_QueryActiveShellView
,
705 IShellBrowserImpl_OnViewWindowActive
,
706 IShellBrowserImpl_SetToolbarItems
715 /***************************************************************************
716 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
718 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
719 ICommDlgBrowser
*iface
,
723 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
725 TRACE("(%p)\n", This
);
727 return IShellBrowserImpl_QueryInterface((IShellBrowser
*)This
,riid
,ppvObj
);
730 /**************************************************************************
731 * IShellBrowserImpl_ICommDlgBrowser_AddRef
733 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser
* iface
)
735 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
737 TRACE("(%p)\n", This
);
739 return IShellBrowserImpl_AddRef((IShellBrowser
*)This
);
742 /**************************************************************************
743 * IShellBrowserImpl_ICommDlgBrowser_Release
745 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser
* iface
)
747 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
749 TRACE("(%p)\n", This
);
751 return IShellBrowserImpl_Release((IShellBrowser
*)This
);
754 /**************************************************************************
755 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
757 * Called when a user double-clicks in the view or presses the ENTER key
759 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser
*iface
,
763 FileOpenDlgInfos
*fodInfos
;
765 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
767 TRACE("(%p)\n", This
);
769 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
771 /* If the selected object is not a folder, send an IDOK command to parent window */
772 if((pidl
= GetPidlFromDataObject(fodInfos
->Shell
.FOIDataObject
, 1)))
776 ULONG ulAttr
= SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
777 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, (LPCITEMIDLIST
*)&pidl
, &ulAttr
);
778 if (ulAttr
& (SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
) )
780 hRes
= IShellBrowser_BrowseObject((IShellBrowser
*)This
,pidl
,SBSP_RELATIVE
);
781 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_FOLDERCHANGE
);
785 /* Tell the dialog that the user selected a file */
786 PostMessageA(This
->hwndOwner
, WM_COMMAND
, IDOK
, 0L);
790 /* Free memory used by pidl */
791 COMDLG32_SHFree((LPVOID
)pidl
);
799 /**************************************************************************
800 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
802 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
807 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
809 TRACE("(%p shv=%p)\n", This
, ppshv
);
813 case CDBOSC_SETFOCUS
:
814 /* FIXME: Reset the default button.
815 This should be taken care of by defdlg. If control
816 other than button receives focus the default button
817 should be restored. */
818 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
821 case CDBOSC_KILLFOCUS
:
823 FileOpenDlgInfos
*fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
824 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
825 SetDlgItemTextA(fodInfos
->ShellInfos
.hwndOwner
,IDOK
,"&Save");
828 case CDBOSC_SELCHANGE
:
829 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface
,ppshv
);
838 /**************************************************************************
839 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
841 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
845 FileOpenDlgInfos
*fodInfos
;
848 WCHAR szPathW
[MAX_PATH
];
850 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
852 TRACE("(%p)\n", This
);
854 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
856 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
857 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
859 if( (ulAttr
& SFGAO_HIDDEN
) /* hidden */
860 | !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
863 /* always include directories and links */
864 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
867 /* Check if there is a mask to apply if not */
868 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !lstrlenW(fodInfos
->ShellInfos
.lpstrCurrentFilter
))
871 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
873 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
)))
875 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
883 /**************************************************************************
884 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
886 static HRESULT
IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser
*iface
, IShellView
*ppshv
)
888 FileOpenDlgInfos
*fodInfos
;
890 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
892 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
893 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
895 /* release old selections */
896 if (fodInfos
->Shell
.FOIDataObject
)
897 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
899 /* get a new DataObject from the ShellView */
900 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
901 &IID_IDataObject
, (LPVOID
*)&fodInfos
->Shell
.FOIDataObject
)))
904 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
906 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
910 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
913 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
914 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
915 IShellBrowserImpl_ICommDlgBrowser_Release
,
916 /* ICommDlgBrowser */
917 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
918 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
919 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
929 /***************************************************************************
930 * IShellBrowserImpl_IServiceProvider_QueryInterface
932 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
933 IServiceProvider
*iface
,
937 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
939 FIXME("(%p)\n", This
);
941 return IShellBrowserImpl_QueryInterface((IShellBrowser
*)This
,riid
,ppvObj
);
944 /**************************************************************************
945 * IShellBrowserImpl_IServiceProvider_AddRef
947 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
949 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
951 FIXME("(%p)\n", This
);
953 return IShellBrowserImpl_AddRef((IShellBrowser
*)This
);
956 /**************************************************************************
957 * IShellBrowserImpl_IServiceProvider_Release
959 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
961 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
963 FIXME("(%p)\n", This
);
965 return IShellBrowserImpl_Release((IShellBrowser
*)This
);
968 /**************************************************************************
969 * IShellBrowserImpl_IServiceProvider_Release
972 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
973 * riid = IShellBrowser) to call SendControlMsg ().
979 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
980 IServiceProvider
* iface
,
985 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
987 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
990 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
992 return IShellBrowserImpl_QueryInterface((IShellBrowser
*)This
,riid
,ppv
);
994 FIXME("(%p) unknown interface requested\n", This
);
995 return E_NOINTERFACE
;
999 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
1002 IShellBrowserImpl_IServiceProvider_QueryInterface
,
1003 IShellBrowserImpl_IServiceProvider_AddRef
,
1004 IShellBrowserImpl_IServiceProvider_Release
,
1005 /* IServiceProvider */
1006 IShellBrowserImpl_IServiceProvider_QueryService