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
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
35 #define NO_SHLWAPI_STREAM
37 #include "filedlgbrowser.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
48 IShellBrowserVtbl
* lpVtbl
;
49 ICommDlgBrowserVtbl
* lpVtblCommDlgBrowser
;
50 IServiceProviderVtbl
* lpVtblServiceProvider
;
51 DWORD ref
; /* Reference counter */
52 HWND hwndOwner
; /* Owner dialog of the interface */
56 /**************************************************************************
59 static IShellBrowserVtbl IShellBrowserImpl_Vtbl
;
60 static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
61 static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
;
63 /**************************************************************************
67 HRESULT
IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser
*iface
, IShellView
*ppshv
);
69 LPITEMIDLIST
GetSelectedPidl(IShellView
*ppshv
);
72 /**************************************************************************
75 extern const char *FileOpenDlgInfosStr
;
77 extern HRESULT
GetName(LPSHELLFOLDER lpsf
, LPITEMIDLIST pidl
,DWORD dwFlags
,LPSTR lpstrFileName
);
78 extern HRESULT
GetFileName(HWND hwnd
, LPITEMIDLIST pidl
, LPSTR lpstrFileName
);
79 extern IShellFolder
* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs
);
80 extern LPITEMIDLIST
GetParentPidl(LPITEMIDLIST pidl
);
81 extern LPITEMIDLIST
GetPidlFromName(IShellFolder
*psf
,LPCSTR lpcstrFileName
);
83 extern BOOL
FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd
,
84 LPITEMIDLIST pidlCurrentFolder
,
87 extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd
,LPITEMIDLIST pidl
);
88 extern BOOL
FILEDLG95_OnOpen(HWND hwnd
);
89 extern HRESULT
SendCustomDlgNotificationMessage(HWND hwndParentDlg
, UINT uCode
);
96 static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos
*fodInfos
)
98 char lpstrPath
[MAX_PATH
];
99 if(SHGetPathFromIDListA(fodInfos
->ShellInfos
.pidlAbsCurrent
,lpstrPath
)) {
100 SetCurrentDirectoryA(lpstrPath
);
101 TRACE("new current folder %s\n", lpstrPath
);
105 /* copied from shell32 to avoid linking to it */
106 static HRESULT
COMDLG32_StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, LPCITEMIDLIST pidl
)
108 TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest
,len
,src
,pidl
);
113 lstrcpynW((LPWSTR
)dest
, src
->u
.pOleStr
, len
);
114 COMDLG32_SHFree(src
->u
.pOleStr
);
118 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, (LPWSTR
)dest
, len
))
119 ((LPWSTR
)dest
)[len
-1] = 0;
125 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
,
126 -1, (LPWSTR
)dest
, len
))
127 ((LPWSTR
)dest
)[len
-1] = 0;
132 FIXME("unknown type!\n");
134 { *(LPWSTR
)dest
= '\0';
145 /**************************************************************************
146 * IShellBrowserImpl_Construct
148 IShellBrowser
* IShellBrowserImpl_Construct(HWND hwndOwner
)
150 IShellBrowserImpl
*sb
;
151 FileOpenDlgInfos
*fodInfos
= (FileOpenDlgInfos
*) GetPropA(hwndOwner
,FileOpenDlgInfosStr
);
153 sb
=(IShellBrowserImpl
*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl
));
155 /* Initialisation of the member variables */
157 sb
->hwndOwner
= hwndOwner
;
159 /* Initialisation of the vTables */
160 sb
->lpVtbl
= &IShellBrowserImpl_Vtbl
;
161 sb
->lpVtblCommDlgBrowser
= &IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
162 sb
->lpVtblServiceProvider
= &IShellBrowserImpl_IServiceProvider_Vtbl
;
163 SHGetSpecialFolderLocation(hwndOwner
, CSIDL_DESKTOP
,
164 &fodInfos
->ShellInfos
.pidlAbsCurrent
);
168 return (IShellBrowser
*) sb
;
171 /***************************************************************************
172 * IShellBrowserImpl_QueryInterface
174 HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
178 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
180 TRACE("(%p)\n\t%s\n", This
, debugstr_guid(riid
));
184 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
187 else if(IsEqualIID(riid
, &IID_IOleWindow
)) /*IOleWindow*/
188 { *ppvObj
= (IOleWindow
*)This
;
191 else if(IsEqualIID(riid
, &IID_IShellBrowser
)) /*IShellBrowser*/
192 { *ppvObj
= (IShellBrowser
*)This
;
195 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
)) /*ICommDlgBrowser*/
196 { *ppvObj
= (ICommDlgBrowser
*) &(This
->lpVtblCommDlgBrowser
);
199 else if(IsEqualIID(riid
, &IID_IServiceProvider
)) /* IServiceProvider */
200 { *ppvObj
= (ICommDlgBrowser
*) &(This
->lpVtblServiceProvider
);
204 { IUnknown_AddRef( (IShellBrowser
*) *ppvObj
);
207 FIXME("Unknown interface requested\n");
208 return E_NOINTERFACE
;
211 /**************************************************************************
212 * IShellBrowser::AddRef
214 ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
216 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
218 TRACE("(%p,%lu)\n", This
, This
->ref
);
220 return ++(This
->ref
);
223 /**************************************************************************
224 * IShellBrowserImpl_Release
226 ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
228 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
230 TRACE("(%p,%lu)\n", This
, This
->ref
);
234 COMDLG32_SHFree(This
);
235 TRACE("-- destroyed\n");
245 /**************************************************************************
246 * IShellBrowserImpl_GetWindow (IOleWindow)
248 * Inherited from IOleWindow::GetWindow
250 * See Windows documentation for more details
252 * Note : We will never be window less in the File Open dialog
255 HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
258 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
260 TRACE("(%p)\n", This
);
265 *phwnd
= This
->hwndOwner
;
267 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
271 /**************************************************************************
272 * IShellBrowserImpl_ContextSensitiveHelp
274 HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
277 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
279 TRACE("(%p)\n", This
);
281 /* Feature not implemented */
289 /**************************************************************************
290 * IShellBrowserImpl_BrowseObject
292 * See Windows documentation on IShellBrowser::BrowseObject for more details
294 * This function will override user specified flags and will always
295 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
297 HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
302 IShellFolder
*psfTmp
;
304 FileOpenDlgInfos
*fodInfos
;
305 LPITEMIDLIST pidlTmp
;
311 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
313 TRACE("(%p)(pidl=%p,flags=0x%08x(%s))\n", This
, pidl
, wFlags
,
314 (wFlags
& SBSP_RELATIVE
) ? "SBSP_RELATIVE" :
315 (wFlags
& SBSP_PARENT
) ? "SBSP_PARENT" :
316 (wFlags
& SBSP_ABSOLUTE
) ? "SBSP_ABSOLUTE" : "SBPS_????");
318 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
320 /* Format the pidl according to its parameter's category */
321 if(wFlags
& SBSP_RELATIVE
)
324 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
325 if(FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
326 pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfTmp
)))
328 ERR("bind to object failed\n");
331 /* create an absolute pidl */
332 pidlTmp
= COMDLG32_PIDL_ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
,
335 else if(wFlags
& SBSP_PARENT
)
337 /* Browse the parent folder (ignores the pidl) */
338 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
339 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
342 else /* SBSP_ABSOLUTE is 0x0000 */
344 /* An absolute pidl (relative from the desktop) */
345 pidlTmp
= COMDLG32_PIDL_ILClone((LPITEMIDLIST
)pidl
);
346 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
351 ERR("could not browse to folder\n");
355 /* If the pidl to browse to is equal to the actual pidl ...
356 do nothing and pretend you did it*/
357 if(COMDLG32_PIDL_ILIsEqual(pidlTmp
,fodInfos
->ShellInfos
.pidlAbsCurrent
))
359 IShellFolder_Release(psfTmp
);
360 COMDLG32_SHFree(pidlTmp
);
361 TRACE("keep current folder\n");
365 /* Release the current DataObject */
366 if (fodInfos
->Shell
.FOIDataObject
)
368 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
369 fodInfos
->Shell
.FOIDataObject
= NULL
;
372 /* Create the associated view */
373 TRACE("create view object\n");
374 if(FAILED(hRes
= IShellFolder_CreateViewObject(psfTmp
, fodInfos
->ShellInfos
.hwndOwner
,
375 &IID_IShellView
, (LPVOID
*)&psvTmp
))) goto error
;
377 /* Check if listview has focus */
378 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
380 /* Get the foldersettings from the old view */
381 if(fodInfos
->Shell
.FOIShellView
)
382 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
384 /* Release the old fodInfos->Shell.FOIShellView and update its value.
385 We have to update this early since ShellView_CreateViewWindow of native
386 shell32 calls OnStateChange and needs the correct view here.*/
387 if(fodInfos
->Shell
.FOIShellView
)
389 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
390 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
392 fodInfos
->Shell
.FOIShellView
= psvTmp
;
394 /* Release old FOIShellFolder and update its value */
395 if (fodInfos
->Shell
.FOIShellFolder
)
396 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
397 fodInfos
->Shell
.FOIShellFolder
= psfTmp
;
399 /* Release old pidlAbsCurrent and update its value */
400 COMDLG32_SHFree((LPVOID
)fodInfos
->ShellInfos
.pidlAbsCurrent
);
401 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
403 COMDLG32_UpdateCurrentDir(fodInfos
);
405 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
406 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
408 /* Create the window */
409 TRACE("create view window\n");
410 if(FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
411 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
412 &rectView
, &hwndView
))) goto error
;
414 fodInfos
->ShellInfos
.hwndView
= hwndView
;
416 /* Select the new folder in the Look In combo box of the Open file dialog */
417 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
419 /* changes the tab order of the ListView to reflect the window's File Dialog */
420 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
421 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
423 /* Since we destroyed the old view if it had focus set focus to the newly created view */
425 SetFocus(fodInfos
->ShellInfos
.hwndView
);
429 ERR("Failed with error 0x%08lx\n", hRes
);
433 /**************************************************************************
434 * IShellBrowserImpl_EnableModelessSB
436 HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
440 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
442 TRACE("(%p)\n", This
);
444 /* Feature not implemented */
448 /**************************************************************************
449 * IShellBrowserImpl_GetControlWindow
451 HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
456 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
458 TRACE("(%p)\n", This
);
460 /* Feature not implemented */
463 /**************************************************************************
464 * IShellBrowserImpl_GetViewStateStream
466 HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
471 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
473 FIXME("(%p 0x%08lx %p)\n", This
, grfMode
, ppStrm
);
475 /* Feature not implemented */
478 /**************************************************************************
479 * IShellBrowserImpl_InsertMenusSB
481 HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
483 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
486 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
488 TRACE("(%p)\n", This
);
490 /* Feature not implemented */
493 /**************************************************************************
494 * IShellBrowserImpl_OnViewWindowActive
496 HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
500 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
502 TRACE("(%p)\n", This
);
504 /* Feature not implemented */
507 /**************************************************************************
508 * IShellBrowserImpl_QueryActiveShellView
510 HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
514 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
516 FileOpenDlgInfos
*fodInfos
;
518 TRACE("(%p)\n", This
);
520 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
522 if(!(*ppshv
= fodInfos
->Shell
.FOIShellView
))
526 IShellView_AddRef(fodInfos
->Shell
.FOIShellView
);
529 /**************************************************************************
530 * IShellBrowserImpl_RemoveMenusSB
532 HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
536 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
538 TRACE("(%p)\n", This
);
540 /* Feature not implemented */
543 /**************************************************************************
544 * IShellBrowserImpl_SendControlMsg
546 HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
554 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
557 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
562 lres
= SendDlgItemMessageA( This
->hwndOwner
, IDC_TOOLBAR
, uMsg
, wParam
, lParam
);
565 FIXME("ctrl id: %x\n", id
);
568 if (pret
) *pret
= lres
;
571 /**************************************************************************
572 * IShellBrowserImpl_SetMenuSB
574 HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
576 HOLEMENU holemenuReserved
,
577 HWND hwndActiveObject
)
580 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
582 TRACE("(%p)\n", This
);
584 /* Feature not implemented */
587 /**************************************************************************
588 * IShellBrowserImpl_SetStatusTextSB
590 HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
591 LPCOLESTR lpszStatusText
)
594 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
596 TRACE("(%p)\n", This
);
598 /* Feature not implemented */
601 /**************************************************************************
602 * IShellBrowserImpl_SetToolbarItems
604 HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
605 LPTBBUTTON lpButtons
,
610 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
612 TRACE("(%p)\n", This
);
614 /* Feature not implemented */
617 /**************************************************************************
618 * IShellBrowserImpl_TranslateAcceleratorSB
620 HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
625 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
627 TRACE("(%p)\n", This
);
629 /* Feature not implemented */
633 static IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
636 IShellBrowserImpl_QueryInterface
,
637 IShellBrowserImpl_AddRef
,
638 IShellBrowserImpl_Release
,
640 IShellBrowserImpl_GetWindow
,
641 IShellBrowserImpl_ContextSensitiveHelp
,
643 IShellBrowserImpl_InsertMenusSB
,
644 IShellBrowserImpl_SetMenuSB
,
645 IShellBrowserImpl_RemoveMenusSB
,
646 IShellBrowserImpl_SetStatusTextSB
,
647 IShellBrowserImpl_EnableModelessSB
,
648 IShellBrowserImpl_TranslateAcceleratorSB
,
649 IShellBrowserImpl_BrowseObject
,
650 IShellBrowserImpl_GetViewStateStream
,
651 IShellBrowserImpl_GetControlWindow
,
652 IShellBrowserImpl_SendControlMsg
,
653 IShellBrowserImpl_QueryActiveShellView
,
654 IShellBrowserImpl_OnViewWindowActive
,
655 IShellBrowserImpl_SetToolbarItems
664 /***************************************************************************
665 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
667 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
668 ICommDlgBrowser
*iface
,
672 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser
,iface
);
674 TRACE("(%p)\n", This
);
676 return IShellBrowserImpl_QueryInterface(This
,riid
,ppvObj
);
679 /**************************************************************************
680 * IShellBrowserImpl_ICommDlgBrowser_AddRef
682 ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser
* iface
)
684 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser
,iface
);
686 TRACE("(%p)\n", This
);
688 return IShellBrowserImpl_AddRef(This
);
691 /**************************************************************************
692 * IShellBrowserImpl_ICommDlgBrowser_Release
694 ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser
* iface
)
696 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser
,iface
);
698 TRACE("(%p)\n", This
);
700 return IShellBrowserImpl_Release(This
);
702 /**************************************************************************
703 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
705 * Called when a user double-clicks in the view or presses the ENTER key
707 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser
*iface
,
711 FileOpenDlgInfos
*fodInfos
;
713 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
715 TRACE("(%p)\n", This
);
717 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
719 /* If the selected object is not a folder, send a IDOK command to parent window */
720 if((pidl
= GetPidlFromDataObject(fodInfos
->Shell
.FOIDataObject
, 1)))
724 ULONG ulAttr
= SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
725 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, (LPCITEMIDLIST
*)&pidl
, &ulAttr
);
726 if (ulAttr
& (SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
) )
728 hRes
= IShellBrowser_BrowseObject((IShellBrowser
*)This
,pidl
,SBSP_RELATIVE
);
729 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_FOLDERCHANGE
);
733 /* Tell the dialog that the user selected a file */
734 hRes
= PostMessageA(This
->hwndOwner
, WM_COMMAND
, IDOK
, 0L);
737 /* Free memory used by pidl */
738 COMDLG32_SHFree((LPVOID
)pidl
);
746 /**************************************************************************
747 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
749 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
754 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
756 TRACE("(%p shv=%p)\n", This
, ppshv
);
760 case CDBOSC_SETFOCUS
:
761 /* FIXME: Reset the default button.
762 This should be taken care of by defdlg. If control
763 other than button receives focus the default button
764 should be restored. */
765 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
768 case CDBOSC_KILLFOCUS
:
770 FileOpenDlgInfos
*fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
771 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
772 SetDlgItemTextA(fodInfos
->ShellInfos
.hwndOwner
,IDOK
,"&Save");
775 case CDBOSC_SELCHANGE
:
776 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface
,ppshv
);
785 /**************************************************************************
786 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
788 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
792 FileOpenDlgInfos
*fodInfos
;
795 WCHAR szPathW
[MAX_PATH
];
797 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
799 TRACE("(%p)\n", This
);
801 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
803 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
804 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
806 if( (ulAttr
& SFGAO_HIDDEN
) /* hidden */
807 | !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
810 /* always include directories and links */
811 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
814 /* Check if there is a mask to apply if not */
815 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !lstrlenW(fodInfos
->ShellInfos
.lpstrCurrentFilter
))
818 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
820 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
)))
822 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
830 /**************************************************************************
831 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
833 HRESULT
IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser
*iface
, IShellView
*ppshv
)
835 FileOpenDlgInfos
*fodInfos
;
837 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
839 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
840 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
842 /* release old selections */
843 if (fodInfos
->Shell
.FOIDataObject
)
844 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
846 /* get a new DataObject from the ShellView */
847 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
848 &IID_IDataObject
, (LPVOID
*)&fodInfos
->Shell
.FOIDataObject
)))
851 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
853 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
857 static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
860 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
861 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
862 IShellBrowserImpl_ICommDlgBrowser_Release
,
863 /* ICommDlgBrowser */
864 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
865 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
866 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
876 /***************************************************************************
877 * IShellBrowserImpl_IServiceProvider_QueryInterface
879 HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
880 IServiceProvider
*iface
,
884 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
886 FIXME("(%p)\n", This
);
888 return IShellBrowserImpl_QueryInterface(This
,riid
,ppvObj
);
891 /**************************************************************************
892 * IShellBrowserImpl_IServiceProvider_AddRef
894 ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
896 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
898 FIXME("(%p)\n", This
);
900 return IShellBrowserImpl_AddRef(This
);
903 /**************************************************************************
904 * IShellBrowserImpl_IServiceProvider_Release
906 ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
908 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
910 FIXME("(%p)\n", This
);
912 return IShellBrowserImpl_Release(This
);
915 /**************************************************************************
916 * IShellBrowserImpl_IServiceProvider_Release
919 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
920 * riid = IShellBrowser) to call SendControlMsg ().
926 HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
927 IServiceProvider
* iface
,
932 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
934 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
937 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
939 return IShellBrowserImpl_QueryInterface(This
,riid
,ppv
);
941 FIXME("(%p) unknown interface requested\n", This
);
942 return E_NOINTERFACE
;
946 static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
949 IShellBrowserImpl_IServiceProvider_QueryInterface
,
950 IShellBrowserImpl_IServiceProvider_AddRef
,
951 IShellBrowserImpl_IServiceProvider_Release
,
952 /* IServiceProvider */
953 IShellBrowserImpl_IServiceProvider_QueryService