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 LPSHELLFOLDER psfDesktop
;
147 res
= SHGetDesktopFolder(&psfDesktop
);
151 res
= IShellFolder_GetDisplayNameOf(psfDesktop
, fodInfos
->ShellInfos
.pidlAbsCurrent
,
152 SHGDN_FORPARSING
, &strret
);
153 if (SUCCEEDED(res
)) {
154 WCHAR wszCurrentDir
[MAX_PATH
];
156 res
= StrRetToBufW(&strret
, fodInfos
->ShellInfos
.pidlAbsCurrent
, wszCurrentDir
, MAX_PATH
);
158 SetCurrentDirectoryW(wszCurrentDir
);
161 IShellFolder_Release(psfDesktop
);
164 /* copied from shell32 to avoid linking to it */
165 static HRESULT
COMDLG32_StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, LPCITEMIDLIST pidl
)
167 TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest
,len
,src
,pidl
);
172 lstrcpynW((LPWSTR
)dest
, src
->u
.pOleStr
, len
);
173 COMDLG32_SHFree(src
->u
.pOleStr
);
177 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, (LPWSTR
)dest
, len
))
178 ((LPWSTR
)dest
)[len
-1] = 0;
184 if (len
&& !MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
,
185 -1, (LPWSTR
)dest
, len
))
186 ((LPWSTR
)dest
)[len
-1] = 0;
191 FIXME("unknown type!\n");
193 { *(LPWSTR
)dest
= '\0';
204 /**************************************************************************
205 * IShellBrowserImpl_Construct
207 IShellBrowser
* IShellBrowserImpl_Construct(HWND hwndOwner
)
209 IShellBrowserImpl
*sb
;
210 FileOpenDlgInfos
*fodInfos
= (FileOpenDlgInfos
*) GetPropA(hwndOwner
,FileOpenDlgInfosStr
);
212 sb
=(IShellBrowserImpl
*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl
));
214 /* Initialisation of the member variables */
216 sb
->hwndOwner
= hwndOwner
;
218 /* Initialisation of the vTables */
219 sb
->lpVtbl
= &IShellBrowserImpl_Vtbl
;
220 sb
->lpVtblCommDlgBrowser
= &IShellBrowserImpl_ICommDlgBrowser_Vtbl
;
221 sb
->lpVtblServiceProvider
= &IShellBrowserImpl_IServiceProvider_Vtbl
;
222 SHGetSpecialFolderLocation(hwndOwner
, CSIDL_DESKTOP
,
223 &fodInfos
->ShellInfos
.pidlAbsCurrent
);
227 return (IShellBrowser
*) sb
;
230 /***************************************************************************
231 * IShellBrowserImpl_QueryInterface
233 HRESULT WINAPI
IShellBrowserImpl_QueryInterface(IShellBrowser
*iface
,
237 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
239 TRACE("(%p)\n\t%s\n", This
, debugstr_guid(riid
));
243 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
246 else if(IsEqualIID(riid
, &IID_IOleWindow
)) /*IOleWindow*/
247 { *ppvObj
= (IOleWindow
*)This
;
250 else if(IsEqualIID(riid
, &IID_IShellBrowser
)) /*IShellBrowser*/
251 { *ppvObj
= (IShellBrowser
*)This
;
254 else if(IsEqualIID(riid
, &IID_ICommDlgBrowser
)) /*ICommDlgBrowser*/
255 { *ppvObj
= (ICommDlgBrowser
*) &(This
->lpVtblCommDlgBrowser
);
258 else if(IsEqualIID(riid
, &IID_IServiceProvider
)) /* IServiceProvider */
259 { *ppvObj
= (ICommDlgBrowser
*) &(This
->lpVtblServiceProvider
);
263 { IUnknown_AddRef( (IShellBrowser
*) *ppvObj
);
266 FIXME("Unknown interface requested\n");
267 return E_NOINTERFACE
;
270 /**************************************************************************
271 * IShellBrowser::AddRef
273 ULONG WINAPI
IShellBrowserImpl_AddRef(IShellBrowser
* iface
)
275 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
276 ULONG ref
= InterlockedIncrement(&This
->ref
);
278 TRACE("(%p,%lu)\n", This
, ref
- 1);
283 /**************************************************************************
284 * IShellBrowserImpl_Release
286 ULONG WINAPI
IShellBrowserImpl_Release(IShellBrowser
* iface
)
288 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
289 ULONG ref
= InterlockedDecrement(&This
->ref
);
291 TRACE("(%p,%lu)\n", This
, ref
+ 1);
295 COMDLG32_SHFree(This
);
296 TRACE("-- destroyed\n");
306 /**************************************************************************
307 * IShellBrowserImpl_GetWindow (IOleWindow)
309 * Inherited from IOleWindow::GetWindow
311 * See Windows documentation for more details
313 * Note : We will never be window less in the File Open dialog
316 HRESULT WINAPI
IShellBrowserImpl_GetWindow(IShellBrowser
* iface
,
319 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
321 TRACE("(%p)\n", This
);
326 *phwnd
= This
->hwndOwner
;
328 return (*phwnd
) ? S_OK
: E_UNEXPECTED
;
332 /**************************************************************************
333 * IShellBrowserImpl_ContextSensitiveHelp
335 HRESULT WINAPI
IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser
* iface
,
338 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
340 TRACE("(%p)\n", This
);
342 /* Feature not implemented */
350 /**************************************************************************
351 * IShellBrowserImpl_BrowseObject
353 * See Windows documentation on IShellBrowser::BrowseObject for more details
355 * This function will override user specified flags and will always
356 * use SBSP_DEFBROWSER and SBSP_DEFMODE.
358 HRESULT WINAPI
IShellBrowserImpl_BrowseObject(IShellBrowser
*iface
,
363 IShellFolder
*psfTmp
;
365 FileOpenDlgInfos
*fodInfos
;
366 LPITEMIDLIST pidlTmp
;
372 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
374 TRACE("(%p)(pidl=%p,flags=0x%08x)\n", This
, pidl
, wFlags
);
375 COMDLG32_DumpSBSPFlags(wFlags
);
377 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
379 /* Format the pidl according to its parameter's category */
380 if(wFlags
& SBSP_RELATIVE
)
383 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
384 if(FAILED(hRes
= IShellFolder_BindToObject(fodInfos
->Shell
.FOIShellFolder
,
385 pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfTmp
)))
387 ERR("bind to object failed\n");
390 /* create an absolute pidl */
391 pidlTmp
= COMDLG32_PIDL_ILCombine(fodInfos
->ShellInfos
.pidlAbsCurrent
,
394 else if(wFlags
& SBSP_PARENT
)
396 /* Browse the parent folder (ignores the pidl) */
397 pidlTmp
= GetParentPidl(fodInfos
->ShellInfos
.pidlAbsCurrent
);
398 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
401 else /* SBSP_ABSOLUTE is 0x0000 */
403 /* An absolute pidl (relative from the desktop) */
404 pidlTmp
= COMDLG32_PIDL_ILClone((LPITEMIDLIST
)pidl
);
405 psfTmp
= GetShellFolderFromPidl(pidlTmp
);
410 ERR("could not browse to folder\n");
414 /* If the pidl to browse to is equal to the actual pidl ...
415 do nothing and pretend you did it*/
416 if(COMDLG32_PIDL_ILIsEqual(pidlTmp
,fodInfos
->ShellInfos
.pidlAbsCurrent
))
418 IShellFolder_Release(psfTmp
);
419 COMDLG32_SHFree(pidlTmp
);
420 TRACE("keep current folder\n");
424 /* Release the current DataObject */
425 if (fodInfos
->Shell
.FOIDataObject
)
427 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
428 fodInfos
->Shell
.FOIDataObject
= NULL
;
431 /* Create the associated view */
432 TRACE("create view object\n");
433 if(FAILED(hRes
= IShellFolder_CreateViewObject(psfTmp
, fodInfos
->ShellInfos
.hwndOwner
,
434 &IID_IShellView
, (LPVOID
*)&psvTmp
))) goto error
;
436 /* Check if listview has focus */
437 bViewHasFocus
= IsChild(fodInfos
->ShellInfos
.hwndView
,GetFocus());
439 /* Get the foldersettings from the old view */
440 if(fodInfos
->Shell
.FOIShellView
)
441 IShellView_GetCurrentInfo(fodInfos
->Shell
.FOIShellView
, &fodInfos
->ShellInfos
.folderSettings
);
443 /* Release the old fodInfos->Shell.FOIShellView and update its value.
444 We have to update this early since ShellView_CreateViewWindow of native
445 shell32 calls OnStateChange and needs the correct view here.*/
446 if(fodInfos
->Shell
.FOIShellView
)
448 IShellView_DestroyViewWindow(fodInfos
->Shell
.FOIShellView
);
449 IShellView_Release(fodInfos
->Shell
.FOIShellView
);
451 fodInfos
->Shell
.FOIShellView
= psvTmp
;
453 /* Release old FOIShellFolder and update its value */
454 if (fodInfos
->Shell
.FOIShellFolder
)
455 IShellFolder_Release(fodInfos
->Shell
.FOIShellFolder
);
456 fodInfos
->Shell
.FOIShellFolder
= psfTmp
;
458 /* Release old pidlAbsCurrent and update its value */
459 COMDLG32_SHFree((LPVOID
)fodInfos
->ShellInfos
.pidlAbsCurrent
);
460 fodInfos
->ShellInfos
.pidlAbsCurrent
= pidlTmp
;
462 COMDLG32_UpdateCurrentDir(fodInfos
);
464 GetWindowRect(GetDlgItem(This
->hwndOwner
, IDC_SHELLSTATIC
), &rectView
);
465 MapWindowPoints(0, This
->hwndOwner
, (LPPOINT
)&rectView
, 2);
467 /* Create the window */
468 TRACE("create view window\n");
469 if(FAILED(hRes
= IShellView_CreateViewWindow(psvTmp
, NULL
,
470 &fodInfos
->ShellInfos
.folderSettings
, fodInfos
->Shell
.FOIShellBrowser
,
471 &rectView
, &hwndView
))) goto error
;
473 fodInfos
->ShellInfos
.hwndView
= hwndView
;
475 /* Select the new folder in the Look In combo box of the Open file dialog */
476 FILEDLG95_LOOKIN_SelectItem(fodInfos
->DlgInfos
.hwndLookInCB
,fodInfos
->ShellInfos
.pidlAbsCurrent
);
478 /* changes the tab order of the ListView to reflect the window's File Dialog */
479 hDlgWnd
= GetDlgItem(GetParent(hwndView
), IDC_LOOKIN
);
480 SetWindowPos(hwndView
, hDlgWnd
, 0,0,0,0, SWP_NOMOVE
| SWP_NOSIZE
);
482 /* Since we destroyed the old view if it had focus set focus to the newly created view */
484 SetFocus(fodInfos
->ShellInfos
.hwndView
);
488 ERR("Failed with error 0x%08lx\n", hRes
);
492 /**************************************************************************
493 * IShellBrowserImpl_EnableModelessSB
495 HRESULT WINAPI
IShellBrowserImpl_EnableModelessSB(IShellBrowser
*iface
,
499 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
501 TRACE("(%p)\n", This
);
503 /* Feature not implemented */
507 /**************************************************************************
508 * IShellBrowserImpl_GetControlWindow
510 HRESULT WINAPI
IShellBrowserImpl_GetControlWindow(IShellBrowser
*iface
,
515 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
517 TRACE("(%p)\n", This
);
519 /* Feature not implemented */
522 /**************************************************************************
523 * IShellBrowserImpl_GetViewStateStream
525 HRESULT WINAPI
IShellBrowserImpl_GetViewStateStream(IShellBrowser
*iface
,
530 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
532 FIXME("(%p 0x%08lx %p)\n", This
, grfMode
, ppStrm
);
534 /* Feature not implemented */
537 /**************************************************************************
538 * IShellBrowserImpl_InsertMenusSB
540 HRESULT WINAPI
IShellBrowserImpl_InsertMenusSB(IShellBrowser
*iface
,
542 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
545 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
547 TRACE("(%p)\n", This
);
549 /* Feature not implemented */
552 /**************************************************************************
553 * IShellBrowserImpl_OnViewWindowActive
555 HRESULT WINAPI
IShellBrowserImpl_OnViewWindowActive(IShellBrowser
*iface
,
559 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
561 TRACE("(%p)\n", This
);
563 /* Feature not implemented */
566 /**************************************************************************
567 * IShellBrowserImpl_QueryActiveShellView
569 HRESULT WINAPI
IShellBrowserImpl_QueryActiveShellView(IShellBrowser
*iface
,
573 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
575 FileOpenDlgInfos
*fodInfos
;
577 TRACE("(%p)\n", This
);
579 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
581 if(!(*ppshv
= fodInfos
->Shell
.FOIShellView
))
585 IShellView_AddRef(fodInfos
->Shell
.FOIShellView
);
588 /**************************************************************************
589 * IShellBrowserImpl_RemoveMenusSB
591 HRESULT WINAPI
IShellBrowserImpl_RemoveMenusSB(IShellBrowser
*iface
,
595 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
597 TRACE("(%p)\n", This
);
599 /* Feature not implemented */
602 /**************************************************************************
603 * IShellBrowserImpl_SendControlMsg
605 HRESULT WINAPI
IShellBrowserImpl_SendControlMsg(IShellBrowser
*iface
,
613 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
616 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
621 lres
= SendDlgItemMessageA( This
->hwndOwner
, IDC_TOOLBAR
, uMsg
, wParam
, lParam
);
624 FIXME("ctrl id: %x\n", id
);
627 if (pret
) *pret
= lres
;
630 /**************************************************************************
631 * IShellBrowserImpl_SetMenuSB
633 HRESULT WINAPI
IShellBrowserImpl_SetMenuSB(IShellBrowser
*iface
,
635 HOLEMENU holemenuReserved
,
636 HWND hwndActiveObject
)
639 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
641 TRACE("(%p)\n", This
);
643 /* Feature not implemented */
646 /**************************************************************************
647 * IShellBrowserImpl_SetStatusTextSB
649 HRESULT WINAPI
IShellBrowserImpl_SetStatusTextSB(IShellBrowser
*iface
,
650 LPCOLESTR lpszStatusText
)
653 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
655 TRACE("(%p)\n", This
);
657 /* Feature not implemented */
660 /**************************************************************************
661 * IShellBrowserImpl_SetToolbarItems
663 HRESULT WINAPI
IShellBrowserImpl_SetToolbarItems(IShellBrowser
*iface
,
664 LPTBBUTTON lpButtons
,
669 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
671 TRACE("(%p)\n", This
);
673 /* Feature not implemented */
676 /**************************************************************************
677 * IShellBrowserImpl_TranslateAcceleratorSB
679 HRESULT WINAPI
IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser
*iface
,
684 IShellBrowserImpl
*This
= (IShellBrowserImpl
*)iface
;
686 TRACE("(%p)\n", This
);
688 /* Feature not implemented */
692 static IShellBrowserVtbl IShellBrowserImpl_Vtbl
=
695 IShellBrowserImpl_QueryInterface
,
696 IShellBrowserImpl_AddRef
,
697 IShellBrowserImpl_Release
,
699 IShellBrowserImpl_GetWindow
,
700 IShellBrowserImpl_ContextSensitiveHelp
,
702 IShellBrowserImpl_InsertMenusSB
,
703 IShellBrowserImpl_SetMenuSB
,
704 IShellBrowserImpl_RemoveMenusSB
,
705 IShellBrowserImpl_SetStatusTextSB
,
706 IShellBrowserImpl_EnableModelessSB
,
707 IShellBrowserImpl_TranslateAcceleratorSB
,
708 IShellBrowserImpl_BrowseObject
,
709 IShellBrowserImpl_GetViewStateStream
,
710 IShellBrowserImpl_GetControlWindow
,
711 IShellBrowserImpl_SendControlMsg
,
712 IShellBrowserImpl_QueryActiveShellView
,
713 IShellBrowserImpl_OnViewWindowActive
,
714 IShellBrowserImpl_SetToolbarItems
723 /***************************************************************************
724 * IShellBrowserImpl_ICommDlgBrowser_QueryInterface
726 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
727 ICommDlgBrowser
*iface
,
731 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser
,iface
);
733 TRACE("(%p)\n", This
);
735 return IShellBrowserImpl_QueryInterface(This
,riid
,ppvObj
);
738 /**************************************************************************
739 * IShellBrowserImpl_ICommDlgBrowser_AddRef
741 ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser
* iface
)
743 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser
,iface
);
745 TRACE("(%p)\n", This
);
747 return IShellBrowserImpl_AddRef(This
);
750 /**************************************************************************
751 * IShellBrowserImpl_ICommDlgBrowser_Release
753 ULONG WINAPI
IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser
* iface
)
755 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser
,iface
);
757 TRACE("(%p)\n", This
);
759 return IShellBrowserImpl_Release(This
);
761 /**************************************************************************
762 * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
764 * Called when a user double-clicks in the view or presses the ENTER key
766 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser
*iface
,
770 FileOpenDlgInfos
*fodInfos
;
772 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
774 TRACE("(%p)\n", This
);
776 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
778 /* If the selected object is not a folder, send an IDOK command to parent window */
779 if((pidl
= GetPidlFromDataObject(fodInfos
->Shell
.FOIDataObject
, 1)))
783 ULONG ulAttr
= SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
784 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, (LPCITEMIDLIST
*)&pidl
, &ulAttr
);
785 if (ulAttr
& (SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
) )
787 hRes
= IShellBrowser_BrowseObject((IShellBrowser
*)This
,pidl
,SBSP_RELATIVE
);
788 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_FOLDERCHANGE
);
792 /* Tell the dialog that the user selected a file */
793 PostMessageA(This
->hwndOwner
, WM_COMMAND
, IDOK
, 0L);
797 /* Free memory used by pidl */
798 COMDLG32_SHFree((LPVOID
)pidl
);
806 /**************************************************************************
807 * IShellBrowserImpl_ICommDlgBrowser_OnStateChange
809 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser
*iface
,
814 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
816 TRACE("(%p shv=%p)\n", This
, ppshv
);
820 case CDBOSC_SETFOCUS
:
821 /* FIXME: Reset the default button.
822 This should be taken care of by defdlg. If control
823 other than button receives focus the default button
824 should be restored. */
825 SendMessageA(This
->hwndOwner
, DM_SETDEFID
, IDOK
, 0);
828 case CDBOSC_KILLFOCUS
:
830 FileOpenDlgInfos
*fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
831 if(fodInfos
->DlgInfos
.dwDlgProp
& FODPROP_SAVEDLG
)
832 SetDlgItemTextA(fodInfos
->ShellInfos
.hwndOwner
,IDOK
,"&Save");
835 case CDBOSC_SELCHANGE
:
836 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface
,ppshv
);
845 /**************************************************************************
846 * IShellBrowserImpl_ICommDlgBrowser_IncludeObject
848 HRESULT WINAPI
IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser
*iface
,
852 FileOpenDlgInfos
*fodInfos
;
855 WCHAR szPathW
[MAX_PATH
];
857 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
859 TRACE("(%p)\n", This
);
861 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
863 ulAttr
= SFGAO_HIDDEN
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
| SFGAO_LINK
;
864 IShellFolder_GetAttributesOf(fodInfos
->Shell
.FOIShellFolder
, 1, &pidl
, &ulAttr
);
866 if( (ulAttr
& SFGAO_HIDDEN
) /* hidden */
867 | !(ulAttr
& (SFGAO_FILESYSTEM
| SFGAO_FILESYSANCESTOR
))) /* special folder */
870 /* always include directories and links */
871 if(ulAttr
& (SFGAO_FOLDER
| SFGAO_LINK
))
874 /* Check if there is a mask to apply if not */
875 if(!fodInfos
->ShellInfos
.lpstrCurrentFilter
|| !lstrlenW(fodInfos
->ShellInfos
.lpstrCurrentFilter
))
878 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos
->Shell
.FOIShellFolder
, pidl
, SHGDN_INFOLDER
| SHGDN_FORPARSING
, &str
)))
880 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW
, MAX_PATH
, &str
, pidl
)))
882 if (PathMatchSpecW(szPathW
, fodInfos
->ShellInfos
.lpstrCurrentFilter
))
890 /**************************************************************************
891 * IShellBrowserImpl_ICommDlgBrowser_OnSelChange
893 HRESULT
IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser
*iface
, IShellView
*ppshv
)
895 FileOpenDlgInfos
*fodInfos
;
897 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl
,iface
);
899 fodInfos
= (FileOpenDlgInfos
*) GetPropA(This
->hwndOwner
,FileOpenDlgInfosStr
);
900 TRACE("(%p do=%p view=%p)\n", This
, fodInfos
->Shell
.FOIDataObject
, fodInfos
->Shell
.FOIShellView
);
902 /* release old selections */
903 if (fodInfos
->Shell
.FOIDataObject
)
904 IDataObject_Release(fodInfos
->Shell
.FOIDataObject
);
906 /* get a new DataObject from the ShellView */
907 if(FAILED(IShellView_GetItemObject(fodInfos
->Shell
.FOIShellView
, SVGIO_SELECTION
,
908 &IID_IDataObject
, (LPVOID
*)&fodInfos
->Shell
.FOIDataObject
)))
911 FILEDLG95_FILENAME_FillFromSelection(This
->hwndOwner
);
913 SendCustomDlgNotificationMessage(This
->hwndOwner
, CDN_SELCHANGE
);
917 static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
920 IShellBrowserImpl_ICommDlgBrowser_QueryInterface
,
921 IShellBrowserImpl_ICommDlgBrowser_AddRef
,
922 IShellBrowserImpl_ICommDlgBrowser_Release
,
923 /* ICommDlgBrowser */
924 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
,
925 IShellBrowserImpl_ICommDlgBrowser_OnStateChange
,
926 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
936 /***************************************************************************
937 * IShellBrowserImpl_IServiceProvider_QueryInterface
939 HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryInterface(
940 IServiceProvider
*iface
,
944 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
946 FIXME("(%p)\n", This
);
948 return IShellBrowserImpl_QueryInterface(This
,riid
,ppvObj
);
951 /**************************************************************************
952 * IShellBrowserImpl_IServiceProvider_AddRef
954 ULONG WINAPI
IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider
* iface
)
956 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
958 FIXME("(%p)\n", This
);
960 return IShellBrowserImpl_AddRef(This
);
963 /**************************************************************************
964 * IShellBrowserImpl_IServiceProvider_Release
966 ULONG WINAPI
IShellBrowserImpl_IServiceProvider_Release(IServiceProvider
* iface
)
968 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
970 FIXME("(%p)\n", This
);
972 return IShellBrowserImpl_Release(This
);
975 /**************************************************************************
976 * IShellBrowserImpl_IServiceProvider_Release
979 * the w2k shellview asks for (guidService = SID_STopLevelBrowser,
980 * riid = IShellBrowser) to call SendControlMsg ().
986 HRESULT WINAPI
IShellBrowserImpl_IServiceProvider_QueryService(
987 IServiceProvider
* iface
,
992 _ICOM_THIS_FromIServiceProvider(IShellBrowser
,iface
);
994 FIXME("(%p)\n\t%s\n\t%s\n", This
,debugstr_guid(guidService
), debugstr_guid(riid
) );
997 if(guidService
&& IsEqualIID(guidService
, &SID_STopLevelBrowser
))
999 return IShellBrowserImpl_QueryInterface(This
,riid
,ppv
);
1001 FIXME("(%p) unknown interface requested\n", This
);
1002 return E_NOINTERFACE
;
1006 static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl
=
1009 IShellBrowserImpl_IServiceProvider_QueryInterface
,
1010 IShellBrowserImpl_IServiceProvider_AddRef
,
1011 IShellBrowserImpl_IServiceProvider_Release
,
1012 /* IServiceProvider */
1013 IShellBrowserImpl_IServiceProvider_QueryService