ReactOS 0.4.15-dev-7711-g5627da4
shellbrowser.cpp
Go to the documentation of this file.
1/*
2 * ReactOS Explorer
3 *
4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include "precomp.h"
22
23#include <shellapi.h>
24#include <htiframe.h>
25#include <strsafe.h>
26
27extern HRESULT IUnknown_ShowDW(IUnknown * punk, BOOL fShow);
28
29#include "newatlinterfaces.h"
30
31/*
32TODO:
33 **Provide implementation of new and delete that use LocalAlloc
34 **Persist history for shell view isn't working correctly, possibly because of the mismatch between traveling and updating the travel log. The
35 view doesn't restore the selection correctly.
36 **Build explorer.exe, browseui.dll, comctl32.dll, shdocvw.dll, shell32.dll, shlwapi.dll into a directory and run them for testing...
37 **Add brand band bitmaps to shell32.dll
38 **If Go button on address bar is clicked, each time a new duplicate entry is added to travel log
39****The current entry is updated in travel log before doing the travel, which means when traveling back the update of the
40 current state overwrites the wrong entry's contents. This needs to be changed.
41****Fix close of browser window to release all objects
42****Given only a GUID in ShowBrowserBar, what is the correct way to determine if the bar is vertical or horizontal?
43 **When a new bar is added to base bar site, how is base bar told so it can resize?
44 **Does the base bar site have a classid?
45 **What should refresh command send to views to make them refresh?
46 **When new bar is created, what status notifications need to be fired?
47 **How does keyboard filtering dispatch?
48 **For deferred persist history load, how does the view connect up and get the state?
49 How does context menu send open, cut, rename commands to its site (the shell view)?
50 **Fix browser to implement IProfferService and hold onto brand band correctly - this will allow animations.
51
52 **Route View->Toolbars commands to internet toolbar
53 **Handle travel log items in View->Go
54 **Fix ShowBrowserBar to pass correct size on when bar is shown
55****Fix SetBorderSpaceDW to cascade resize to subsequent bars
56****Make ShowToolbar check if bar is already created before creating it again
57****Shell should fill in the list of explorer bars in the View submenus
58 **Add folder menu in the file menu
59 **Fix CShellBrowser::GetBorderDW to compute available size correctly
60 **When a new bar is shown, re-fire the navigate event. This makes the explorer band select the correct folder
61 **Implement support for refresh. Forward refresh to explorer bar (refresh on toolbar and in menu is dispatched different)
62 Make folders toolbar item update state appropriately
63 Read list of bands from registry on launch
64 Read list of bars from registry on launch
65 If the folders or search bars don't exist, disable the toolbar buttons
66 If the favorites or history bars don't exist, disable the toolbar butons
67 Fix Apply to all Folders in Folder Options
68 Implement close command
69 Add explorer band context menu to file menu
70 Add code to allow restore of internet toolbar from registry
71 Fix code that calls FireNavigateComplete to pass the correct new path
72
73 What are the other command ids for QueryStatus/FireCommandStateChange?
74
75 Add handler for cabinet settings change
76 Add handler for system metrics change (renegotiate border space?)
77 Add handler for theme change and forward to contained windows
78
79 When folders are shown, the status bar text should change
80 Add code to save/restore shell view settings
81 Implement tabbing between frames
82 Fix handling of focus everywhere
83 Most keyboard shortcuts don't work, such as F2 for rename, F5 for refresh (see list in "explorer keyboard shortcuts")
84
85 The status bar doesn't show help text for items owned by frame during menu tracking
86 Stub out frame command handlers
87 "Arrange icons by" group is not checked properly
88
89 When folders are hidden, icon is the same as the current shell object being displayed. When folders are shown,
90 the icon is always an open folder with magnifying glass
91 Fix bars to calculate height correctly
92 Hookup policies for everything...
93 Investigate toolbar message WM_USER+93
94 Investigate toolbar message WM_USER+100 (Adds extra padding between parts of buttons with BTNS_DROPDOWN | BTNS_SHOWTEXT style
95
96 Vertical Explorer Bar CATID_InfoBand
97 Horizontal Explorer Bar CATID_CommBand
98 Desk Band CATID_DeskBand
99
100 cache of bars
101 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\Component Categories\{00021493-0000-0000-C000-000000000046}\Enum
102 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\Component Categories\{00021494-0000-0000-C000-000000000046}\Enum
103
104 create key here with CLSID of bar to register tool band
105 HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Toolbar
106
107*/
108
109#ifndef __GNUC__
110#pragma comment(linker, \
111 "\"/manifestdependency:type='Win32' "\
112 "name='Microsoft.Windows.Common-Controls' "\
113 "version='6.0.0.0' "\
114 "processorArchitecture='*' "\
115 "publicKeyToken='6595b64144ccf1df' "\
116 "language='*'\"")
117#endif // __GNUC__
118
119static const unsigned int folderOptionsPageCountMax = 20;
120static const long BTP_DONT_UPDATE_HISTORY = 0;
121static const long BTP_UPDATE_CUR_HISTORY = 1;
122static const long BTP_UPDATE_NEXT_HISTORY = 2;
123
125
126
127// this class is private to browseui.dll and is not registered externally?
128//DEFINE_GUID(CLSID_ShellFldSetExt, 0x6D5313C0, 0x8C62, 0x11D1, 0xB2, 0xCD, 0x00, 0x60, 0x97, 0xDF, 0x8C, 0x11);
129
130void DeleteMenuItems(HMENU theMenu, unsigned int firstIDToDelete, unsigned int lastIDToDelete)
131{
132 MENUITEMINFO menuItemInfo;
133 int menuItemCount;
134 int curIndex;
135
136 menuItemCount = GetMenuItemCount(theMenu);
137 curIndex = 0;
138 while (curIndex < menuItemCount)
139 {
140 menuItemInfo.cbSize = sizeof(menuItemInfo);
141 menuItemInfo.fMask = MIIM_ID;
142 if (GetMenuItemInfo(theMenu, curIndex, TRUE, &menuItemInfo) &&
143 menuItemInfo.wID >= firstIDToDelete && menuItemInfo.wID <= lastIDToDelete)
144 {
145 DeleteMenu(theMenu, curIndex, MF_BYPOSITION);
146 menuItemCount--;
147 }
148 else
149 curIndex++;
150 }
151}
152
154{
155 CComPtr<IShellFolder> desktop;
156
157 HRESULT hr = ::SHGetDesktopFolder(&desktop);
159 return E_FAIL;
160 if (path == NULL || path->mkid.cb == 0)
161 {
162 *newFolder = desktop;
163 desktop.p->AddRef ();
164 return S_OK;
165 }
166 return desktop->BindToObject (path, NULL, IID_PPV_ARG(IShellFolder, newFolder));
167}
168
169static const TCHAR szCabinetWndClass[] = TEXT("CabinetWClass");
170//static const TCHAR szExploreWndClass[] = TEXT("ExploreWClass");
171
172class CDockManager;
173class CShellBrowser;
174
176 public CWindowImpl<CToolbarProxy, CWindow, CControlWinTraits>
177{
178private:
180public:
181 void Initialize(HWND parent, IUnknown *explorerToolbar);
182 void Destroy();
183private:
184
185 // message handlers
188
193};
194
196{
197 HWND myWindow;
198 HRESULT hResult;
199
200 myWindow = SHCreateWorkerWindowW(0, parent, 0, WS_CHILD, NULL, 0);
201 if (myWindow != NULL)
202 {
203 SubclassWindow(myWindow);
204 SetWindowPos(NULL, -32000, -32000, 0, 0, SWP_NOOWNERZORDER | SWP_NOZORDER);
205 hResult = explorerToolbar->QueryInterface(
206 IID_PPV_ARG(IExplorerToolbar, &fExplorerToolbar));
207 }
208}
209
211{
214}
215
217{
218 long int result;
219 HRESULT hResult;
220
221 result = 0;
222 if (fExplorerToolbar.p != NULL)
223 {
224 hResult = fExplorerToolbar->AddBitmap(&CGID_ShellBrowser, 1, (long)wParam,
225 reinterpret_cast<TBADDBITMAP *>(lParam), &result, RGB(192, 192, 192));
226 hResult = fExplorerToolbar->AddBitmap(&CGID_ShellBrowser, 2, (long)wParam,
227 reinterpret_cast<TBADDBITMAP *>(lParam), &result, RGB(192, 192, 192));
228 }
229 return result;
230}
231
233{
235 HRESULT hResult;
236
237 result = 0;
238 if (fExplorerToolbar.p != NULL)
239 hResult = fExplorerToolbar->SendToolbarMsg(&CGID_ShellBrowser, uMsg, wParam, lParam, &result);
240 return result;
241}
242
243/*
244Switch to a new bar when it receives an Exec(CGID_IDeskBand, 1, 1, vaIn, NULL);
245 where vaIn will be a VT_UNKNOWN with the new bar. It also sends a RB_SHOWBAND to the
246 rebar
247*/
248
252};
253
255 public CWindowImpl<CShellBrowser, CWindow, CFrameWinTraits>,
256 public CComObjectRootEx<CComMultiThreadModelNoCS>,
257 public IShellBrowser,
258 public IDropTarget,
259 public IServiceProvider,
260 public IProfferServiceImpl<CShellBrowser>,
261 public IShellBrowserService,
262 public IWebBrowser2,
263 public ITravelLogClient,
264 public IPersistHistory,
265 public IDockingWindowSite,
266 public IOleCommandTarget,
267 public IBrowserService2,
268 public IConnectionPointContainerImpl<CShellBrowser>,
269 public MyIConnectionPointImpl<CShellBrowser, &DIID_DWebBrowserEvents2>,
270 public MyIConnectionPointImpl<CShellBrowser, &DIID_DWebBrowserEvents>
271{
272private:
274 {
275 public:
277 {
278 memset(&borderSpace, 0, sizeof(borderSpace));
279 hwnd = NULL;
280 }
281
285 };
286 static const int BIInternetToolbar = 0;
287 static const int BIVerticalBaseBar = 1;
288 static const int BIHorizontalBaseBar = 2;
289
290 HWND fCurrentShellViewWindow; // our currently hosted shell view window
299 GUID fCurrentVertBar; //The guid of the built in vertical bar that is being shown
300 // The next three fields support persisted history for shell views.
301 // They do not need to be reference counted.
306 HACCEL m_hAccel;
308public:
309#if 0
311 {
312 OutputDebugString(_T("AddRef\n"));
314 }
316 {
317 OutputDebugString(_T("Release\n"));
319 }
320#endif
321
325public:
327 HRESULT BrowseToPath(IShellFolder *newShellFolder, LPCITEMIDLIST absolutePIDL,
328 FOLDERSETTINGS *folderSettings, long flags);
329 HRESULT GetMenuBand(REFIID riid, void **shellMenu);
330 HRESULT GetBaseBar(bool vertical, REFIID riid, void **theBaseBar);
331 BOOL IsBandLoaded(const CLSID clsidBand, bool vertical, DWORD *pdwBandID);
332 HRESULT ShowBand(const CLSID &classID, bool vertical);
336 void RepositionBars();
338 HRESULT BuildExplorerBandCategory(HMENU hBandsMenu, CATID category, DWORD dwPos, UINT *nbFound);
339 BOOL IsBuiltinBand(CLSID &bandID);
341 {
342 return WindowProc;
343 }
344 HRESULT FireEvent(DISPID dispIdMember, int argCount, VARIANT *arguments);
345 HRESULT FireNavigateComplete(const wchar_t *newDirectory);
346 HRESULT FireCommandStateChange(bool newState, int commandID);
350 void UpdateGotoMenu(HMENU theMenu);
351 void UpdateViewMenu(HMENU theMenu);
352 void RefreshCabinetState();
353 void UpdateWindowTitle();
354
355/* // *** IDockingWindowFrame methods ***
356 virtual HRESULT STDMETHODCALLTYPE AddToolbar(IUnknown *punkSrc, LPCWSTR pwszItem, DWORD dwAddFlags);
357 virtual HRESULT STDMETHODCALLTYPE RemoveToolbar(IUnknown *punkSrc, DWORD dwRemoveFlags);
358 virtual HRESULT STDMETHODCALLTYPE FindToolbar(LPCWSTR pwszItem, REFIID riid, void **ppv);
359 */
360
361 // *** IDockingWindowSite methods ***
362 virtual HRESULT STDMETHODCALLTYPE GetBorderDW(IUnknown* punkObj, LPRECT prcBorder);
363 virtual HRESULT STDMETHODCALLTYPE RequestBorderSpaceDW(IUnknown* punkObj, LPCBORDERWIDTHS pbw);
364 virtual HRESULT STDMETHODCALLTYPE SetBorderSpaceDW(IUnknown* punkObj, LPCBORDERWIDTHS pbw);
365
366 // *** IOleCommandTarget methods ***
367 virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds,
368 OLECMD prgCmds[ ], OLECMDTEXT *pCmdText);
369 virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID,
370 DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
371
372 // *** IOleWindow methods ***
373 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *lphwnd);
375
376 // *** IShellBrowser methods ***
377 virtual HRESULT STDMETHODCALLTYPE InsertMenusSB(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths);
378 virtual HRESULT STDMETHODCALLTYPE SetMenuSB(HMENU hmenuShared, HOLEMENU holemenuRes, HWND hwndActiveObject);
379 virtual HRESULT STDMETHODCALLTYPE RemoveMenusSB(HMENU hmenuShared);
380 virtual HRESULT STDMETHODCALLTYPE SetStatusTextSB(LPCOLESTR pszStatusText);
384 virtual HRESULT STDMETHODCALLTYPE GetViewStateStream(DWORD grfMode, IStream **ppStrm);
389 virtual HRESULT STDMETHODCALLTYPE SetToolbarItems(LPTBBUTTON lpButtons, UINT nButtons, UINT uFlags);
390
391 // *** IDropTarget methods ***
392 virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
393 virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
395 virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
396
397 // *** IServiceProvider methods ***
398 virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject);
399
400 // *** IShellBowserService methods ***
402
403 // *** IDispatch methods ***
405 virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
407 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
408 virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
409 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
410
411 // *** IBrowserService methods ***
413 virtual HRESULT STDMETHODCALLTYPE SetTitle(IShellView *psv, LPCWSTR pszName);
420 virtual HRESULT STDMETHODCALLTYPE IEParseDisplayName(UINT uiCP, LPCWSTR pwszPath, LPITEMIDLIST *ppidlOut);
425 virtual HRESULT STDMETHODCALLTYPE NotifyRedirect(IShellView *psv, LPCITEMIDLIST pidl, BOOL *pfDidBrowse);
429 virtual HRESULT STDMETHODCALLTYPE GetFlags(DWORD *pdwFlags);
435 virtual HRESULT STDMETHODCALLTYPE GetHistoryObject(IOleObject **ppole, IStream **pstm, IBindCtx **ppbc);
436 virtual HRESULT STDMETHODCALLTYPE SetHistoryObject(IOleObject *pole, BOOL fIsLocalAnchor);
438 virtual HRESULT STDMETHODCALLTYPE GetSetCodePage(VARIANT *pvarIn, VARIANT *pvarOut);
439 virtual HRESULT STDMETHODCALLTYPE OnHttpEquiv(IShellView *psv, BOOL fDone, VARIANT *pvarargIn, VARIANT *pvarargOut);
440 virtual HRESULT STDMETHODCALLTYPE GetPalette(HPALETTE *hpal);
441 virtual HRESULT STDMETHODCALLTYPE RegisterWindow(BOOL fForceRegister, int swc);
442
443 // *** IBrowserService2 methods ***
451 virtual LRESULT STDMETHODCALLTYPE OnNotify(struct tagNMHDR *pnm);
456 virtual HRESULT STDMETHODCALLTYPE CreateViewWindow(IShellView *psvNew, IShellView *psvOld, LPRECT prcView, HWND *phwnd);
458 virtual HRESULT STDMETHODCALLTYPE GetViewWindow(HWND *phwndView);
463 virtual HRESULT STDMETHODCALLTYPE Offline(int iCmd);
466 virtual HRESULT STDMETHODCALLTYPE UpdateSecureLockIcon(int eSecureLock);
478 virtual HRESULT STDMETHODCALLTYPE _ExecChildren(IUnknown *punkBar, BOOL fBroadcast, const GUID *pguidCmdGroup,
479 DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
481 HWND hwndBar, BOOL fBroadcast, UINT uMsg, WPARAM wParam, LPARAM lParam);
486 virtual HRESULT STDMETHODCALLTYPE _put_itbLastFocus(UINT itbLastFocus);
493 virtual IStream *STDMETHODCALLTYPE v_GetViewStream(LPCITEMIDLIST pidl, DWORD grfMode, LPCWSTR pwszName);
495 virtual HRESULT STDMETHODCALLTYPE SetAcceleratorMenu(HACCEL hacc);
502 int citb, LPTOOLBARITEM *pptbi, HWND *phwnd);
503 virtual HRESULT STDMETHODCALLTYPE _ResizeNextBorderHelper(UINT itb, BOOL bUseHmonitor);
504 virtual UINT STDMETHODCALLTYPE _FindTBar(IUnknown *punkSrc);
507 virtual HRESULT STDMETHODCALLTYPE _GetBorderDWHelper(IUnknown *punkSrc, LPRECT lprectBorder, BOOL bUseHmonitor);
509
510 // *** IWebBrowser methods ***
515 virtual HRESULT STDMETHODCALLTYPE Navigate(BSTR URL, VARIANT *Flags, VARIANT *TargetFrameName,
516 VARIANT *PostData, VARIANT *Headers);
526 virtual HRESULT STDMETHODCALLTYPE get_Left(long *pl);
527 virtual HRESULT STDMETHODCALLTYPE put_Left(long Left);
528 virtual HRESULT STDMETHODCALLTYPE get_Top(long *pl);
529 virtual HRESULT STDMETHODCALLTYPE put_Top(long Top);
530 virtual HRESULT STDMETHODCALLTYPE get_Width(long *pl);
532 virtual HRESULT STDMETHODCALLTYPE get_Height(long *pl);
534 virtual HRESULT STDMETHODCALLTYPE get_LocationName(BSTR *LocationName);
535 virtual HRESULT STDMETHODCALLTYPE get_LocationURL(BSTR *LocationURL);
537
538 // *** IWebBrowserApp methods ***
540 virtual HRESULT STDMETHODCALLTYPE ClientToWindow(int *pcx, int *pcy);
551 virtual HRESULT STDMETHODCALLTYPE get_StatusText(BSTR *StatusText);
552 virtual HRESULT STDMETHODCALLTYPE put_StatusText(BSTR StatusText);
559
560 // *** IWebBrowser2 methods ***
561 virtual HRESULT STDMETHODCALLTYPE Navigate2(VARIANT *URL, VARIANT *Flags, VARIANT *TargetFrameName,
562 VARIANT *PostData, VARIANT *Headers);
564 virtual HRESULT STDMETHODCALLTYPE ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt,
565 VARIANT *pvaIn, VARIANT *pvaOut);
566 virtual HRESULT STDMETHODCALLTYPE ShowBrowserBar(VARIANT *pvaClsid, VARIANT *pvarShow, VARIANT *pvarSize);
567 virtual HRESULT STDMETHODCALLTYPE get_ReadyState(READYSTATE *plReadyState);
582
583 // *** ITravelLogClient methods ***
585 virtual HRESULT STDMETHODCALLTYPE GetWindowData(IStream *pStream, LPWINDOWDATA pWinData);
586 virtual HRESULT STDMETHODCALLTYPE LoadHistoryPosition(LPWSTR pszUrlLocation, DWORD dwPosition);
587
588 // *** IPersist methods ***
589 virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
590
591 // *** IPersistHistory methods ***
592 virtual HRESULT STDMETHODCALLTYPE LoadHistory(IStream *pStream, IBindCtx *pbc);
594 virtual HRESULT STDMETHODCALLTYPE SetPositionCookie(DWORD dwPositioncookie);
595 virtual HRESULT STDMETHODCALLTYPE GetPositionCookie(DWORD *pdwPositioncookie);
596
597 // message handlers
598 LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
599 LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
600 LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
605 LRESULT OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
606 LRESULT OnFolderOptions(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
607 LRESULT OnMapNetworkDrive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
608 LRESULT OnDisconnectNetworkDrive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
609 LRESULT OnAboutReactOS(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
610 LRESULT OnGoBack(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
611 LRESULT OnGoForward(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
612 LRESULT OnGoUpLevel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
613 LRESULT OnBackspace(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
614 LRESULT OnGoHome(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
615 LRESULT OnAddToFavorites(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
616 LRESULT OnOrganizeFavorites(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
617 LRESULT OnToggleStatusBarVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
618 LRESULT OnToggleToolbarLock(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
619 LRESULT OnToggleToolbarBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
620 LRESULT OnToggleAddressBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
621 LRESULT OnToggleLinksBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
622 LRESULT OnToggleTextLabels(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
623 LRESULT OnToolbarCustomize(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
624 LRESULT OnGoTravel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
625 LRESULT OnRefresh(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
626 LRESULT OnExplorerBar(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
632
634 {
635 static ATL::CWndClassInfo wc =
636 {
638 0, 0, NULL, LoadIcon(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDI_CABINET)),
640 NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
641 };
642 return wc;
643 }
644
686
688 CONNECTION_POINT_ENTRY(DIID_DWebBrowserEvents2)
689 CONNECTION_POINT_ENTRY(DIID_DWebBrowserEvents)
691
693 COM_INTERFACE_ENTRY_IID(IID_IDockingWindowSite, IDockingWindowSite)
694 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
696 COM_INTERFACE_ENTRY_IID(IID_IShellBrowser, IShellBrowser)
697 COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget)
698 COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
699 COM_INTERFACE_ENTRY_IID(IID_IProfferService, IProfferService)
700 COM_INTERFACE_ENTRY_IID(IID_IShellBrowserService, IShellBrowserService)
703 COM_INTERFACE_ENTRY_IID(IID_IWebBrowser, IWebBrowser)
704 COM_INTERFACE_ENTRY_IID(IID_IWebBrowserApp, IWebBrowserApp)
705 COM_INTERFACE_ENTRY_IID(IID_IWebBrowser2, IWebBrowser2)
706 COM_INTERFACE_ENTRY_IID(IID_ITravelLogClient, ITravelLogClient)
708 COM_INTERFACE_ENTRY_IID(IID_IPersistHistory, IPersistHistory)
709 COM_INTERFACE_ENTRY_IID(IID_IBrowserService, IBrowserService)
710 COM_INTERFACE_ENTRY_IID(IID_IBrowserService2, IBrowserService2)
712};
713
715
717{
727}
728
730{
731 if (menuDsa)
733}
734
736{
737 CComPtr<IPersistStreamInit> persistStreamInit;
738 HRESULT hResult;
739 CComPtr<IUnknown> clientBar;
740
742
743 menuDsa = DSA_Create(sizeof(MenuBandInfo), 5);
744 if (!menuDsa)
745 return E_OUTOFMEMORY;
746
747 // create window
749 if (m_hWnd == NULL)
750 return E_FAIL;
751
753 if (FAILED_UNEXPECTEDLY(hResult))
754 return hResult;
755
757
758 // create interfaces
759 hResult = clientBar->QueryInterface(IID_PPV_ARG(IPersistStreamInit, &persistStreamInit));
760 if (FAILED_UNEXPECTEDLY(hResult))
761 return hResult;
762
763 hResult = IUnknown_SetSite(clientBar, static_cast<IShellBrowser *>(this));
764 if (FAILED_UNEXPECTEDLY(hResult))
765 return hResult;
766
767 hResult = IUnknown_Exec(clientBar, CGID_PrivCITCommands, 1, 1 /* or 0 */, NULL, NULL);
768 if (FAILED_UNEXPECTEDLY(hResult))
769 return hResult;
770
771 // TODO: create settingsStream from registry entry
772 //if (settingsStream.p)
773 //{
774 // hResult = persistStreamInit->Load(settingsStream);
775 // if (FAILED_UNEXPECTEDLY(hResult))
776 // return hResult;
777 //}
778 //else
779 {
780 hResult = persistStreamInit->InitNew();
781 if (FAILED_UNEXPECTEDLY(hResult))
782 return hResult;
783 }
784
785 hResult = IUnknown_ShowDW(clientBar, TRUE);
786 if (FAILED_UNEXPECTEDLY(hResult))
787 return hResult;
788
789 fToolbarProxy.Initialize(m_hWnd, clientBar);
790
791 // create status bar
794 dwStatusStyle |= WS_VISIBLE;
796 0, 0, 500, 20, m_hWnd, (HMENU)IDC_STATUSBAR,
797 _AtlBaseModule.GetModuleInstance(), 0);
798
800 UpdateWindow();
801
802 return S_OK;
803}
804
806{
807 CComPtr<IShellFolder> newFolder;
808 FOLDERSETTINGS newFolderSettings;
809 HRESULT hResult;
810 CLSID clsid;
811 BOOL HasIconViewType;
812
813 // called by shell view to browse to new folder
814 // also called by explorer band to navigate to new folder
815 hResult = SHBindToFolder(pidl, &newFolder);
816 if (FAILED_UNEXPECTEDLY(hResult))
817 return hResult;
818 // HACK & FIXME: Get view mode from shellbag when fully implemented.
819 IUnknown_GetClassID(newFolder, &clsid);
820 HasIconViewType = clsid == CLSID_MyComputer || clsid == CLSID_ControlPanel ||
821 clsid == CLSID_ShellDesktop;
822
823 if (HasIconViewType)
824 newFolderSettings.ViewMode = FVM_ICON;
825 else
826 newFolderSettings.ViewMode = FVM_DETAILS;
827 newFolderSettings.fFlags = 0;
828 hResult = BrowseToPath(newFolder, pidl, &newFolderSettings, flags);
829 if (FAILED_UNEXPECTEDLY(hResult))
830 return hResult;
831 return S_OK;
832}
833
835{
836 LPCITEMIDLIST pidlnext;
837 WORD length;
838 BOOL ret;
839
840 ret = TRUE;
841 if (! _ILIsDesktop(pidl))
842 {
843 length = pidl->mkid.cb;
844 pidlnext =
845 reinterpret_cast<LPCITEMIDLIST>(
846 reinterpret_cast<const BYTE *>(pidl) + length);
847 if (pidlnext->mkid.cb != 0)
848 ret = FALSE;
849 }
850 return ret;
851}
852
854 const IID *riid, LPVOID *ppv, LPITEMIDLIST *ppidlLast)
855{
857 LPITEMIDLIST pidlChild;
858 LPITEMIDLIST pidlParent;
859 HRESULT hResult;
860
861 hResult = E_FAIL;
862 if (ppv == NULL)
863 return E_POINTER;
864 *ppv = NULL;
865 if (ppidlLast != NULL)
866 *ppidlLast = NULL;
867 if (_ILIsPidlSimple(pidl))
868 {
869 if (ppidlLast != NULL)
870 *ppidlLast = ILClone(pidl);
871 hResult = SHGetDesktopFolder((IShellFolder **)ppv);
872 }
873 else
874 {
875 pidlChild = ILClone(ILFindLastID(pidl));
876 pidlParent = ILClone(pidl);
877 ILRemoveLastID(pidlParent);
878 hResult = SHGetDesktopFolder(&psf);
879 if (SUCCEEDED(hResult))
880 hResult = psf->BindToObject(pidlParent, NULL, *riid, ppv);
881 if (SUCCEEDED(hResult) && ppidlLast != NULL)
882 *ppidlLast = pidlChild;
883 else
884 ILFree(pidlChild);
885 ILFree(pidlParent);
886 }
887 return hResult;
888}
889
891 LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
892{
893 CComPtr<IShellFolder> parentFolder;
894 LPITEMIDLIST childPIDL = NULL;
895 STRRET L108;
896 HRESULT hResult;
897
898 hResult = SHBindToFolderIDListParent(NULL, pidl, &IID_PPV_ARG(IShellFolder, &parentFolder), &childPIDL);
899 if (FAILED(hResult))
900 goto cleanup;
901
902 hResult = parentFolder->GetDisplayNameOf(childPIDL, uFlags, &L108);
903 if (FAILED(hResult))
904 goto cleanup;
905
906 StrRetToBufW(&L108, childPIDL, pszBuf, cchBuf);
907 if (rgfInOut)
908 {
909 hResult = parentFolder->GetAttributesOf(1, const_cast<LPCITEMIDLIST *>(&childPIDL), rgfInOut);
910 if (FAILED(hResult))
911 goto cleanup;
912 }
913
914 hResult = S_OK;
915
916cleanup:
917 if (childPIDL)
918 ILFree(childPIDL);
919 return hResult;
920}
921
922HRESULT IEGetNameAndFlags(LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
923{
924 return IEGetNameAndFlagsEx(pidl, uFlags, 0, pszBuf, cchBuf, rgfInOut);
925}
926
928 LPCITEMIDLIST absolutePIDL, FOLDERSETTINGS *folderSettings, long flags)
929{
930 CComPtr<IShellFolder> saveCurrentShellFolder;
931 CComPtr<IShellView> saveCurrentShellView;
932 CComPtr<IShellView> newShellView;
933 CComPtr<ITravelLog> travelLog;
934 HWND newShellViewWindow;
935 BOOL windowUpdateIsLocked;
936 RECT shellViewWindowBounds;
937 HWND previousView;
938 HCURSOR saveCursor;
939 wchar_t newTitle[MAX_PATH];
940 SHGDNF nameFlags;
941 HRESULT hResult;
942
943 if (newShellFolder == NULL)
944 return E_INVALIDARG;
945
946 hResult = GetTravelLog(&travelLog);
947 if (FAILED_UNEXPECTEDLY(hResult))
948 return hResult;
949
950 // update history
952 {
953 if (travelLog->CountEntries(static_cast<IDropTarget *>(this)) > 0)
954 hResult = travelLog->UpdateEntry(static_cast<IDropTarget *>(this), FALSE);
955 // what to do with error? Do we want to halt browse because state save failed?
956 }
957
959 {
960 fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
961 }
962
963 // create view object
964 hResult = newShellFolder->CreateViewObject(m_hWnd, IID_PPV_ARG(IShellView, &newShellView));
965 if (FAILED_UNEXPECTEDLY(hResult))
966 return hResult;
967 previousView = fCurrentShellViewWindow;
968
969 // enter updating section
970 saveCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
971 windowUpdateIsLocked = LockWindowUpdate(TRUE);
972 if (fCurrentShellView != NULL)
974
975 // set site
976 hResult = IUnknown_SetSite(newShellView, static_cast<IDropTarget *>(this));
977
978 // update folder and view
979 saveCurrentShellFolder = fCurrentShellFolder;
980 saveCurrentShellView = fCurrentShellView;
981 fCurrentShellFolder = newShellFolder;
982 fCurrentShellView = newShellView;
983
984 // get boundary
985 if (previousView != NULL)
986 ::GetWindowRect(previousView, &shellViewWindowBounds);
987 else
988 ZeroMemory(&shellViewWindowBounds, sizeof(shellViewWindowBounds));
989 ::MapWindowPoints(0, m_hWnd, reinterpret_cast<POINT *>(&shellViewWindowBounds), 2);
990
991 // update current pidl
993 fCurrentDirectoryPIDL = ILClone(absolutePIDL);
994
995 // create view window
996 hResult = newShellView->CreateViewWindow(saveCurrentShellView, folderSettings,
997 this, &shellViewWindowBounds, &newShellViewWindow);
998 if (FAILED_UNEXPECTEDLY(hResult) || newShellViewWindow == NULL)
999 {
1000 fCurrentShellView = saveCurrentShellView;
1001 fCurrentShellFolder = saveCurrentShellFolder;
1003 if (windowUpdateIsLocked)
1005 SetCursor(saveCursor);
1006 return hResult;
1007 }
1008
1009 // update view window
1010 if (saveCurrentShellView != NULL)
1011 saveCurrentShellView->DestroyViewWindow();
1012 fCurrentShellViewWindow = newShellViewWindow;
1013
1014 if (previousView == NULL)
1015 {
1017 }
1018
1019 // no use
1020 saveCurrentShellView.Release();
1021 saveCurrentShellFolder.Release();
1022
1023 hResult = newShellView->UIActivate(SVUIA_ACTIVATE_FOCUS);
1024
1025 // leave updating section
1026 if (windowUpdateIsLocked)
1028 SetCursor(saveCursor);
1029
1030 // update history
1032 {
1033 hResult = travelLog->AddEntry(static_cast<IDropTarget *>(this), FALSE);
1034 hResult = travelLog->UpdateEntry(static_cast<IDropTarget *>(this), FALSE);
1035 }
1036
1037 // completed
1038 nameFlags = SHGDN_FORADDRESSBAR | SHGDN_FORPARSING;
1039 hResult = IEGetNameAndFlags(fCurrentDirectoryPIDL, nameFlags, newTitle,
1040 sizeof(newTitle) / sizeof(wchar_t), NULL);
1041 if (SUCCEEDED(hResult))
1042 {
1043 FireNavigateComplete(newTitle);
1044 }
1045 else
1046 {
1047 FireNavigateComplete(L"ERROR");
1048 }
1049
1051
1052 LPCITEMIDLIST pidlChild;
1053 INT index, indexOpen;
1054 HIMAGELIST himlSmall, himlLarge;
1055
1057 hResult = SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
1058 if (SUCCEEDED(hResult))
1059 {
1060 index = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
1061
1062 Shell_GetImageLists(&himlLarge, &himlSmall);
1063
1064 HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
1065 HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
1066
1067 /* Hack to make it possible to release the old icons */
1068 /* Something seems to go wrong with WM_SETICON */
1069 HICON oldSmall = (HICON)SendMessage(WM_GETICON, ICON_SMALL, 0);
1070 HICON oldLarge = (HICON)SendMessage(WM_GETICON, ICON_BIG, 0);
1071
1072 SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icSmall));
1073 SendMessage(WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icLarge));
1074
1075 DestroyIcon(oldSmall);
1076 DestroyIcon(oldLarge);
1077 }
1078
1080 hResult = UpdateForwardBackState();
1081 hResult = UpdateUpState();
1082 return S_OK;
1083}
1084
1086{
1087 CComPtr<IBandSite> bandSite;
1088 CComPtr<IDeskBand> deskBand;
1089 HRESULT hResult;
1090
1091 if (!fClientBars[BIInternetToolbar].clientBar)
1092 return E_FAIL;
1093
1095 if (FAILED_UNEXPECTEDLY(hResult))
1096 return hResult;
1097
1098 hResult = bandSite->QueryBand(1, &deskBand, NULL, NULL, 0);
1099 if (FAILED_UNEXPECTEDLY(hResult))
1100 return hResult;
1101
1102 return deskBand->QueryInterface(riid, shellMenu);
1103}
1104
1105HRESULT CShellBrowser::GetBaseBar(bool vertical, REFIID riid, void **theBaseBar)
1106{
1107 CComPtr<IUnknown> newBaseBar;
1108 CComPtr<IDeskBar> deskBar;
1109 CComPtr<IUnknown> newBaseBarSite;
1110 CComPtr<IDeskBarClient> deskBarClient;
1111 IUnknown **cache;
1112 HRESULT hResult;
1113
1114 if (vertical)
1116 else
1118 if (*cache == NULL)
1119 {
1120 hResult = CBaseBar_CreateInstance(IID_PPV_ARG(IUnknown, &newBaseBar), vertical);
1121 if (FAILED_UNEXPECTEDLY(hResult))
1122 return hResult;
1123 hResult = CBaseBarSite_CreateInstance(IID_PPV_ARG(IUnknown, &newBaseBarSite), vertical);
1124 if (FAILED_UNEXPECTEDLY(hResult))
1125 return hResult;
1126
1127 // we have to store our basebar into cache now
1128 *cache = newBaseBar;
1129 (*cache)->AddRef();
1130
1131 // tell the new base bar about the shell browser
1132 hResult = IUnknown_SetSite(newBaseBar, static_cast<IDropTarget *>(this));
1133 if (FAILED_UNEXPECTEDLY(hResult))
1134 return hResult;
1135
1136 // tell the new base bar about the new base bar site
1137 hResult = newBaseBar->QueryInterface(IID_PPV_ARG(IDeskBar, &deskBar));
1138 if (FAILED_UNEXPECTEDLY(hResult))
1139 return hResult;
1140 hResult = deskBar->SetClient(newBaseBarSite);
1141 if (FAILED_UNEXPECTEDLY(hResult))
1142 return hResult;
1143
1144 // tell the new base bar site about the new base bar
1145 hResult = newBaseBarSite->QueryInterface(IID_PPV_ARG(IDeskBarClient, &deskBarClient));
1146 if (FAILED_UNEXPECTEDLY(hResult))
1147 return hResult;
1148 hResult = deskBarClient->SetDeskBarSite(newBaseBar);
1149 if (FAILED_UNEXPECTEDLY(hResult))
1150 return hResult;
1151
1152 }
1153 return (*cache)->QueryInterface(riid, theBaseBar);
1154}
1155
1156BOOL CShellBrowser::IsBandLoaded(const CLSID clsidBand, bool vertical, DWORD *pdwBandID)
1157{
1158 HRESULT hResult;
1159 CComPtr<IDeskBar> deskBar;
1160 CComPtr<IUnknown> baseBarSite;
1161 CComPtr<IBandSite> bandSite;
1162 CLSID clsidTmp;
1163 DWORD numBands;
1164 DWORD dwBandID;
1165 DWORD i;
1166
1167 /* Get our basebarsite to be able to enumerate bands */
1168 hResult = GetBaseBar(vertical, IID_PPV_ARG(IDeskBar, &deskBar));
1169 if (FAILED_UNEXPECTEDLY(hResult))
1170 return FALSE;
1171 hResult = deskBar->GetClient(&baseBarSite);
1172 if (FAILED_UNEXPECTEDLY(hResult))
1173 return FALSE;
1174 hResult = baseBarSite->QueryInterface(IID_PPV_ARG(IBandSite, &bandSite));
1175 if (FAILED_UNEXPECTEDLY(hResult))
1176 return FALSE;
1177
1178 hResult = bandSite->EnumBands(-1, &numBands);
1179 if (FAILED_UNEXPECTEDLY(hResult))
1180 return FALSE;
1181
1182 for(i = 0; i < numBands; i++)
1183 {
1184 CComPtr<IPersist> bandPersist;
1185
1186 hResult = bandSite->EnumBands(i, &dwBandID);
1187 if (FAILED_UNEXPECTEDLY(hResult))
1188 return FALSE;
1189
1190 hResult = bandSite->GetBandObject(dwBandID, IID_PPV_ARG(IPersist, &bandPersist));
1191 if (FAILED_UNEXPECTEDLY(hResult))
1192 return FALSE;
1193 hResult = bandPersist->GetClassID(&clsidTmp);
1194 if (FAILED_UNEXPECTEDLY(hResult))
1195 return FALSE;
1196 if (IsEqualGUID(clsidBand, clsidTmp))
1197 {
1198 if (pdwBandID) *pdwBandID = dwBandID;
1199 return TRUE;
1200 }
1201 }
1202 return FALSE;
1203}
1204
1205HRESULT CShellBrowser::ShowBand(const CLSID &classID, bool vertical)
1206{
1207 CComPtr<IDockingWindow> dockingWindow;
1208 CComPtr<IUnknown> baseBarSite;
1209 CComPtr<IUnknown> newBand;
1210 CComPtr<IDeskBar> deskBar;
1211 VARIANT vaIn;
1212 HRESULT hResult;
1213 DWORD dwBandID;
1214
1215 hResult = GetBaseBar(vertical, IID_PPV_ARG(IDeskBar, &deskBar));
1216 if (FAILED_UNEXPECTEDLY(hResult))
1217 return hResult;
1218
1219 hResult = deskBar->GetClient(&baseBarSite);
1220 if (FAILED_UNEXPECTEDLY(hResult))
1221 return hResult;
1222
1223 hResult = deskBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
1224 if (FAILED_UNEXPECTEDLY(hResult))
1225 return hResult;
1226
1227 if (!IsBandLoaded(classID, vertical, &dwBandID))
1228 {
1229 TRACE("ShowBand called for CLSID %s, vertical=%d...\n", wine_dbgstr_guid(&classID), vertical);
1230 if (IsEqualCLSID(CLSID_ExplorerBand, classID))
1231 {
1232 TRACE("CLSID_ExplorerBand requested, building internal band.\n");
1234 if (FAILED_UNEXPECTEDLY(hResult))
1235 return hResult;
1236 }
1237 else if (IsEqualCLSID(classID, CLSID_FileSearchBand))
1238 {
1239 TRACE("CLSID_FileSearchBand requested, building internal band.\n");
1240 hResult = CSearchBar_CreateInstance(IID_PPV_ARG(IUnknown, &newBand));
1241 if (FAILED_UNEXPECTEDLY(hResult))
1242 return hResult;
1243 }
1244 else
1245 {
1246 TRACE("A different CLSID requested, using CoCreateInstance.\n");
1247 hResult = CoCreateInstance(classID, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IUnknown, &newBand));
1248 if (FAILED_UNEXPECTEDLY(hResult))
1249 return hResult;
1250 }
1251 }
1252 else
1253 {
1254 CComPtr<IBandSite> pBandSite;
1255
1256 hResult = baseBarSite->QueryInterface(IID_PPV_ARG(IBandSite, &pBandSite));
1257 if (!SUCCEEDED(hResult))
1258 {
1259 ERR("Can't get IBandSite interface\n");
1260 return E_FAIL;
1261 }
1262 hResult = pBandSite->GetBandObject(dwBandID, IID_PPV_ARG(IUnknown, &newBand));
1263 if (!SUCCEEDED(hResult))
1264 {
1265 ERR("Can't find band object\n");
1266 return E_FAIL;
1267 }
1268
1269 // It's hackish, but we should be able to show the wanted band until we
1270 // find the proper way to do this (but it seems to work to add a new band)
1271 // Here we'll just re-add the existing band to the site, causing it to display.
1272 }
1273 V_VT(&vaIn) = VT_UNKNOWN;
1274 V_UNKNOWN(&vaIn) = newBand.p;
1275 hResult = IUnknown_Exec(baseBarSite, CGID_IDeskBand, 1, 1, &vaIn, NULL);
1276 if (FAILED_UNEXPECTEDLY(hResult))
1277 {
1278 return hResult;
1279 }
1280
1281 hResult = dockingWindow->ShowDW(TRUE);
1282 if (FAILED_UNEXPECTEDLY(hResult))
1283 return hResult;
1284
1285 if (vertical)
1286 {
1287 fCurrentVertBar = classID;
1289 }
1290
1291 return S_OK;
1292}
1293
1295{
1297 if (newDirectory == NULL)
1298 return E_OUTOFMEMORY;
1299 if (_ILIsDesktop(newDirectory))
1300 {
1301 ILFree(newDirectory);
1302 return E_INVALIDARG;
1303 }
1304 ILRemoveLastID(newDirectory);
1306 ILFree(newDirectory);
1307 if (FAILED_UNEXPECTEDLY(hResult))
1308 return hResult;
1309 return S_OK;
1310}
1311
1313{
1314 PROPSHEETHEADER* sheetInfo = reinterpret_cast<PROPSHEETHEADER*>(lParam);
1315 if (sheetInfo->nPages >= folderOptionsPageCountMax)
1316 return FALSE;
1317 sheetInfo->phpage[sheetInfo->nPages] = thePage;
1318 sheetInfo->nPages++;
1319 return TRUE;
1320}
1321
1323{
1324 CComPtr<IShellPropSheetExt> folderOptionsSheet;
1325 PROPSHEETHEADER m_PropSheet;
1327// CComPtr<IGlobalFolderSettings> globalSettings;
1328// SHELLSTATE2 shellState;
1329 HRESULT hResult;
1330
1331 memset(m_psp, 0, sizeof(m_psp));
1332 memset(&m_PropSheet, 0, sizeof(m_PropSheet));
1333
1334 // create sheet object
1335 hResult = CoCreateInstance(CLSID_ShellFldSetExt, NULL, CLSCTX_INPROC_SERVER,
1336 IID_PPV_ARG(IShellPropSheetExt, &folderOptionsSheet));
1337 if (FAILED_UNEXPECTEDLY(hResult))
1338 return E_FAIL;
1339
1340 // must set site in order for Apply to all Folders on Advanced page to be enabled
1341 hResult = IUnknown_SetSite(folderOptionsSheet, static_cast<IDispatch *>(this));
1342 m_PropSheet.phpage = m_psp;
1343
1344#if 0
1345 hResult = CoCreateInstance(CLSID_GlobalFolderSettings, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IGlobalFolderSettings, &globalSettings));
1346 if (FAILED_UNEXPECTEDLY(hResult))
1347 return E_FAIL;
1348 hResult = globalSettings->Get(&shellState, sizeof(shellState));
1349 if (FAILED_UNEXPECTEDLY(hResult))
1350 return E_FAIL;
1351#endif
1352
1353 // add pages
1354 hResult = folderOptionsSheet->AddPages(AddFolderOptionsPage, reinterpret_cast<LPARAM>(&m_PropSheet));
1355 if (FAILED_UNEXPECTEDLY(hResult))
1356 return E_FAIL;
1357
1358// CORE-11140 : Disabled this bit, because it prevents the folder options from showing.
1359// It returns 'E_NOTIMPL'
1360#if 0
1361 if (fCurrentShellView != NULL)
1362 {
1363 hResult = fCurrentShellView->AddPropertySheetPages(
1364 0, AddFolderOptionsPage, reinterpret_cast<LPARAM>(&m_PropSheet));
1365 if (FAILED_UNEXPECTEDLY(hResult))
1366 return E_FAIL;
1367 }
1368#endif
1369
1370 // show sheet
1371 CStringW strFolderOptions(MAKEINTRESOURCEW(IDS_FOLDER_OPTIONS));
1372 m_PropSheet.dwSize = sizeof(PROPSHEETHEADER);
1373 m_PropSheet.dwFlags = 0;
1374 m_PropSheet.hwndParent = m_hWnd;
1375 m_PropSheet.hInstance = _AtlBaseModule.GetResourceInstance();
1376 m_PropSheet.pszCaption = strFolderOptions;
1377 m_PropSheet.nStartPage = 0;
1378 PropertySheet(&m_PropSheet);
1379 return S_OK;
1380}
1381
1383{
1384 CShellBrowser *pThis = reinterpret_cast<CShellBrowser *>(hWnd);
1385 _ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
1386 LRESULT lResult;
1387 const _ATL_MSG *previousMessage;
1388 BOOL handled;
1389 WNDPROC saveWindowProc;
1390 HRESULT hResult;
1391
1392 hWnd = pThis->m_hWnd;
1393 previousMessage = pThis->m_pCurrentMsg;
1394 pThis->m_pCurrentMsg = &msg;
1395
1396 /* If the shell browser is initialized, let the menu band preprocess the messages */
1397 if (pThis->fCurrentDirectoryPIDL)
1398 {
1399 CComPtr<IMenuBand> menuBand;
1400 hResult = pThis->GetMenuBand(IID_PPV_ARG(IMenuBand, &menuBand));
1401 if (SUCCEEDED(hResult) && menuBand.p != NULL)
1402 {
1403 hResult = menuBand->TranslateMenuMessage(&msg, &lResult);
1404 if (hResult == S_OK)
1405 return lResult;
1406 uMsg = msg.message;
1407 wParam = msg.wParam;
1408 lParam = msg.lParam;
1409 }
1410 menuBand.Release();
1411 }
1412
1413 handled = pThis->ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, 0);
1414 ATLASSERT(pThis->m_pCurrentMsg == &msg);
1415 if (handled == FALSE)
1416 {
1417 if (uMsg == WM_NCDESTROY)
1418 {
1419 saveWindowProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hWnd, GWLP_WNDPROC));
1420 lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1421 if (saveWindowProc == reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hWnd, GWLP_WNDPROC)))
1423 pThis->m_dwState |= WINSTATE_DESTROYED;
1424 }
1425 else
1426 lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1427 }
1428 pThis->m_pCurrentMsg = previousMessage;
1429 if (previousMessage == NULL && (pThis->m_dwState & WINSTATE_DESTROYED) != 0)
1430 {
1431 pThis->m_dwState &= ~WINSTATE_DESTROYED;
1432 pThis->m_hWnd = NULL;
1433 pThis->OnFinalMessage(hWnd);
1434 }
1435 return lResult;
1436}
1437
1439{
1440 RECT clientRect;
1441 RECT statusRect;
1442 int x;
1443
1444 GetClientRect(&clientRect);
1445
1447 {
1448 ::GetWindowRect(fStatusBar, &statusRect);
1449 ::SetWindowPos(fStatusBar, NULL, clientRect.left, clientRect.bottom - (statusRect.bottom - statusRect.top),
1450 clientRect.right - clientRect.left,
1451 statusRect.bottom - statusRect.top, SWP_NOOWNERZORDER | SWP_NOZORDER);
1452 clientRect.bottom -= statusRect.bottom - statusRect.top;
1453 }
1454
1455 for (x = 0; x < 3; x++)
1456 {
1458 RECT borderSpace = fClientBars[x].borderSpace;
1459 if (hwnd == NULL && fClientBars[x].clientBar != NULL)
1460 {
1461 IUnknown_GetWindow(fClientBars[x].clientBar, &hwnd);
1463 }
1464 if (hwnd != NULL)
1465 {
1466 RECT toolbarRect = clientRect;
1467 if (borderSpace.top != 0)
1468 {
1469 toolbarRect.bottom = toolbarRect.top + borderSpace.top;
1470 }
1471 else if (borderSpace.bottom != 0)
1472 {
1473 toolbarRect.top = toolbarRect.bottom - borderSpace.bottom;
1474 }
1475 else if (borderSpace.left != 0)
1476 {
1477 toolbarRect.right = toolbarRect.left + borderSpace.left;
1478 }
1479 else if (borderSpace.right != 0)
1480 {
1481 toolbarRect.left = toolbarRect.right - borderSpace.right;
1482 }
1483
1485 toolbarRect.left,
1486 toolbarRect.top,
1487 toolbarRect.right - toolbarRect.left,
1488 toolbarRect.bottom - toolbarRect.top,
1490
1491 if (borderSpace.top != 0)
1492 {
1493 clientRect.top = toolbarRect.bottom;
1494 }
1495 else if (borderSpace.bottom != 0)
1496 {
1497 clientRect.bottom = toolbarRect.top;
1498 }
1499 else if (borderSpace.left != 0)
1500 {
1501 clientRect.left = toolbarRect.right;
1502 }
1503 else if (borderSpace.right != 0)
1504 {
1505 clientRect.right = toolbarRect.left;
1506 }
1507 }
1508 }
1509 ::SetWindowPos(fCurrentShellViewWindow, NULL, clientRect.left, clientRect.top,
1510 clientRect.right - clientRect.left,
1511 clientRect.bottom - clientRect.top, SWP_NOOWNERZORDER | SWP_NOZORDER);
1512}
1513
1514HRESULT CShellBrowser::FireEvent(DISPID dispIdMember, int argCount, VARIANT *arguments)
1515{
1516 DISPPARAMS params;
1519 HRESULT hResult;
1520
1521 params.rgvarg = arguments;
1522 params.rgdispidNamedArgs = NULL;
1523 params.cArgs = argCount;
1524 params.cNamedArgs = 0;
1525 IUnknown** pp = vec.begin();
1526 while (pp < vec.end())
1527 {
1528 if (*pp != NULL)
1529 {
1530 CComPtr<IDispatch> theDispatch;
1531
1532 hResult = (*pp)->QueryInterface(IID_PPV_ARG(IDispatch, &theDispatch));
1533 hResult = theDispatch->Invoke(dispIdMember, GUID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, NULL);
1534 }
1535 pp++;
1536 }
1537 pp = vec2.begin();
1538 while (pp < vec2.end())
1539 {
1540 if (*pp != NULL)
1541 {
1542 CComPtr<IDispatch> theDispatch;
1543
1544 hResult = (*pp)->QueryInterface(IID_PPV_ARG(IDispatch, &theDispatch));
1545 hResult = theDispatch->Invoke(dispIdMember, GUID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, NULL);
1546 }
1547 pp++;
1548 }
1549 return S_OK;
1550}
1551
1553{
1554 // these two variants intentionally to do use CComVariant because it would double free/release
1555 // or does not need to dispose at all
1556 VARIANT varArg[2];
1557 VARIANT varArgs;
1558 CComBSTR tempString(newDirectory);
1559
1560 V_VT(&varArgs) = VT_BSTR;
1561 V_BSTR(&varArgs) = tempString.m_str;
1562
1563 V_VT(&varArg[0]) = VT_VARIANT | VT_BYREF;
1564 V_VARIANTREF(&varArg[0]) = &varArgs;
1565 V_VT(&varArg[1]) = VT_DISPATCH;
1566 V_DISPATCH(&varArg[1]) = (IDispatch *)this;
1567
1568 return FireEvent(DISPID_NAVIGATECOMPLETE2, 2, varArg);
1569}
1570
1572{
1573 VARIANT varArg[2];
1574
1575 V_VT(&varArg[0]) = VT_BOOL;
1576 V_BOOL(&varArg[0]) = newState ? VARIANT_TRUE : VARIANT_FALSE;
1577 V_VT(&varArg[1]) = VT_I4;
1578 V_I4(&varArg[1]) = commandID;
1579
1580 return FireEvent(DISPID_COMMANDSTATECHANGE, 2, varArg);
1581}
1582
1584{
1585 return FireCommandStateChange(false, -1);
1586}
1587
1589{
1590 CComPtr<ITravelLog> travelLog;
1591 CComPtr<ITravelEntry> unusedEntry;
1592 bool canGoBack;
1593 bool canGoForward;
1594 HRESULT hResult;
1595
1596 canGoBack = false;
1597 canGoForward = false;
1598 hResult = GetTravelLog(&travelLog);
1599 if (FAILED_UNEXPECTEDLY(hResult))
1600 return hResult;
1601 hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this), TLOG_BACK, &unusedEntry);
1602 if (SUCCEEDED(hResult))
1603 {
1604 canGoBack = true;
1605 unusedEntry.Release();
1606 }
1607 hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this), TLOG_FORE, &unusedEntry);
1608 if (SUCCEEDED(hResult))
1609 {
1610 canGoForward = true;
1611 unusedEntry.Release();
1612 }
1613 hResult = FireCommandStateChange(canGoBack, 2);
1614 hResult = FireCommandStateChange(canGoForward, 1);
1615 return S_OK;
1616}
1617
1619{
1620 bool canGoUp;
1621 HRESULT hResult;
1622
1623 canGoUp = true;
1625 canGoUp = false;
1626 hResult = FireCommandStateChange(canGoUp, 3);
1627 return S_OK;
1628}
1629
1631{
1632 CComPtr<ITravelLog> travelLog;
1633 CComPtr<ITravelEntry> unusedEntry;
1634 int position;
1635 MENUITEMINFO menuItemInfo;
1636 HRESULT hResult;
1637
1639
1640 position = GetMenuItemCount(theMenu);
1641 hResult = GetTravelLog(&travelLog);
1642 if (FAILED_UNEXPECTEDLY(hResult))
1643 return;
1644
1645 hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this),
1646 TLOG_BACK,
1647 &unusedEntry);
1648
1649 if (SUCCEEDED(hResult))
1650 {
1652 unusedEntry.Release();
1653 }
1654 else
1656
1657 hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this),
1658 TLOG_FORE,
1659 &unusedEntry);
1660
1661 if (SUCCEEDED(hResult))
1662 {
1664 unusedEntry.Release();
1665 }
1666 else
1668
1669 SHEnableMenuItem(theMenu,
1672
1673 hResult = travelLog->InsertMenuEntries(static_cast<IDropTarget *>(this), theMenu, position,
1675 if (SUCCEEDED(hResult))
1676 {
1677 menuItemInfo.cbSize = sizeof(menuItemInfo);
1678 menuItemInfo.fMask = MIIM_TYPE | MIIM_ID;
1679 menuItemInfo.fType = MF_SEPARATOR;
1680 menuItemInfo.wID = IDM_GOTO_TRAVEL_SEP;
1681 InsertMenuItem(theMenu, position, TRUE, &menuItemInfo);
1682 }
1683}
1684
1686{
1687 CComPtr<ITravelLog> travelLog;
1688 HMENU gotoMenu;
1689 OLECMD commandList[5];
1690 HMENU toolbarMenuBar;
1691 HMENU toolbarMenu;
1692 MENUITEMINFO menuItemInfo;
1693 HRESULT hResult;
1694
1695 gotoMenu = SHGetMenuFromID(theMenu, FCIDM_MENU_EXPLORE);
1696 if (gotoMenu != NULL)
1697 UpdateGotoMenu(gotoMenu);
1698
1699 commandList[0].cmdID = ITID_TOOLBARBANDSHOWN;
1700 commandList[1].cmdID = ITID_ADDRESSBANDSHOWN;
1701 commandList[2].cmdID = ITID_LINKSBANDSHOWN;
1702 commandList[3].cmdID = ITID_TOOLBARLOCKED;
1703 commandList[4].cmdID = ITID_CUSTOMIZEENABLED;
1704
1706 CGID_PrivCITCommands, 5, commandList, NULL);
1707 if (FAILED_UNEXPECTEDLY(hResult))
1709 else
1710 {
1711 menuItemInfo.cbSize = sizeof(menuItemInfo);
1712 menuItemInfo.fMask = MIIM_SUBMENU;
1713 GetMenuItemInfo(theMenu, IDM_VIEW_TOOLBARS, FALSE, &menuItemInfo);
1714 DestroyMenu(menuItemInfo.hSubMenu);
1715
1716 toolbarMenuBar = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_CONTEXTMENU));
1717 toolbarMenu = GetSubMenu(toolbarMenuBar, 0);
1718 RemoveMenu(toolbarMenuBar, 0, MF_BYPOSITION);
1719 DestroyMenu(toolbarMenuBar);
1720
1721 // TODO: Implement
1722 SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_STANDARDBUTTONS, commandList[0].cmdf & OLECMDF_ENABLED);
1723 SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_ADDRESSBAR, commandList[1].cmdf & OLECMDF_ENABLED);
1724 SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_LINKSBAR, commandList[2].cmdf & OLECMDF_ENABLED);
1725 SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_CUSTOMIZE, commandList[4].cmdf & OLECMDF_ENABLED);
1726
1727 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_STANDARDBUTTONS, commandList[0].cmdf & OLECMDF_LATCHED);
1728 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_ADDRESSBAR, commandList[1].cmdf & OLECMDF_LATCHED);
1729 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_LINKSBAR, commandList[2].cmdf & OLECMDF_LATCHED);
1730 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_LOCKTOOLBARS, commandList[3].cmdf & OLECMDF_LATCHED);
1731 if ((commandList[4].cmdf & OLECMDF_ENABLED) == 0)
1735
1736 menuItemInfo.cbSize = sizeof(menuItemInfo);
1737 menuItemInfo.fMask = MIIM_SUBMENU;
1738 menuItemInfo.hSubMenu = toolbarMenu;
1739 SetMenuItemInfo(theMenu, IDM_VIEW_TOOLBARS, FALSE, &menuItemInfo);
1740 }
1742}
1743
1745{
1746 HMENU hBandsMenu;
1747 UINT nbFound;
1748
1750 if (!hBandsMenu)
1751 {
1752 OutputDebugString(L"No menu !\n");
1753 return E_FAIL;
1754 }
1756 BuildExplorerBandCategory(hBandsMenu, CATID_InfoBand, 4, NULL);
1757 BuildExplorerBandCategory(hBandsMenu, CATID_CommBand, 20, &nbFound);
1758 if (!nbFound)
1759 {
1760 // Remove separator
1762 }
1763 // Remove media menu since XP does it (according to API Monitor)
1765 return S_OK;
1766}
1767
1769{
1770 HRESULT hr;
1771 CComPtr<IEnumGUID> pEnumGUID;
1772 WCHAR wszBandName[MAX_PATH];
1773 WCHAR wszBandGUID[MAX_PATH];
1774 WCHAR wRegKey[MAX_PATH];
1775 UINT cBands;
1776 DWORD dwRead;
1777 DWORD dwDataSize;
1778 GUID iter;
1779 MenuBandInfo mbi;
1780
1781 mbi.fVertical = IsEqualGUID(category, CATID_InfoBand);
1782 cBands = 0;
1783 hr = SHEnumClassesOfCategories(1, &category, 0, NULL, &pEnumGUID);
1785 {
1786 return hr;
1787 }
1788 do
1789 {
1790 pEnumGUID->Next(1, &iter, &dwRead);
1791 if (dwRead)
1792 {
1793 // Get the band name
1794 if (IsBuiltinBand(iter))
1795 continue;
1796 if (!StringFromGUID2(iter, wszBandGUID, MAX_PATH))
1797 continue;
1798 StringCchPrintfW(wRegKey, MAX_PATH, L"CLSID\\%s", wszBandGUID);
1799 dwDataSize = MAX_PATH;
1800 SHGetValue(HKEY_CLASSES_ROOT, wRegKey, NULL, NULL, wszBandName, &dwDataSize);
1801
1802 mbi.barGuid = iter;
1803 InsertMenu(hBandsMenu, dwPos + cBands, MF_BYPOSITION, IDM_EXPLORERBAND_BEGINCUSTOM + DSA_GetItemCount(menuDsa), wszBandName);
1804 DSA_AppendItem(menuDsa, &mbi);
1805 cBands++;
1806 }
1807 }
1808 while (dwRead > 0);
1809 if (nbFound)
1810 *nbFound = cBands;
1811 return S_OK;
1812}
1813
1815{
1816 if (IsEqualCLSID(bandID, CLSID_ExplorerBand))
1817 return TRUE;
1818 if (IsEqualCLSID(bandID, CLSID_SH_SearchBand) || IsEqualCLSID(bandID, CLSID_SearchBand))
1819 return TRUE;
1820 if (IsEqualCLSID(bandID, CLSID_IE_SearchBand) || IsEqualCLSID(bandID, CLSID_FileSearchBand))
1821 return TRUE;
1822 if (IsEqualCLSID(bandID, CLSID_SH_HistBand))
1823 return TRUE;
1824 if (IsEqualCLSID(bandID, CLSID_SH_FavBand))
1825 return TRUE;
1826 if (IsEqualCLSID(bandID, CLSID_ChannelsBand))
1827 return TRUE;
1828 return FALSE;
1829}
1830
1832{
1833 CComPtr<IObjectWithSite> objectWithSite;
1834 CComPtr<IContextMenu> contextMenu;
1835 CMINVOKECOMMANDINFO commandInfo;
1836 const char *searchGUID = "{169A0691-8DF9-11d1-A1C4-00C04FD75D13}";
1837 HRESULT hResult;
1838
1839 // TODO: Query shell if this command is enabled first
1840
1841 memset(&commandInfo, 0, sizeof(commandInfo));
1842 commandInfo.cbSize = sizeof(commandInfo);
1843 commandInfo.hwnd = m_hWnd;
1844 commandInfo.lpParameters = searchGUID;
1845 commandInfo.nShow = SW_SHOWNORMAL;
1846
1847 hResult = CoCreateInstance(CLSID_ShellSearchExt, NULL, CLSCTX_INPROC_SERVER,
1848 IID_PPV_ARG(IContextMenu, &contextMenu));
1849 if (FAILED_UNEXPECTEDLY(hResult))
1850 return 0;
1851 hResult = contextMenu->QueryInterface(IID_PPV_ARG(IObjectWithSite, &objectWithSite));
1852 if (FAILED_UNEXPECTEDLY(hResult))
1853 return 0;
1854 hResult = objectWithSite->SetSite(dynamic_cast<IShellBrowser*>(this));
1855 if (FAILED_UNEXPECTEDLY(hResult))
1856 return 0;
1857 hResult = contextMenu->InvokeCommand(&commandInfo);
1858 hResult = objectWithSite->SetSite(NULL);
1859 return hResult;
1860}
1861
1863{
1864 CComPtr<IUnknown> int1Retry;
1865 CComPtr<IUnknown> int2Retry;
1866 HRESULT hResult;
1867
1868 if (int1 == int2)
1869 return true;
1870 if (int1 == NULL || int2 == NULL)
1871 return false;
1872 hResult = int1->QueryInterface(IID_PPV_ARG(IUnknown, &int1Retry));
1873 if (FAILED_UNEXPECTEDLY(hResult))
1874 return false;
1875 hResult = int2->QueryInterface(IID_PPV_ARG(IUnknown, &int2Retry));
1876 if (FAILED_UNEXPECTEDLY(hResult))
1877 return false;
1878 if (int1Retry == int2Retry)
1879 return true;
1880 return false;
1881}
1882
1884{
1885 static const INT excludeItems[] = { 1, 1, 1, IDC_STATUSBAR, 0, 0 };
1886
1887 RECT availableBounds;
1888
1889 GetEffectiveClientRect(m_hWnd, &availableBounds, excludeItems);
1890 for (INT x = 0; x < 3; x++)
1891 {
1892 if (fClientBars[x].clientBar.p != NULL && !IUnknownIsEqual(fClientBars[x].clientBar, punkObj))
1893 {
1894 availableBounds.top += fClientBars[x].borderSpace.top;
1895 availableBounds.left += fClientBars[x].borderSpace.left;
1896 availableBounds.bottom -= fClientBars[x].borderSpace.bottom;
1897 availableBounds.right -= fClientBars[x].borderSpace.right;
1898 }
1899 }
1900 *prcBorder = availableBounds;
1901 return S_OK;
1902}
1903
1905{
1906 return S_OK;
1907}
1908
1910{
1911 for (INT x = 0; x < 3; x++)
1912 {
1913 if (IUnknownIsEqual(fClientBars[x].clientBar, punkObj))
1914 {
1915 fClientBars[x].borderSpace = *pbw;
1916 // if this bar changed size, it cascades and forces all subsequent bars to resize
1918 return S_OK;
1919 }
1920 }
1921 return E_INVALIDARG;
1922}
1923
1925 ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT *pCmdText)
1926{
1927 CComPtr<IOleCommandTarget> commandTarget;
1928 HRESULT hResult;
1929
1930 if (prgCmds == NULL)
1931 return E_INVALIDARG;
1932 if (pguidCmdGroup == NULL)
1933 {
1934 if (fCurrentShellView.p != NULL)
1935 {
1936 hResult = fCurrentShellView->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &commandTarget));
1937 if (SUCCEEDED(hResult) && commandTarget.p != NULL)
1938 return commandTarget->QueryStatus(NULL, 1, prgCmds, pCmdText);
1939 }
1940 while (cCmds != 0)
1941 {
1942 prgCmds->cmdf = 0;
1943 prgCmds++;
1944 cCmds--;
1945 }
1946 }
1947 else if (IsEqualIID(*pguidCmdGroup, CGID_Explorer))
1948 {
1949 while (cCmds != 0)
1950 {
1951 switch (prgCmds->cmdID)
1952 {
1953 case 0x1c: // search
1955 if (IsEqualCLSID(CLSID_SH_SearchBand, fCurrentVertBar) ||
1956 IsEqualCLSID(CLSID_SearchBand, fCurrentVertBar) ||
1957 IsEqualCLSID(CLSID_IE_SearchBand, fCurrentVertBar) ||
1958 IsEqualCLSID(CLSID_FileSearchBand, fCurrentVertBar))
1959 {
1960 prgCmds->cmdf |= OLECMDF_LATCHED;
1961 }
1962 break;
1963 case 0x1d: // history
1965 if (IsEqualCLSID(CLSID_SH_HistBand, fCurrentVertBar))
1966 prgCmds->cmdf |= OLECMDF_LATCHED;
1967 break;
1968 case 0x1e: // favorites
1970 if (IsEqualCLSID(CLSID_SH_FavBand, fCurrentVertBar))
1971 prgCmds->cmdf |= OLECMDF_LATCHED;
1972 break;
1973 case 0x23: // folders
1975 if (IsEqualCLSID(CLSID_ExplorerBand, fCurrentVertBar))
1976 prgCmds->cmdf |= OLECMDF_LATCHED;
1977 break;
1978 default:
1979 prgCmds->cmdf = 0;
1980 break;
1981 }
1982 prgCmds++;
1983 cCmds--;
1984 }
1985 }
1986 else if (IsEqualIID(*pguidCmdGroup, CGID_ShellBrowser))
1987 {
1988 while (cCmds != 0)
1989 {
1990 switch (prgCmds->cmdID)
1991 {
1993 prgCmds->cmdf = OLECMDF_SUPPORTED;
1994 if (fCurrentDirectoryPIDL->mkid.cb != 0)
1995 prgCmds->cmdf |= OLECMDF_ENABLED;
1996 break;
1997 }
1998 prgCmds++;
1999 cCmds--;
2000 }
2001 }
2002 return S_OK;
2003}
2004
2006 DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2007{
2008 HRESULT hResult;
2009
2010 if (!pguidCmdGroup)
2011 {
2012 TRACE("Unhandled null CGID %d %d %p %p\n", nCmdID, nCmdexecopt, pvaIn, pvaOut);
2013 return E_NOTIMPL;
2014 }
2015 if (IsEqualIID(*pguidCmdGroup, CGID_Explorer))
2016 {
2017 switch (nCmdID)
2018 {
2019 case 0x1c: //Toggle Search
2020 case 0x1d: //Toggle History
2021 case 0x1e: //Toggle Favorites
2022 case 0x23: //Toggle Folders
2023 const GUID* pclsid;
2024 if (nCmdID == 0x1c) pclsid = &CLSID_FileSearchBand;
2025 else if (nCmdID == 0x1d) pclsid = &CLSID_SH_HistBand;
2026 else if (nCmdID == 0x1e) pclsid = &CLSID_SH_FavBand;
2027 else pclsid = &CLSID_ExplorerBand;
2028
2029 if (IsEqualCLSID(*pclsid, fCurrentVertBar))
2030 {
2031 hResult = IUnknown_ShowDW(fClientBars[BIVerticalBaseBar].clientBar.p, FALSE);
2034 }
2035 else
2036 {
2037 hResult = ShowBand(*pclsid, true);
2038 }
2039 return S_OK;
2040 case 0x22:
2041 //Sent when a band closes
2042 if (V_VT(pvaIn) != VT_UNKNOWN)
2043 return E_INVALIDARG;
2044
2045 if (IUnknownIsEqual(V_UNKNOWN(pvaIn), fClientBars[BIVerticalBaseBar].clientBar.p))
2046 {
2049 }
2050 return S_OK;
2051 case 0x27:
2052 if (nCmdexecopt == 1)
2053 {
2054 // pvaIn is a VT_UNKNOWN with a band that is being hidden
2055 }
2056 else
2057 {
2058 // update zones part of the status bar
2059 }
2060 return S_OK;
2061 case 0x35: // don't do this, and the internet toolbar doesn't create a menu band
2062 V_VT(pvaOut) = VT_INT_PTR;
2063 V_INTREF(pvaOut) = reinterpret_cast<INT *>(
2064 LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU)));
2065 return S_OK;
2066 case 0x38:
2067 // indicate if this cabinet was opened as a browser
2068 return S_FALSE;
2069 default:
2070 return E_NOTIMPL;
2071 }
2072 }
2073 else if (IsEqualIID(*pguidCmdGroup, CGID_InternetButtons))
2074 {
2075 switch (nCmdID)
2076 {
2077 case 0x23:
2078 // placeholder
2079 return S_OK;
2080 }
2081 }
2082 else if (IsEqualIID(*pguidCmdGroup, CGID_Theater))
2083 {
2084 switch (nCmdID)
2085 {
2086 case 6:
2087 // what is theater mode and why do we receive this?
2088 return E_NOTIMPL;
2089 }
2090 }
2091 else if (IsEqualIID(*pguidCmdGroup, CGID_MenuBand))
2092 {
2093 switch (nCmdID)
2094 {
2095 case 14:
2096 // initialize favorites menu
2097 return S_OK;
2098 }
2099 }
2100 else if (IsEqualIID(*pguidCmdGroup, CGID_ShellDocView))
2101 {
2102 switch (nCmdID)
2103 {
2104 case 0x12:
2105 // refresh on toolbar clicked
2106 return S_OK;
2107 case 0x26:
2108 // called for unknown bands ?
2109 return S_OK;
2110 case 0x4d:
2111 // tell the view if it should hide the task pane or not
2112 return (fClientBars[BIVerticalBaseBar].clientBar.p == NULL) ? S_FALSE : S_OK;
2113 }
2114 }
2115 else if (IsEqualIID(*pguidCmdGroup, CGID_ShellBrowser))
2116 {
2117 switch (nCmdID)
2118 {
2119 case 40994:
2120 return NavigateToParent();
2121 }
2122 }
2123 else if (IsEqualIID(*pguidCmdGroup, CGID_IExplorerToolbar))
2124 {
2125 switch (nCmdID)
2126 {
2127 case 0x7063:
2128 return DoFolderOptions();
2129 }
2130 }
2131 else if (IsEqualIID(*pguidCmdGroup, CGID_DefView))
2132 {
2133 switch (nCmdID)
2134 {
2135 case 1:
2136 // Reset All Folders option in Folder Options
2137 break;
2138 }
2139 }
2140 else
2141 {
2142 return E_NOTIMPL;
2143 }
2144 return E_NOTIMPL;
2145}
2146
2148{
2149 if (lphwnd == NULL)
2150 return E_POINTER;
2151 *lphwnd = m_hWnd;
2152 return S_OK;
2153}
2154
2156{
2157 return E_NOTIMPL;
2158}
2159
2160HRESULT STDMETHODCALLTYPE CShellBrowser::InsertMenusSB(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
2161{
2162 HMENU mainMenu = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU));
2163
2164 Shell_MergeMenus(hmenuShared, mainMenu, 0, 0, FCIDM_BROWSERLAST, MM_SUBMENUSHAVEIDS);
2165
2166 int GCCU(itemCount3) = GetMenuItemCount(hmenuShared);
2167 Unused(itemCount3);
2168
2169 DestroyMenu(mainMenu);
2170
2171 lpMenuWidths->width[0] = 2;
2172 lpMenuWidths->width[2] = 3;
2173 lpMenuWidths->width[4] = 1;
2174 return S_OK;
2175}
2176
2177HRESULT STDMETHODCALLTYPE CShellBrowser::SetMenuSB(HMENU hmenuShared, HOLEMENU holemenuRes, HWND hwndActiveObject)
2178{
2179 CComPtr<IShellMenu> shellMenu;
2180 HRESULT hResult;
2181
2182 if (hmenuShared && IsMenu(hmenuShared) == FALSE)
2183 return E_FAIL;
2184 hResult = GetMenuBand(IID_PPV_ARG(IShellMenu, &shellMenu));
2185 if (FAILED_UNEXPECTEDLY(hResult))
2186 return hResult;
2187
2188 if (!hmenuShared)
2189 {
2190 hmenuShared = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU));
2191 }
2192 // FIXME: Figure out the proper way to do this.
2193 HMENU hMenuFavs = GetSubMenu(hmenuShared, 3);
2194 if (hMenuFavs)
2195 {
2197 }
2198
2199 hResult = shellMenu->SetMenu(hmenuShared, m_hWnd, SMSET_DONTOWN);
2200 if (FAILED_UNEXPECTEDLY(hResult))
2201 return hResult;
2202 fCurrentMenuBar = hmenuShared;
2204 return S_OK;
2205}
2206
2208{
2209 if (hmenuShared == fCurrentMenuBar)
2210 {
2211 //DestroyMenu(fCurrentMenuBar);
2213 }
2214 return S_OK;
2215}
2216
2218{
2219 //
2220 if (pszStatusText)
2221 {
2222 ::SetWindowText(fStatusBar, pszStatusText);
2223 }
2224 else
2225 {
2226
2227 }
2228 return S_OK;
2229}
2230
2232{
2233 return E_NOTIMPL;
2234}
2235
2237{
2239 return S_FALSE;
2240 return S_OK;
2241}
2242
2244{
2245 if ((wFlags & SBSP_EXPLOREMODE) != NULL)
2246 ShowBand(CLSID_ExplorerBand, true);
2247
2249 if (fTravelLog)
2251 return BrowseToPIDL(pidl, flags);
2252}
2253
2255{
2256 return E_NOTIMPL;
2257}
2258
2260{
2261 if (lphwnd == NULL)
2262 return E_POINTER;
2263 *lphwnd = NULL;
2264 switch (id)
2265 {
2266 case FCW_TOOLBAR:
2267 *lphwnd = fToolbarProxy.m_hWnd;
2268 return S_OK;
2269 case FCW_STATUS:
2270 *lphwnd = fStatusBar;
2271 return S_OK;
2272 case FCW_TREE:
2273 // find the directory browser and return it
2274 // this should be used only to determine if a tree is present
2275 return S_OK;
2276 case FCW_PROGRESS:
2277 // is this a progress dialog?
2278 return S_OK;
2279 }
2280 return S_OK;
2281}
2282
2284 UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pret)
2285{
2286 LPARAM result;
2287
2288 if (pret != NULL)
2289 *pret = 0;
2290 switch (id)
2291 {
2292 case FCW_TOOLBAR:
2294 if (pret != NULL)
2295 *pret = result;
2296 break;
2297 case FCW_STATUS:
2299 if (pret != NULL)
2300 *pret = result;
2301 break;
2302 }
2303 return S_OK;
2304}
2305
2307{
2308 if (ppshv == NULL)
2309 return E_POINTER;
2310 *ppshv = fCurrentShellView;
2311 if (fCurrentShellView.p != NULL)
2313 return S_OK;
2314}
2315
2317{
2318 return E_NOTIMPL;
2319}
2320
2322{
2323 return E_NOTIMPL;
2324}
2325
2327 IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2328{
2329 return E_NOTIMPL;
2330}
2331
2333{
2334 return E_NOTIMPL;
2335}
2336
2338{
2339 return E_NOTIMPL;
2340}
2341
2343 IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2344{
2345 return E_NOTIMPL;
2346}
2347
2349{
2350 // view does a query for SID_STopLevelBrowser, IID_IShellBrowserService
2351 // the returned interface has a method GetPropertyBag on it
2352 if (IsEqualIID(guidService, SID_STopLevelBrowser))
2353 return this->QueryInterface(riid, ppvObject);
2354 if (IsEqualIID(guidService, SID_SShellBrowser))
2355 return this->QueryInterface(riid, ppvObject);
2356 if (IsEqualIID(guidService, SID_ITargetFrame2))
2357 return this->QueryInterface(riid, ppvObject);
2358 if (IsEqualIID(guidService, SID_IWebBrowserApp)) // without this, the internet toolbar won't reflect notifications
2359 return this->QueryInterface(riid, ppvObject);
2360 if (IsEqualIID(guidService, SID_SProxyBrowser))
2361 return this->QueryInterface(riid, ppvObject);
2362 if (IsEqualIID(guidService, SID_IExplorerToolbar))
2363 return fClientBars[BIInternetToolbar].clientBar->QueryInterface(riid, ppvObject);
2364 if (IsEqualIID(riid, IID_IShellBrowser))
2365 return this->QueryInterface(riid, ppvObject);
2366 return E_NOINTERFACE;
2367}
2368
2370{
2373}
2374
2376{
2377 if (ppvObject == NULL)
2378 return E_POINTER;
2379
2380 *ppvObject = NULL;
2381
2382 LPITEMIDLIST pidl;
2383 HRESULT hr = GetPidl(&pidl);
2385 return E_FAIL;
2386
2387 // FIXME: pidl for Internet etc.
2388
2389 if (_ILIsNetworkPlace(pidl))
2390 flags |= SHGVSPB_ROAM;
2391
2392 hr = SHGetViewStatePropertyBag(pidl, L"Shell", flags, riid, ppvObject);
2393
2394 ILFree(pidl);
2395 return hr;
2396}
2397
2399{
2400 return E_NOTIMPL;
2401}
2402
2404{
2405 return E_NOTIMPL;
2406}
2407
2409 UINT cNames, LCID lcid, DISPID *rgDispId)
2410{
2411 return E_NOTIMPL;
2412}
2413
2415 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2416{
2417 return E_NOTIMPL;
2418}
2419
2421{
2422 return E_NOTIMPL;
2423}
2424
2426{
2427 return E_NOTIMPL;
2428}
2429
2431{
2432 return E_NOTIMPL;
2433}
2434
2436{
2437 return E_NOTIMPL;
2438}
2439
2441{
2442 HRESULT hResult;
2443
2444 // called by toolbar when displaying tooltips
2445 if (pptl == NULL)
2446 return E_FAIL;
2447
2448 *pptl = NULL;
2449 if (fTravelLog.p == NULL)
2450 {
2452 if (FAILED_UNEXPECTEDLY(hResult))
2453 return hResult;
2454 }
2455 *pptl = fTravelLog.p;
2456 fTravelLog.p->AddRef();
2457 return S_OK;
2458}
2459
2461{
2462 return E_NOTIMPL;
2463}
2464
2466{
2467 return E_NOTIMPL;
2468}
2469
2471{
2472 return E_NOTIMPL;
2473}
2474
2476{
2477 return E_NOTIMPL;
2478}
2479
2481{
2482 return E_NOTIMPL;
2483}
2484
2486{
2487 return E_NOTIMPL;
2488}
2489
2491{
2492 return E_NOTIMPL;
2493}
2494
2496{
2497 return E_NOTIMPL;
2498}
2499
2501{
2502 return E_NOTIMPL;
2503}
2504
2506{
2507 return E_NOTIMPL;
2508}
2509
2511{
2512 return E_NOTIMPL;
2513}
2514
2516{
2517 return E_NOTIMPL;
2518}
2519
2521{
2522 return E_NOTIMPL;
2523}
2524
2526{
2527 return E_NOTIMPL;
2528}
2529
2531{
2532 // called by explorer bar to get current pidl
2533 if (ppidl == NULL)
2534 return E_POINTER;
2536 return S_OK;
2537}
2538
2540{
2541 return E_NOTIMPL;
2542}
2543
2545{
2546 return -1;
2547}
2548
2550{
2551 return E_NOTIMPL;
2552}
2553
2555{
2556 if (ppole == NULL || pstm == NULL || ppbc == NULL)
2557 return E_INVALIDARG;
2558 *ppole = fHistoryObject;
2559 if (fHistoryObject != NULL)
2561 *pstm = fHistoryStream;
2562 if (fHistoryStream != NULL)
2564 *ppbc = fHistoryBindContext;
2570 if (*ppole == NULL)
2571 return E_FAIL;
2572 return S_OK;
2573}
2574
2576{
2577 return E_NOTIMPL;
2578}
2579
2581{
2582 return E_NOTIMPL;
2583}
2584
2586{
2587 return E_NOTIMPL;
2588}
2589
2591 IShellView *psv, BOOL fDone, VARIANT *pvarargIn, VARIANT *pvarargOut)
2592{
2593 return E_NOTIMPL;
2594}
2595
2597{
2598 return E_NOTIMPL;
2599}
2600
2602{
2603 return E_NOTIMPL;
2604}
2605
2607{
2608 return E_NOTIMPL;
2609}
2610
2612{
2613 return E_NOTIMPL;
2614}
2615
2617{
2618 return E_NOTIMPL;
2619}
2620
2622{
2623 return E_NOTIMPL;
2624}
2625
2627{
2629 return S_OK;
2630}
2631
2633{
2634 return 0;
2635}
2636
2638{
2639 return E_NOTIMPL;
2640}
2641
2643{
2644 return 0;
2645}
2646
2648{
2649 return E_NOTIMPL;
2650}
2651
2653{
2654 return E_NOTIMPL;
2655}
2656
2658{
2659 return E_NOTIMPL;
2660}
2661
2663{
2664 return E_NOTIMPL;
2665}
2666
2668 IShellView *psvNew, IShellView *psvOld, LPRECT prcView, HWND *phwnd)
2669{
2670 return E_NOTIMPL;
2671}
2672
2674{
2675 return E_NOTIMPL;
2676}
2677
2679{
2680 return E_NOTIMPL;
2681}
2682
2684{
2685 return E_NOTIMPL;
2686}
2687
2689{
2690 return NULL;
2691}
2692
2694{
2695 return E_NOTIMPL;
2696}
2697
2699{
2700 return E_NOTIMPL;
2701}
2702
2704{
2705 return E_NOTIMPL;
2706}
2707
2709{
2710 return E_NOTIMPL;
2711}
2712
2714{
2715 return E_NOTIMPL;
2716}
2717
2719{
2720 return E_NOTIMPL;
2721}
2722
2724{
2725 return E_NOTIMPL;
2726}
2727
2729{
2730 return E_NOTIMPL;
2731}
2732
2734{
2735 return E_NOTIMPL;
2736}
2737
2739{
2740 return E_NOTIMPL;
2741}
2742
2744{
2745 return E_NOTIMPL;
2746}
2747
2749{
2750 return E_NOTIMPL;
2751}
2752
2754{
2755 return E_NOTIMPL;
2756}
2757
2759{
2760 return E_NOTIMPL;
2761}
2762
2764{
2765 return E_NOTIMPL;
2766}
2767
2769{
2770 return E_NOTIMPL;
2771}
2772
2774{
2775 return E_NOTIMPL;
2776}
2777
2779 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut)
2780{
2781 return E_NOTIMPL;
2782}
2783
2785 HWND hwndBar, BOOL fBroadcast, UINT uMsg, WPARAM wParam, LPARAM lParam)
2786{
2787 return E_NOTIMPL;
2788}
2789
2791{
2792 return E_NOTIMPL;
2793}
2794
2796{
2797 return E_NOTIMPL;
2798}
2799
2801{
2802 return E_NOTIMPL;
2803}
2804
2806{
2807 return 0;
2808}
2809
2811{
2812 return E_NOTIMPL;
2813}
2814
2816{
2817 return E_NOTIMPL;
2818}
2819
2821{
2822 return E_NOTIMPL;
2823}
2824
2826{
2827 return E_NOTIMPL;
2828}
2829
2831{
2832 return E_NOTIMPL;
2833}
2834
2836{
2837 return E_NOTIMPL;
2838}
2839
2841{
2842 return E_NOTIMPL;
2843}
2844
2846{
2847 return NULL;
2848}
2849
2851{
2852 return 0;
2853}
2854
2856{
2857 return E_NOTIMPL;
2858}
2859
2861{
2862 return 0;
2863}
2864
2866{
2867 return NULL;
2868}
2869
2871{
2872 return E_NOTIMPL;
2873}
2874
2876{
2877 return E_NOTIMPL;
2878}
2879
2881{
2882 return E_NOTIMPL;
2883}
2884
2886 LPMSG lpMsg, UINT itbNext, int citb, LPTOOLBARITEM *pptbi, HWND *phwnd)
2887{
2888 return E_NOTIMPL;
2889}
2890
2892{
2893 return E_NOTIMPL;
2894}
2895
2897{
2898 return 0;
2899}
2900
2902{
2903 return E_NOTIMPL;
2904}
2905
2907{
2908 for (int i = 0; i < 3; i++)
2909 {
2910 if (IUnknown_TranslateAcceleratorIO(fClientBars[i].clientBar, pmsg) == S_OK)
2911 return S_OK;
2912 }
2913
2914 if (!fCurrentShellView)
2915 return S_FALSE;
2916
2917 return fCurrentShellView->TranslateAcceleratorW(pmsg);
2918}
2919
2921{
2922 return E_NOTIMPL;
2923}
2924
2926{
2927 return E_NOTIMPL;
2928}
2929
2931{
2932 CComPtr<ITravelLog> travelLog;
2933 HRESULT hResult = GetTravelLog(&travelLog);
2934 if (FAILED_UNEXPECTEDLY(hResult))
2935 return hResult;
2936 return travelLog->Travel(static_cast<IDropTarget *>(this), TLOG_BACK);
2937}
2938
2940{
2941 CComPtr<ITravelLog> travelLog;
2942 HRESULT hResult = GetTravelLog(&travelLog);
2943 if (FAILED_UNEXPECTEDLY(hResult))
2944 return hResult;
2945 return travelLog->Travel(static_cast<IDropTarget *>(this), TLOG_FORE);
2946}
2947
2949{
2950 return E_NOTIMPL;
2951}
2952
2954{
2955 return E_NOTIMPL;
2956}
2957
2959 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
2960{
2962 HRESULT hResult;
2963 CComPtr<IShellFolder> pDesktop;
2964
2965 hResult = SHGetDesktopFolder(&pDesktop);
2966 if (FAILED_UNEXPECTEDLY(hResult))
2967 return hResult;
2968 hResult = pDesktop->ParseDisplayName(NULL, NULL, URL, NULL, &pidl, NULL);
2969 if (FAILED_UNEXPECTEDLY(hResult))
2970 return hResult;
2971 return BrowseObject(pidl, 1);
2972}
2973
2975{
2976 VARIANT level;
2977
2978 V_VT(&level) = VT_I4;
2979 V_I4(&level) = 4;
2980 return Refresh2(&level);
2981}
2982
2984{
2985 CComPtr<IOleCommandTarget> oleCommandTarget;
2986 HRESULT hResult;
2987
2988 hResult = fCurrentShellView->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &oleCommandTarget));
2989 if (FAILED_UNEXPECTEDLY(hResult))
2990 return hResult;
2991 return oleCommandTarget->Exec(NULL, 22, 1, Level, NULL);
2992}
2993
2995{
2996 return E_NOTIMPL;
2997}
2998
3000{
3001 return E_NOTIMPL;
3002}
3003
3005{
3006 return E_NOTIMPL;
3007}
3008
3010{
3011 return E_NOTIMPL;
3012}
3013
3015{
3016 return E_NOTIMPL;
3017}
3018
3020{
3021 return E_NOTIMPL;
3022}
3023
3025{
3026 return E_NOTIMPL;
3027}
3028#ifdef __exdisp_h__
3029#define long LONG
3030#endif
3032{
3033 return E_NOTIMPL;
3034}
3035
3037{
3038 return E_NOTIMPL;
3039}
3040
3042{
3043 return E_NOTIMPL;
3044}
3045
3047{
3048 return E_NOTIMPL;
3049}
3050
3052{
3053 return E_NOTIMPL;
3054}
3055
3057{
3058 return E_NOTIMPL;
3059}
3060
3062{
3063 return E_NOTIMPL;
3064}
3065
3067{
3068 return E_NOTIMPL;
3069}
3070#ifdef __exdisp_h__
3071#undef long
3072#endif
3074{
3075 return E_NOTIMPL;
3076}
3077
3079{
3080 return E_NOTIMPL;
3081}
3082
3084{
3085 return E_NOTIMPL;
3086}
3087
3089{
3090 return E_NOTIMPL;
3091}
3092
3094{
3095 return E_NOTIMPL;
3096}
3097
3099{
3100 return E_NOTIMPL;
3101}
3102
3104{
3105 return E_NOTIMPL;
3106}
3107
3109{
3110 return E_NOTIMPL;
3111}
3112
3114{
3115 return E_NOTIMPL;
3116}
3117
3119{
3120 return E_NOTIMPL;
3121}
3122
3124{
3125 return E_NOTIMPL;
3126}
3127
3129{
3130 return E_NOTIMPL;
3131}
3132
3134{
3135 return E_NOTIMPL;
3136}
3137
3139{
3140 return E_NOTIMPL;
3141}
3142
3144{
3145 return E_NOTIMPL;
3146}
3147
3149{
3150 return E_NOTIMPL;
3151}
3152
3154{
3155 return E_NOTIMPL;
3156}
3157
3159{
3160 return E_NOTIMPL;
3161}
3162
3164{
3165 return E_NOTIMPL;
3166}
3167
3169{
3170 return E_NOTIMPL;
3171}
3172
3174{
3175 return E_NOTIMPL;
3176}
3177
3179{
3180 return E_NOTIMPL;
3181}
3182
3184{
3185 return E_NOTIMPL;
3186}
3187
3189 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
3190{
3191 LPITEMIDLIST pidl = NULL;
3192 HRESULT hResult;
3193 // called from drive combo box to navigate to a directory
3194 // Also called by search band to display shell results folder view
3195
3196 if (V_VT(URL) == VT_BSTR)
3197 {
3198 return this->Navigate(V_BSTR(URL), Flags, TargetFrameName, PostData, Headers);
3199 }
3200 if (V_VT(URL) == (VT_ARRAY | VT_UI1))
3201 {
3202 if (V_ARRAY(URL)->cDims != 1 || V_ARRAY(URL)->cbElements != 1)
3203 return E_INVALIDARG;
3204
3205 pidl = static_cast<LPITEMIDLIST>(V_ARRAY(URL)->pvData);
3206 }
3208 if (FAILED_UNEXPECTEDLY(hResult))
3209 return hResult;
3210 return S_OK;
3211}
3212
3214{
3215 return E_NOTIMPL;
3216}
3217
3219 VARIANT *pvaIn, VARIANT *pvaOut)
3220{
3221 return E_NOTIMPL;
3222}
3223
3225{
3226 CLSID classID;
3227 bool vertical;
3228
3229 // called to show search bar
3230 if (V_VT(pvaClsid) != VT_BSTR)
3231 return E_INVALIDARG;
3232 CLSIDFromString(V_BSTR(pvaClsid), &classID);
3233 // TODO: properly compute the value of vertical
3234 vertical = true;
3235 return ShowBand(classID, vertical);
3236}
3237
3239{
3240 return E_NOTIMPL;
3241}
3242
3244{
3245 return E_NOTIMPL;
3246}
3247
3249{
3250 return E_NOTIMPL;
3251}
3252
3254{
3255 return E_NOTIMPL;
3256}
3257
3259{
3260 return E_NOTIMPL;
3261}
3262
3264{
3265 return E_NOTIMPL;
3266}
3267
3269{
3270 return E_NOTIMPL;
3271}
3272
3274{
3275 return E_NOTIMPL;
3276}
3277
3279{
3280 return E_NOTIMPL;
3281}
3282
3284{
3285 return E_NOTIMPL;
3286}
3287
3289{
3290 return E_NOTIMPL;
3291}
3292
3294{
3295 return E_NOTIMPL;
3296}
3297
3299{
3300 return E_NOTIMPL;
3301}
3302
3304{
3305 return E_NOTIMPL;
3306}
3307
3309{
3310 return E_NOTIMPL;
3311}
3312
3314{
3315 return E_NOTIMPL;
3316}
3317
3319{
3320 if (pWinData == NULL)
3321 return E_POINTER;
3322
3323 pWinData->dwWindowID = -1;
3324 pWinData->uiCP = 0;
3325 pWinData->pidl = ILClone(fCurrentDirectoryPIDL);
3326 pWinData->lpszUrl = NULL;
3327 pWinData->lpszUrlLocation = NULL;
3328 pWinData->lpszTitle = NULL;
3329 return S_OK;
3330}
3331
3333{
3334 return E_NOTIMPL;
3335}
3336
3338{
3339 return E_NOTIMPL;
3340}
3341
3343{
3344 CComPtr<IPersistHistory> viewPersistHistory;
3345 CComPtr<IOleObject> viewHistoryObject;
3346 persistState oldState;
3347 ULONG numRead;
3348 LPITEMIDLIST pidl;
3349 HRESULT hResult;
3350
3351 hResult = pStream->Read(&oldState, sizeof(oldState), &numRead);
3352 if (FAILED_UNEXPECTEDLY(hResult))
3353 return hResult;
3354 if (numRead != sizeof(oldState) || oldState.dwSize != sizeof(oldState))
3355 return E_FAIL;
3356 if (oldState.browseType != 2)
3357 return E_FAIL;
3358 pidl = static_cast<LPITEMIDLIST>(CoTaskMemAlloc(oldState.pidlSize));
3359 if (pidl == NULL)
3360 return E_OUTOFMEMORY;
3361 hResult = pStream->Read(pidl, oldState.pidlSize, &numRead);
3362 if (FAILED_UNEXPECTEDLY(hResult))
3363 {
3364 ILFree(pidl);
3365 return hResult;
3366 }
3367 if (numRead != oldState.pidlSize)
3368 {
3369 ILFree(pidl);
3370 return E_FAIL;
3371 }
3372 hResult = CoCreateInstance(oldState.persistClass, NULL, CLSCTX_LOCAL_SERVER | CLSCTX_INPROC_SERVER,
3373 IID_PPV_ARG(IOleObject, &viewHistoryObject));
3374 fHistoryObject = viewHistoryObject;
3375 fHistoryStream = pStream;
3376 fHistoryBindContext = pbc;
3377 hResult = BrowseToPIDL(pidl, BTP_DONT_UPDATE_HISTORY);
3381 ILFree(pidl);
3382 if (FAILED_UNEXPECTEDLY(hResult))
3383 return hResult;
3384 return S_OK;
3385}
3386
3388{
3389 CComPtr<IPersistHistory> viewPersistHistory;
3390 persistState newState;
3391 HRESULT hResult;
3392
3393 hResult = fCurrentShellView->GetItemObject(
3394 SVGIO_BACKGROUND, IID_PPV_ARG(IPersistHistory, &viewPersistHistory));
3395 memset(&newState, 0, sizeof(newState));
3396 newState.dwSize = sizeof(newState);
3397 newState.browseType = 2;
3398 newState.browserIndex = GetBrowserIndex();
3399 if (viewPersistHistory.p != NULL)
3400 {
3401 hResult = viewPersistHistory->GetClassID(&newState.persistClass);
3402 if (FAILED_UNEXPECTEDLY(hResult))
3403 return hResult;
3404 }
3406 hResult = pStream->Write(&newState, sizeof(newState), NULL);
3407 if (FAILED_UNEXPECTEDLY(hResult))
3408 return hResult;
3409 hResult = pStream->Write(fCurrentDirectoryPIDL, newState.pidlSize, NULL);
3410 if (FAILED_UNEXPECTEDLY(hResult))
3411 return hResult;
3412 if (viewPersistHistory.p != NULL)
3413 {
3414 hResult = viewPersistHistory->SaveHistory(pStream);
3415 if (FAILED_UNEXPECTEDLY(hResult))
3416 return hResult;
3417 }
3418 return S_OK;
3419}
3420
3422{
3423 return E_NOTIMPL;
3424}
3425
3427{
3428 return E_NOTIMPL;
3429}
3430
3432{
3433 OnCreate(reinterpret_cast<LPCREATESTRUCT> (lParam));
3434 return 0;
3435}
3436
3438{
3439 HRESULT hr;
3440
3441 /* The current thread is about to go down so render any IDataObject that may be left in the clipboard */
3443
3444 // TODO: rip down everything
3445 {
3447
3448 fCurrentShellView->DestroyViewWindow();
3449 fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
3450
3451 for (int i = 0; i < 3; i++)
3452 {
3455 CComPtr<IUnknown> pBarSite;
3457
3458 if (fClientBars[i].clientBar == NULL)
3459 continue;
3460
3461 hr = fClientBars[i].clientBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &pdw));
3463 continue;
3464
3465 /* We should destroy our basebarsite too */
3466 hr = pdw->QueryInterface(IID_PPV_ARG(IDeskBar, &bar));
3467 if (SUCCEEDED(hr))
3468 {
3469 hr = bar->GetClient(&pBarSite);
3470 if (SUCCEEDED(hr) && pBarSite)
3471 {
3472 hr = pBarSite->QueryInterface(IID_PPV_ARG(IDeskBarClient, &pClient));
3473 if (SUCCEEDED(hr))
3474 pClient->SetDeskBarSite(NULL);
3475 }
3476 }
3477 pdw->CloseDW(0);
3478
3479 pClient = NULL;
3480 pBarSite = NULL;
3481 pdw = NULL;
3482 bar = NULL;
3483 ReleaseCComPtrExpectZero(fClientBars[i].clientBar);
3484 }
3485 ReleaseCComPtrExpectZero(fCurrentShellView);
3486 ReleaseCComPtrExpectZero(fTravelLog);
3487
3492 }
3493 PostQuitMessage(0);
3494 return 0;
3495}
3496
3498{
3499 CComPtr<IDockingWindow> dockingWindow;
3500 RECT availableBounds;
3501 static const INT excludeItems[] = {1, 1, 1, IDC_STATUSBAR, 0, 0};
3502 HRESULT hResult;
3503
3504 if (wParam != SIZE_MINIMIZED)
3505 {
3506 GetEffectiveClientRect(m_hWnd, &availableBounds, excludeItems);
3507 for (INT x = 0; x < 3; x++)
3508 {
3509 if (fClientBars[x].clientBar != NULL)
3510 {
3511 hResult = fClientBars[x].clientBar->QueryInterface(
3512 IID_PPV_ARG(IDockingWindow, &dockingWindow));
3513 if (SUCCEEDED(hResult) && dockingWindow != NULL)
3514 {
3515 hResult = dockingWindow->ResizeBorderDW(
3516 &availableBounds, static_cast<IDropTarget *>(this), TRUE);
3517 break;
3518 }
3519 }
3520 }
3522 }
3523 return 1;
3524}
3525
3527{
3528 HMENU theMenu;
3529 LPARAM menuIndex = lParam;
3530
3531 theMenu = reinterpret_cast<HMENU>(wParam);
3532
3534 {
3535 menuIndex = 0;
3536 }
3537 else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_EDIT))
3538 {
3539 menuIndex = 1;
3540 }
3541 else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_VIEW))
3542 {
3543 UpdateViewMenu(theMenu);
3544 menuIndex = 2;
3545 }
3547 {
3548 menuIndex = 3;
3549 }
3550 else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_TOOLS))
3551 {
3552 // FIXME: Remove once implemented
3555 menuIndex = 4;
3556 }
3557 else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_HELP))
3558 {
3559 menuIndex = 5;
3560 }
3561
3562 LRESULT ret = RelayMsgToShellView(uMsg, wParam, menuIndex, bHandled);
3563
3564 return ret;
3565}
3566
3568{
3570 return 0;
3571}
3572
3574{
3577 return 0;
3578}
3579
3581{
3584 return 0;
3585}
3586
3587LRESULT CShellBrowser::OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3588{
3589 return SendMessage(WM_CLOSE);
3590}
3591
3592LRESULT CShellBrowser::OnFolderOptions(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3593{
3594 HRESULT hResult = DoFolderOptions();
3595 if (FAILED(hResult))
3596 TRACE("DoFolderOptions failed with hResult=%08lx\n", hResult);
3597 return 0;
3598}
3599
3600LRESULT CShellBrowser::OnMapNetworkDrive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3601{
3602#ifndef __REACTOS__
3604#endif /* __REACTOS__ */
3605 return 0;
3606}
3607
3609{
3611 return 0;
3612}
3613
3614LRESULT CShellBrowser::OnAboutReactOS(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3615{
3616 ShellAbout(m_hWnd, _T("ReactOS"), NULL, NULL);
3617 return 0;
3618}
3619
3620LRESULT CShellBrowser::OnGoBack(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3621{
3622 HRESULT hResult = GoBack();
3623 if (FAILED(hResult))
3624 TRACE("GoBack failed with hResult=%08lx\n", hResult);
3625 return 0;
3626}
3627
3628LRESULT CShellBrowser::OnGoForward(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3629{
3630 HRESULT hResult = GoForward();
3631 if (FAILED(hResult))
3632 TRACE("GoForward failed with hResult=%08lx\n", hResult);
3633 return 0;
3634}
3635
3636LRESULT CShellBrowser::OnGoUpLevel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3637{
3638 HRESULT hResult = NavigateToParent();
3639 if (FAILED(hResult))
3640 TRACE("NavigateToParent failed with hResult=%08lx\n", hResult);
3641 return 0;
3642}
3643
3644LRESULT CShellBrowser::OnGoHome(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3645{
3646 HRESULT hResult = GoHome();
3647 if (FAILED(hResult))
3648 TRACE("GoHome failed with hResult=%08lx\n", hResult);
3649 return 0;
3650}
3651
3652LRESULT CShellBrowser::OnBackspace(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3653{
3654 // FIXME: This does not appear to be what windows does.
3655 HRESULT hResult = NavigateToParent();
3656 if (FAILED(hResult))
3657 TRACE("NavigateToParent failed with hResult=%08lx\n", hResult);
3658 return 0;
3659}
3660
3661static BOOL
3663 IN LPCWSTR pszLnkFileName,
3664 IN LPCITEMIDLIST pidl,
3665 IN LPCWSTR pszDescription OPTIONAL)
3666{
3667 IPersistFile *pPF;
3668 IShellLinkW *pSL;
3670 if (FAILED(hr))
3671 return hr;
3672
3673 hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
3674 IID_IShellLinkW, (LPVOID*)&pSL);
3675 if (SUCCEEDED(hr))
3676 {
3677 pSL->SetIDList(pidl);
3678
3679 if (pszDescription)
3680 pSL->SetDescription(pszDescription);
3681
3682 hr = pSL->QueryInterface(IID_IPersistFile, (LPVOID*)&pPF);
3683 if (SUCCEEDED(hr))
3684 {
3685 hr = pPF->Save(pszLnkFileName, TRUE);
3686 pPF->Release();
3687 }
3688 pSL->Release();
3689 }
3690
3692
3693 return SUCCEEDED(hr);
3694}
3695
3697{
3699 if (FAILED(hr))
3701
3702 return hr;
3703}
3704
3705LRESULT CShellBrowser::OnAddToFavorites(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3706{
3707 LPITEMIDLIST pidlFavs;
3708 HRESULT hr = GetFavsLocation(m_hWnd, &pidlFavs);
3710 return 0;
3711
3712 SHFILEINFOW fileInfo = { NULL };
3713 if (!SHGetFileInfoW((LPCWSTR)fCurrentDirectoryPIDL, 0, &fileInfo, sizeof(fileInfo),
3715 {
3716 return 0;
3717 }
3718
3720 SHGetPathFromIDListW(pidlFavs, szPath);
3721 PathAppendW(szPath, fileInfo.szDisplayName);
3722 PathAddExtensionW(szPath, L".lnk");
3723
3725 return 0;
3726}
3727
3728LRESULT CShellBrowser::OnOrganizeFavorites(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3729{
3730 CComPtr<IShellFolder> psfDesktop;
3731 LPITEMIDLIST pidlFavs;
3732 HRESULT hr = GetFavsLocation(m_hWnd, &pidlFavs);
3734 return 0;
3735