2 * Implementation of IShellBrowser for the File Open common dialog
4 * Copyright 1999 Francois Boisvert
5 * Copyright 1999, 2000 Juergen Schmied
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 IShellBrowser IShellBrowser_iface
;
28 ICommDlgBrowser ICommDlgBrowser_iface
;
29 IServiceProvider IServiceProvider_iface
;
30 LONG ref
; /* Reference counter */
31 HWND hwndOwner
; /* Owner dialog of the interface */
35 static inline IShellBrowserImpl
*impl_from_IShellBrowser(IShellBrowser
*iface
)
37 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IShellBrowser_iface
);
40 static inline IShellBrowserImpl
*impl_from_ICommDlgBrowser( ICommDlgBrowser
*iface
)
42 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, ICommDlgBrowser_iface
);
45 static inline IShellBrowserImpl
*impl_from_IServiceProvider( IServiceProvider
*iface
)
47 return CONTAINING_RECORD(iface
, IShellBrowserImpl
, IServiceProvider_iface
);
50 /**************************************************************************
53 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
54 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
55 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
;
61 #define add_flag(a) if (flags & a) {strcat(str, #a );strcat(str," ");}
62 static void COMDLG32_DumpSBSPFlags(UINT uflags
)
64 if (TRACE_ON(commdlg
))
71 #define FE(x) { x, #x}
72 /* SBSP_DEFBROWSER == 0 */
76 /* SBSP_DEFMODE == 0 */
80 FE(SBSP_NOTRANSFERHIST
),
82 /* SBSP_ABSOLUTE == 0 */
85 FE(SBSP_NAVIGATEBACK
),
86 FE(SBSP_NAVIGATEFORWARD
),
87 FE(SBSP_ALLOW_AUTONAVIGATE
),
89 FE(SBSP_NOAUTOSELECT
),
90 FE(SBSP_WRITENOHISTORY
),
93 FE(SBSP_INITIATEDBYHLINKFRAME
),
96 TRACE("SBSP Flags: %08x =", uflags
);
97 for (i
= 0; i
< (sizeof(flags
) / sizeof(flags
[0])); i
++)
98 if (flags
[i
].mask
& uflags
)
99 TRACE("%s ", flags
[i
].name
);
104 static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos
*fodInfos
)
106 LPSHELLFOLDER psfDesktop
;
110 res
= SHGetDesktopFolder(&psfDesktop
);
114 res
= IShellFolder_GetDisplayNameOf(psfDesktop
, fodInfos
->ShellInfos
.pidlAbsCurrent
,
115 SHGDN_FORPARSING
, &strret
);
116 if (SUCCEEDED(res
)) {
117 WCHAR wszCurrentDir
[MAX_PATH
];
119 res
= StrRetToBufW(&strret
, fodInfos
->ShellInfos
.pidlAbsCurrent
, wszCurrentDir
, MAX_PATH
);
121 SetCurrentDirectoryW(wszCurrentDir
);
124 IShellFolder_Release(psfDesktop
);
127 /* copied from shell32 to avoid linking to it */
128 static BOOL
COMDLG32_StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, LPCITEMIDLIST pidl
)
130 TRACE("dest=%p len=0x%x strret=%p pidl=%p\n", dest
, len
, src
, pidl
);
135 lstrcpynW(dest
, src
->u
.pOleStr
, len
);
136 COMDLG32_SHFree(src
->u
.pOleStr
);
140 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, dest
, len
))
141 ((LPWSTR
)dest
)[len
-1] = 0;
147 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
,
149 ((LPWSTR
)dest
)[len
-1] = 0;
154 FIXME("unknown type!\n");
156 { *(LPWSTR
)dest
= '\0';
167 /**************************************************************************
168 * IShellBrowserImpl_Construct
170 IShellBrowser
* IShellBrowserImpl_Construct(HWND hwndOwner
)
172 IShellBrowserImpl
*sb
;
173 FileOpenDlgInfos
*fodInfos
= GetPropA(hwndOwner
,FileOpenDlgInfosStr
);
175 sb
= COMDLG32_SHAlloc(sizeof(IShellBrowserImpl
));
177 /* Initialisation of the member variables */
179 sb
->hwndOwner
= hwndOwner
;
181 /* Initialisation of the vTables */
182 sb
->IShellBrowser_iface
.lpVtbl
= &IShellBrowserImpl_Vtbl
;
183 sb
->ICommDlgBrowser_iface
.lpVtbl
= &IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
184 sb
->IServiceProvider_iface
.lpVtbl
= &IShellBrowserImpl_IServiceProvider_Vtbl
;
185 SHGetSpecialFolderLocation(hwndOwner
, CSIDL_DESKTOP
,
186 &fodInfos
->ShellInfos
.pidlAbsCurrent
);
190 return &sb
->IShellBrowser_iface
;
193 /***************************************************************************
194 * IShellBrowserImpl_QueryInterface
196 static HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
200 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
202 TRACE("(%p)\n\t%s\n", This
, debugstr_guid(riid
));
206 if(IsEqualIID(riid
, &IID_IUnknown
))
207 *ppvObj
= &This
->IShellBrowser_iface
;
208 else if(IsEqualIID(riid
, &IID_IOleWindow
))
209 *ppvObj
= &This
->IShellBrowser_iface
;
210 else if(IsEqualIID(riid
, &IID_IShellBrowser
))
211 *ppvObj
= &This
->IShellBrowser_iface
;
212 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
))
213 *ppvObj
= &This
->ICommDlgBrowser_iface
;
214 else if(IsEqualIID(riid
, &IID_IServiceProvider
))
215 *ppvObj
= &This
->IServiceProvider_iface
;
218 IUnknown_AddRef((IUnknown
*)*ppvObj
);
222 FIXME("Unknown interface requested\n");
223 return E_NOINTERFACE
;
226 /**************************************************************************
227 * IShellBrowser::AddRef
229 static ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
231 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
232 ULONG ref
= InterlockedIncrement(&This
->ref
);
234 TRACE("(%p,%u)\n", This
, ref
- 1);
239 /**************************************************************************
240 * IShellBrowserImpl_Release
242 static ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
244 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
245 ULONG ref
= InterlockedDecrement(&This
->ref
);
247 TRACE("(%p,%u)\n", This
, ref
+ 1);
251 COMDLG32_SHFree(This
);
252 TRACE("-- destroyed\n");
262 /**************************************************************************
263 * IShellBrowserImpl_GetWindow (IOleWindow)
265 * Inherited from IOleWindow::GetWindow
267 * See Windows documentation for more details
269 * Note : We will never be window less in the File Open dialog
272 static HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
275 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
277 TRACE("(%p)\n", This
);
282 *phwnd
= This
->hwndOwner
;
284 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
288 /**************************************************************************
289 * IShellBrowserImpl_ContextSensitiveHelp
291 static HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
294 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
296 TRACE("(%p)\n", This
);
298 /* Feature not implemented */
306 /**************************************************************************
307 * IShellBrowserImpl_BrowseObject
309 * See Windows documentation on IShellBrowser::BrowseObject for more details
311 * This function will override user specified flags and will always
312 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
314 static HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
319 IShellFolder
*psfTmp
;
321 FileOpenDlgInfos
*fodInfos
;
322 LPITEMIDLIST pidlTmp
;
328 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
330 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This
, pidl
, wFlags
);
331 COMDLG32_DumpSBSPFlags(wFlags
);
333 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
335 /* Format the pidl according to its parameter's category */
336 if(wFlags
& SBSP_RELATIVE
)
339 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
340 if(FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
341 pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfTmp
)))
343 ERR("bind to object failed\n");
346 /* create an absolute pidl */
347 pidlTmp
= COMDLG32_PIDL_ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
, pidl
);
349 else if(wFlags
& SBSP_PARENT
)
351 /* Browse the parent folder (ignores the pidl) */
352 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
353 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
356 else /* SBSP_ABSOLUTE is 0x0000 */
358 /* An absolute pidl (relative from the desktop) */
359 pidlTmp
= COMDLG32_PIDL_ILClone(pidl
);
360 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
365 ERR("could not browse to folder\n");
369 /* If the pidl to browse to is equal to the actual pidl ...
370 do nothing and pretend you did it*/
371 if(COMDLG32_PIDL_ILIsEqual(pidlTmp
,fodInfos
->ShellInfos
.pidlAbsCurrent
))
373 IShellFolder_Release(psfTmp
);
374 COMDLG32_SHFree(pidlTmp
);
375 TRACE("keep current folder\n");
379 /* Release the current DataObject */
380 if (fodInfos
->Shell
.FOIDataObject
)
382 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
383 fodInfos
->Shell
.FOIDataObject
= NULL
;
386 /* Create the associated view */
387 TRACE("create view object\n");
388 if(FAILED(hRes
= IShellFolder_CreateViewObject(psfTmp
, fodInfos
->ShellInfos
.hwndOwner
,
389 &IID_IShellView
, (LPVOID
*)&psvTmp
))) goto error
;
391 /* Check if listview has focus */
392 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
394 /* Get the foldersettings from the old view */
395 if(fodInfos
->Shell
.FOIShellView
)
396 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
398 /* Release the old fodInfos->Shell.FOIShellView and update its value.
399 We have to update this early since ShellView_CreateViewWindow of native
400 shell32 calls OnStateChange and needs the correct view here.*/
401 if(fodInfos
->Shell
.FOIShellView
)
403 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
404 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
406 fodInfos
->Shell
.FOIShellView
= psvTmp
;
408 /* Release old FOIShellFolder and update its value */
409 if (fodInfos
->Shell
.FOIShellFolder
)
410 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
411 fodInfos
->Shell
.FOIShellFolder
= psfTmp
;
413 /* Release old pidlAbsCurrent and update its value */
414 COMDLG32_SHFree(fodInfos
->ShellInfos
.pidlAbsCurrent
);
415 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
417 COMDLG32_UpdateCurrentDir(fodInfos
);
419 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
420 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
422 /* Create the window */
423 TRACE("create view window\n");
424 if(FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
425 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
426 &rectView
, &hwndView
))) goto error
;
428 fodInfos
->ShellInfos
.hwndView
= hwndView
;
430 /* Set view window control id to 5002 */
431 SetWindowLongPtrW(hwndView
, GWLP_ID
, lst2
);
432 SendMessageW( hwndView
, WM_SETFONT
, SendMessageW( GetParent(hwndView
), WM_GETFONT
, 0, 0 ), FALSE
);
434 /* Select the new folder in the Look In combo box of the Open file dialog */
435 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
437 /* changes the tab order of the ListView to reflect the window's File Dialog */
438 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
439 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
441 /* Since we destroyed the old view if it had focus set focus to the newly created view */
443 SetFocus(fodInfos
->ShellInfos
.hwndView
);
447 ERR("Failed with error 0x%08x\n", hRes
);
451 /**************************************************************************
452 * IShellBrowserImpl_EnableModelessSB
454 static HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
458 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
460 TRACE("(%p)\n", This
);
462 /* Feature not implemented */
466 /**************************************************************************
467 * IShellBrowserImpl_GetControlWindow
469 static HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
474 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
476 TRACE("(%p)\n", This
);
478 /* Feature not implemented */
482 /**************************************************************************
483 * IShellBrowserImpl_GetViewStateStream
485 static HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
490 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
492 FIXME("(%p 0x%08x %p)\n", This
, grfMode
, ppStrm
);
494 /* Feature not implemented */
498 /**************************************************************************
499 * IShellBrowserImpl_InsertMenusSB
501 static HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
503 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
506 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
508 TRACE("(%p)\n", This
);
510 /* Feature not implemented */
514 /**************************************************************************
515 * IShellBrowserImpl_OnViewWindowActive
517 static HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
521 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
523 TRACE("(%p)\n", This
);
525 /* Feature not implemented */
529 /**************************************************************************
530 * IShellBrowserImpl_QueryActiveShellView
532 static HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
536 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
538 FileOpenDlgInfos
*fodInfos
;
540 TRACE("(%p)\n", This
);
542 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
544 if(!(*ppshv
= fodInfos
->Shell
.FOIShellView
))
548 IShellView_AddRef(fodInfos
->Shell
.FOIShellView
);
552 /**************************************************************************
553 * IShellBrowserImpl_RemoveMenusSB
555 static HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
559 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
561 TRACE("(%p)\n", This
);
563 /* Feature not implemented */
567 /**************************************************************************
568 * IShellBrowserImpl_SendControlMsg
570 static HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
578 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
581 TRACE("(%p)->(0x%08x 0x%08x 0x%08lx 0x%08lx %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
586 lres
= SendDlgItemMessageA( This
->hwndOwner
, IDC_TOOLBAR
, uMsg
, wParam
, lParam
);
589 FIXME("ctrl id: %x\n", id
);
592 if (pret
) *pret
= lres
;
596 /**************************************************************************
597 * IShellBrowserImpl_SetMenuSB
599 static HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
601 HOLEMENU holemenuReserved
,
602 HWND hwndActiveObject
)
605 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
607 TRACE("(%p)\n", This
);
609 /* Feature not implemented */
613 /**************************************************************************
614 * IShellBrowserImpl_SetStatusTextSB
616 static HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
617 LPCOLESTR lpszStatusText
)
620 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
622 TRACE("(%p)\n", This
);
624 /* Feature not implemented */
628 /**************************************************************************
629 * IShellBrowserImpl_SetToolbarItems
631 static HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
632 LPTBBUTTON lpButtons
,
637 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
639 TRACE("(%p)\n", This
);
641 /* Feature not implemented */
645 /**************************************************************************
646 * IShellBrowserImpl_TranslateAcceleratorSB
648 static HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
653 IShellBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
655 TRACE("(%p)\n", This
);
657 /* Feature not implemented */
661 static const IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
664 IShellBrowserImpl_QueryInterface
,
665 IShellBrowserImpl_AddRef
,
666 IShellBrowserImpl_Release
,
668 IShellBrowserImpl_GetWindow
,
669 IShellBrowserImpl_ContextSensitiveHelp
,
671 IShellBrowserImpl_InsertMenusSB
,
672 IShellBrowserImpl_SetMenuSB
,
673 IShellBrowserImpl_RemoveMenusSB
,
674 IShellBrowserImpl_SetStatusTextSB
,
675 IShellBrowserImpl_EnableModelessSB
,
676 IShellBrowserImpl_TranslateAcceleratorSB
,
677 IShellBrowserImpl_BrowseObject
,
678 IShellBrowserImpl_GetViewStateStream
,
679 IShellBrowserImpl_GetControlWindow
,
680 IShellBrowserImpl_SendControlMsg
,
681 IShellBrowserImpl_QueryActiveShellView
,
682 IShellBrowserImpl_OnViewWindowActive
,
683 IShellBrowserImpl_SetToolbarItems
692 /***************************************************************************
693 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
695 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
696 ICommDlgBrowser
*iface
,
700 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
702 TRACE("(%p)\n", This
);
704 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
707 /**************************************************************************
708 * IShellBrowserImpl_ICommDlgBrowser_AddRef
710 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser
* iface
)
712 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
714 TRACE("(%p)\n", This
);
716 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
719 /**************************************************************************
720 * IShellBrowserImpl_ICommDlgBrowser_Release
722 static ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser
* iface
)
724 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
726 TRACE("(%p)\n", This
);
728 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
731 /**************************************************************************
732 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
734 * Called when a user double-clicks in the view or presses the ENTER key
736 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser
*iface
,
740 FileOpenDlgInfos
*fodInfos
;
742 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
744 TRACE("(%p)\n", This
);
746 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
748 /* If the selected object is not a folder, send an IDOK command to parent window */
749 if((pidl
= GetPidlFromDataObject(fodInfos
->Shell
.FOIDataObject
, 1)))
753 ULONG ulAttr
= SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
754 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, (LPCITEMIDLIST
*)&pidl
, &ulAttr
);
755 if (ulAttr
& (SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
) )
757 hRes
= IShellBrowser_BrowseObject(&This
->IShellBrowser_iface
,pidl
,SBSP_RELATIVE
);
758 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
759 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_FOLDERCHANGE
);
763 /* Tell the dialog that the user selected a file */
764 PostMessageA(This
->hwndOwner
, WM_COMMAND
, IDOK
, 0L);
768 /* Free memory used by pidl */
769 COMDLG32_SHFree(pidl
);
777 /**************************************************************************
778 * IShellBrowserImpl_OnSelChange
780 static HRESULT
IShellBrowserImpl_OnSelChange(IShellBrowserImpl
*This
, const IShellView
*ppshv
)
782 FileOpenDlgInfos
*fodInfos
;
784 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
785 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
787 /* release old selections */
788 if (fodInfos
->Shell
.FOIDataObject
)
789 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
791 /* get a new DataObject from the ShellView */
792 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
793 &IID_IDataObject
, (void**)&fodInfos
->Shell
.FOIDataObject
)))
796 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
798 if(fodInfos
->ofnInfos
->Flags
& OFN_EXPLORER
)
799 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
803 /**************************************************************************
804 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
806 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
811 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
813 TRACE("(%p shv=%p)\n", This
, ppshv
);
817 case CDBOSC_SETFOCUS
:
818 /* FIXME: Reset the default button.
819 This should be taken care of by defdlg. If control
820 other than button receives focus the default button
821 should be restored. */
822 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
825 case CDBOSC_KILLFOCUS
:
827 FileOpenDlgInfos
*fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
828 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
831 LoadStringW(COMDLG32_hInstance
, IDS_SAVE_BUTTON
, szSave
, sizeof(szSave
)/sizeof(WCHAR
));
832 SetDlgItemTextW(fodInfos
->ShellInfos
.hwndOwner
, IDOK
, szSave
);
836 case CDBOSC_SELCHANGE
:
837 return IShellBrowserImpl_OnSelChange(This
, ppshv
);
846 /* send_includeitem_notification
848 * Sends a CDN_INCLUDEITEM notification for "pidl" to hwndParentDlg
850 static LRESULT
send_includeitem_notification(HWND hwndParentDlg
, LPCITEMIDLIST pidl
)
852 LRESULT hook_result
= 0;
853 FileOpenDlgInfos
*fodInfos
= GetPropA(hwndParentDlg
, FileOpenDlgInfosStr
);
855 if(!fodInfos
) return 0;
857 if(fodInfos
->DlgInfos
.hwndCustomDlg
)
859 TRACE("call notify CDN_INCLUDEITEM for pidl=%p\n", pidl
);
860 if(fodInfos
->unicode
)
862 OFNOTIFYEXW ofnNotify
;
863 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
864 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
865 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
866 ofnNotify
.hdr
.idFrom
= 0;
867 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
868 ofnNotify
.lpOFN
= fodInfos
->ofnInfos
;
869 hook_result
= SendMessageW(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
873 OFNOTIFYEXA ofnNotify
;
874 ofnNotify
.psf
= fodInfos
->Shell
.FOIShellFolder
;
875 ofnNotify
.pidl
= (LPITEMIDLIST
)pidl
;
876 ofnNotify
.hdr
.hwndFrom
= hwndParentDlg
;
877 ofnNotify
.hdr
.idFrom
= 0;
878 ofnNotify
.hdr
.code
= CDN_INCLUDEITEM
;
879 ofnNotify
.lpOFN
= (LPOPENFILENAMEA
)fodInfos
->ofnInfos
;
880 hook_result
= SendMessageA(fodInfos
->DlgInfos
.hwndCustomDlg
, WM_NOTIFY
, 0, (LPARAM
)&ofnNotify
);
883 TRACE("Retval: 0x%08lx\n", hook_result
);
887 /**************************************************************************
888 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
890 static HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
894 FileOpenDlgInfos
*fodInfos
;
897 WCHAR szPathW
[MAX_PATH
];
899 IShellBrowserImpl
*This
= impl_from_ICommDlgBrowser(iface
);
901 TRACE("(%p)\n", This
);
903 fodInfos
= GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
905 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
906 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
908 if( (ulAttr
& SFGAO_HIDDEN
) || /* hidden */
909 !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
912 /* always include directories and links */
913 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
916 /* if the application takes care of including the item we are done */
917 if(fodInfos
->ofnInfos
->Flags
& OFN_ENABLEINCLUDENOTIFY
&&
918 send_includeitem_notification(This
->hwndOwner
, pidl
))
921 /* Check if there is a mask to apply if not */
922 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !lstrlenW(fodInfos
->ShellInfos
.lpstrCurrentFilter
))
925 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
927 if (COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
))
929 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
937 static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
940 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
941 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
942 IShellBrowserImpl_ICommDlgBrowser_Release
,
943 /* ICommDlgBrowser */
944 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
945 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
946 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
956 /***************************************************************************
957 * IShellBrowserImpl_IServiceProvider_QueryInterface
959 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
960 IServiceProvider
*iface
,
964 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
966 FIXME("(%p)\n", This
);
968 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppvObj
);
971 /**************************************************************************
972 * IShellBrowserImpl_IServiceProvider_AddRef
974 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
976 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
978 FIXME("(%p)\n", This
);
980 return IShellBrowserImpl_AddRef(&This
->IShellBrowser_iface
);
983 /**************************************************************************
984 * IShellBrowserImpl_IServiceProvider_Release
986 static ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
988 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
990 FIXME("(%p)\n", This
);
992 return IShellBrowserImpl_Release(&This
->IShellBrowser_iface
);
995 /**************************************************************************
996 * IShellBrowserImpl_IServiceProvider_Release
999 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
1000 * riid = IShellBrowser) to call SendControlMsg ().
1006 static HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
1007 IServiceProvider
* iface
,
1008 REFGUID guidService
,
1012 IShellBrowserImpl
*This
= impl_from_IServiceProvider(iface
);
1014 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
1017 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
1018 return IShellBrowserImpl_QueryInterface(&This
->IShellBrowser_iface
,riid
,ppv
);
1020 FIXME("(%p) unknown interface requested\n", This
);
1021 return E_NOINTERFACE
;
1025 static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
1028 IShellBrowserImpl_IServiceProvider_QueryInterface
,
1029 IShellBrowserImpl_IServiceProvider_AddRef
,
1030 IShellBrowserImpl_IServiceProvider_Release
,
1031 /* IServiceProvider */
1032 IShellBrowserImpl_IServiceProvider_QueryService