xref: /reactos/dll/win32/browseui/shellbrowser.cpp (revision 8c2e9189)
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 
27 extern HRESULT IUnknown_ShowDW(IUnknown * punk, BOOL fShow);
28 
29 #include "newatlinterfaces.h"
30 
31 /*
32 TODO:
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 
119 static const unsigned int                   folderOptionsPageCountMax = 20;
120 static const long                           BTP_DONT_UPDATE_HISTORY = 0;
121 static const long                           BTP_UPDATE_CUR_HISTORY = 1;
122 static const long                           BTP_UPDATE_NEXT_HISTORY = 2;
123 
124 BOOL                                        createNewStuff = false;
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 
130 void 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 
153 HRESULT WINAPI SHBindToFolder(LPCITEMIDLIST path, IShellFolder **newFolder)
154 {
155     CComPtr<IShellFolder>                   desktop;
156 
157     HRESULT hr = ::SHGetDesktopFolder(&desktop);
158     if (FAILED_UNEXPECTEDLY(hr))
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 
169 static const TCHAR szCabinetWndClass[] = TEXT("CabinetWClass");
170 //static const TCHAR szExploreWndClass[] = TEXT("ExploreWClass");
171 
172 class CDockManager;
173 class CShellBrowser;
174 
175 class CToolbarProxy :
176     public CWindowImpl<CToolbarProxy, CWindow, CControlWinTraits>
177 {
178 private:
179     CComPtr<IExplorerToolbar>               fExplorerToolbar;
180 public:
181     void Initialize(HWND parent, IUnknown *explorerToolbar);
182     void Destroy();
183 private:
184 
185     // message handlers
186     LRESULT OnAddBitmap(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
187     LRESULT OnForwardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
188 
189     BEGIN_MSG_MAP(CToolbarProxy)
190         MESSAGE_HANDLER(TB_ADDBITMAP, OnAddBitmap)
191         MESSAGE_RANGE_HANDLER(WM_USER, 0x7fff, OnForwardMessage)
192     END_MSG_MAP()
193 };
194 
195 void CToolbarProxy::Initialize(HWND parent, IUnknown *explorerToolbar)
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 
210 void CToolbarProxy::Destroy()
211 {
212     DestroyWindow();
213     fExplorerToolbar = NULL;
214 }
215 
216 LRESULT CToolbarProxy::OnAddBitmap(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
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 
232 LRESULT CToolbarProxy::OnForwardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
233 {
234     LRESULT                                 result;
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 /*
244 Switch 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 
249 struct MenuBandInfo {
250     GUID barGuid;
251     BOOL fVertical;
252 };
253 
254 class CShellBrowser :
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 {
272 private:
273     class barInfo
274     {
275     public:
276         barInfo()
277         {
278             memset(&borderSpace, 0, sizeof(borderSpace));
279             hwnd = NULL;
280         }
281 
282         RECT                                borderSpace;
283         CComPtr<IUnknown>                   clientBar;
284         HWND                                hwnd;
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
291     CComPtr<IShellFolder>                   fCurrentShellFolder;        //
292     CComPtr<IShellView>                     fCurrentShellView;          //
293     LPITEMIDLIST                            fCurrentDirectoryPIDL;      //
294     HWND                                    fStatusBar;
295     bool                                    fStatusBarVisible;
296     CToolbarProxy                           fToolbarProxy;
297     barInfo                                 fClientBars[3];
298     CComPtr<ITravelLog>                     fTravelLog;
299     HMENU                                   fCurrentMenuBar;
300     CABINETSTATE                            fCabinetState;
301     // The next three fields support persisted history for shell views.
302     // They do not need to be reference counted.
303     IOleObject                              *fHistoryObject;
304     IStream                                 *fHistoryStream;
305     IBindCtx                                *fHistoryBindContext;
306     HDSA menuDsa;
307     HACCEL m_hAccel;
308 public:
309 #if 0
310     ULONG InternalAddRef()
311     {
312         OutputDebugString(_T("AddRef\n"));
313         return CComObjectRootEx<CComMultiThreadModelNoCS>::InternalAddRef();
314     }
315     ULONG InternalRelease()
316     {
317         OutputDebugString(_T("Release\n"));
318         return CComObjectRootEx<CComMultiThreadModelNoCS>::InternalRelease();
319     }
320 #endif
321 
322     CShellBrowser();
323     ~CShellBrowser();
324     HRESULT Initialize(LPITEMIDLIST pidl, DWORD dwFlags);
325 public:
326     HRESULT BrowseToPIDL(LPCITEMIDLIST pidl, long flags);
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 verticali, DWORD *pdwBandID);
332     HRESULT ShowBand(const CLSID &classID, bool vertical);
333     HRESULT NavigateToParent();
334     HRESULT DoFolderOptions();
335     static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
336     void RepositionBars();
337     HRESULT BuildExplorerBandMenu();
338     HRESULT BuildExplorerBandCategory(HMENU hBandsMenu, CATID category, DWORD dwPos, UINT *nbFound);
339     BOOL IsBuiltinBand(CLSID &bandID);
340     virtual WNDPROC GetWindowProc()
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);
347     HRESULT FireCommandStateChangeAll();
348     HRESULT UpdateForwardBackState();
349     HRESULT UpdateUpState();
350     void UpdateGotoMenu(HMENU theMenu);
351     void UpdateViewMenu(HMENU theMenu);
352 
353 /*    // *** IDockingWindowFrame methods ***
354     virtual HRESULT STDMETHODCALLTYPE AddToolbar(IUnknown *punkSrc, LPCWSTR pwszItem, DWORD dwAddFlags);
355     virtual HRESULT STDMETHODCALLTYPE RemoveToolbar(IUnknown *punkSrc, DWORD dwRemoveFlags);
356     virtual HRESULT STDMETHODCALLTYPE FindToolbar(LPCWSTR pwszItem, REFIID riid, void **ppv);
357     */
358 
359     // *** IDockingWindowSite methods ***
360     virtual HRESULT STDMETHODCALLTYPE GetBorderDW(IUnknown* punkObj, LPRECT prcBorder);
361     virtual HRESULT STDMETHODCALLTYPE RequestBorderSpaceDW(IUnknown* punkObj, LPCBORDERWIDTHS pbw);
362     virtual HRESULT STDMETHODCALLTYPE SetBorderSpaceDW(IUnknown* punkObj, LPCBORDERWIDTHS pbw);
363 
364     // *** IOleCommandTarget methods ***
365     virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds,
366         OLECMD prgCmds[  ], OLECMDTEXT *pCmdText);
367     virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID,
368         DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
369 
370     // *** IOleWindow methods ***
371     virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *lphwnd);
372     virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
373 
374     // *** IShellBrowser methods ***
375     virtual HRESULT STDMETHODCALLTYPE InsertMenusSB(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths);
376     virtual HRESULT STDMETHODCALLTYPE SetMenuSB(HMENU hmenuShared, HOLEMENU holemenuRes, HWND hwndActiveObject);
377     virtual HRESULT STDMETHODCALLTYPE RemoveMenusSB(HMENU hmenuShared);
378     virtual HRESULT STDMETHODCALLTYPE SetStatusTextSB(LPCOLESTR pszStatusText);
379     virtual HRESULT STDMETHODCALLTYPE EnableModelessSB(BOOL fEnable);
380     virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorSB(MSG *pmsg, WORD wID);
381     virtual HRESULT STDMETHODCALLTYPE BrowseObject(LPCITEMIDLIST pidl, UINT wFlags);
382     virtual HRESULT STDMETHODCALLTYPE GetViewStateStream(DWORD grfMode, IStream **ppStrm);
383     virtual HRESULT STDMETHODCALLTYPE GetControlWindow(UINT id, HWND *lphwnd);
384     virtual HRESULT STDMETHODCALLTYPE SendControlMsg(UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pret);
385     virtual HRESULT STDMETHODCALLTYPE QueryActiveShellView(IShellView **ppshv);
386     virtual HRESULT STDMETHODCALLTYPE OnViewWindowActive(IShellView *ppshv);
387     virtual HRESULT STDMETHODCALLTYPE SetToolbarItems(LPTBBUTTON lpButtons, UINT nButtons, UINT uFlags);
388 
389     // *** IDropTarget methods ***
390     virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
391     virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
392     virtual HRESULT STDMETHODCALLTYPE DragLeave();
393     virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
394 
395     // *** IServiceProvider methods ***
396     virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject);
397 
398     // *** IShellBowserService methods ***
399     virtual HRESULT STDMETHODCALLTYPE GetPropertyBag(long flags, REFIID riid, void **ppvObject);
400 
401     // *** IDispatch methods ***
402     virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo);
403     virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
404     virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(
405         REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
406     virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
407         DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
408 
409     // *** IBrowserService methods ***
410     virtual HRESULT STDMETHODCALLTYPE GetParentSite(IOleInPlaceSite **ppipsite);
411     virtual HRESULT STDMETHODCALLTYPE SetTitle(IShellView *psv, LPCWSTR pszName);
412     virtual HRESULT STDMETHODCALLTYPE GetTitle(IShellView *psv, LPWSTR pszName, DWORD cchName);
413     virtual HRESULT STDMETHODCALLTYPE GetOleObject(IOleObject **ppobjv);
414     virtual HRESULT STDMETHODCALLTYPE GetTravelLog(ITravelLog **pptl);
415     virtual HRESULT STDMETHODCALLTYPE ShowControlWindow(UINT id, BOOL fShow);
416     virtual HRESULT STDMETHODCALLTYPE IsControlWindowShown(UINT id, BOOL *pfShown);
417     virtual HRESULT STDMETHODCALLTYPE IEGetDisplayName(LPCITEMIDLIST pidl, LPWSTR pwszName, UINT uFlags);
418     virtual HRESULT STDMETHODCALLTYPE IEParseDisplayName(UINT uiCP, LPCWSTR pwszPath, LPITEMIDLIST *ppidlOut);
419     virtual HRESULT STDMETHODCALLTYPE DisplayParseError(HRESULT hres, LPCWSTR pwszPath);
420     virtual HRESULT STDMETHODCALLTYPE NavigateToPidl(LPCITEMIDLIST pidl, DWORD grfHLNF);
421     virtual HRESULT STDMETHODCALLTYPE SetNavigateState(BNSTATE bnstate);
422     virtual HRESULT STDMETHODCALLTYPE GetNavigateState(BNSTATE *pbnstate);
423     virtual HRESULT STDMETHODCALLTYPE NotifyRedirect(IShellView *psv, LPCITEMIDLIST pidl, BOOL *pfDidBrowse);
424     virtual HRESULT STDMETHODCALLTYPE UpdateWindowList();
425     virtual HRESULT STDMETHODCALLTYPE UpdateBackForwardState();
426     virtual HRESULT STDMETHODCALLTYPE SetFlags(DWORD dwFlags, DWORD dwFlagMask);
427     virtual HRESULT STDMETHODCALLTYPE GetFlags(DWORD *pdwFlags);
428     virtual HRESULT STDMETHODCALLTYPE CanNavigateNow( void);
429     virtual HRESULT STDMETHODCALLTYPE GetPidl(LPITEMIDLIST *ppidl);
430     virtual HRESULT STDMETHODCALLTYPE SetReferrer(LPCITEMIDLIST pidl);
431     virtual DWORD STDMETHODCALLTYPE GetBrowserIndex();
432     virtual HRESULT STDMETHODCALLTYPE GetBrowserByIndex(DWORD dwID, IUnknown **ppunk);
433     virtual HRESULT STDMETHODCALLTYPE GetHistoryObject(IOleObject **ppole, IStream **pstm, IBindCtx **ppbc);
434     virtual HRESULT STDMETHODCALLTYPE SetHistoryObject(IOleObject *pole, BOOL fIsLocalAnchor);
435     virtual HRESULT STDMETHODCALLTYPE CacheOLEServer(IOleObject *pole);
436     virtual HRESULT STDMETHODCALLTYPE GetSetCodePage(VARIANT *pvarIn, VARIANT *pvarOut);
437     virtual HRESULT STDMETHODCALLTYPE OnHttpEquiv(IShellView *psv, BOOL fDone, VARIANT *pvarargIn, VARIANT *pvarargOut);
438     virtual HRESULT STDMETHODCALLTYPE GetPalette(HPALETTE *hpal);
439     virtual HRESULT STDMETHODCALLTYPE RegisterWindow(BOOL fForceRegister, int swc);
440 
441     // *** IBrowserService2 methods ***
442     virtual LRESULT STDMETHODCALLTYPE WndProcBS(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
443     virtual HRESULT STDMETHODCALLTYPE SetAsDefFolderSettings();
444     virtual HRESULT STDMETHODCALLTYPE GetViewRect(RECT *prc);
445     virtual HRESULT STDMETHODCALLTYPE OnSize(WPARAM wParam);
446     virtual HRESULT STDMETHODCALLTYPE OnCreate(struct tagCREATESTRUCTW *pcs);
447     virtual LRESULT STDMETHODCALLTYPE OnCommand(WPARAM wParam, LPARAM lParam);
448     virtual HRESULT STDMETHODCALLTYPE OnDestroy();
449     virtual LRESULT STDMETHODCALLTYPE OnNotify(struct tagNMHDR *pnm);
450     virtual HRESULT STDMETHODCALLTYPE OnSetFocus();
451     virtual HRESULT STDMETHODCALLTYPE OnFrameWindowActivateBS(BOOL fActive);
452     virtual HRESULT STDMETHODCALLTYPE ReleaseShellView();
453     virtual HRESULT STDMETHODCALLTYPE ActivatePendingView();
454     virtual HRESULT STDMETHODCALLTYPE CreateViewWindow(IShellView *psvNew, IShellView *psvOld, LPRECT prcView, HWND *phwnd);
455     virtual HRESULT STDMETHODCALLTYPE CreateBrowserPropSheetExt(REFIID riid, void **ppv);
456     virtual HRESULT STDMETHODCALLTYPE GetViewWindow(HWND *phwndView);
457     virtual HRESULT STDMETHODCALLTYPE GetBaseBrowserData(LPCBASEBROWSERDATA *pbbd);
458     virtual LPBASEBROWSERDATA STDMETHODCALLTYPE PutBaseBrowserData( void);
459     virtual HRESULT STDMETHODCALLTYPE InitializeTravelLog(ITravelLog *ptl, DWORD dw);
460     virtual HRESULT STDMETHODCALLTYPE SetTopBrowser();
461     virtual HRESULT STDMETHODCALLTYPE Offline(int iCmd);
462     virtual HRESULT STDMETHODCALLTYPE AllowViewResize(BOOL f);
463     virtual HRESULT STDMETHODCALLTYPE SetActivateState(UINT u);
464     virtual HRESULT STDMETHODCALLTYPE UpdateSecureLockIcon(int eSecureLock);
465     virtual HRESULT STDMETHODCALLTYPE InitializeDownloadManager();
466     virtual HRESULT STDMETHODCALLTYPE InitializeTransitionSite();
467     virtual HRESULT STDMETHODCALLTYPE _Initialize(HWND hwnd, IUnknown *pauto);
468     virtual HRESULT STDMETHODCALLTYPE _CancelPendingNavigationAsync( void);
469     virtual HRESULT STDMETHODCALLTYPE _CancelPendingView();
470     virtual HRESULT STDMETHODCALLTYPE _MaySaveChanges();
471     virtual HRESULT STDMETHODCALLTYPE _PauseOrResumeView(BOOL fPaused);
472     virtual HRESULT STDMETHODCALLTYPE _DisableModeless();
473     virtual HRESULT STDMETHODCALLTYPE _NavigateToPidl(LPCITEMIDLIST pidl, DWORD grfHLNF, DWORD dwFlags);
474     virtual HRESULT STDMETHODCALLTYPE _TryShell2Rename(IShellView *psv, LPCITEMIDLIST pidlNew);
475     virtual HRESULT STDMETHODCALLTYPE _SwitchActivationNow();
476     virtual HRESULT STDMETHODCALLTYPE _ExecChildren(IUnknown *punkBar, BOOL fBroadcast, const GUID *pguidCmdGroup,
477         DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
478     virtual HRESULT STDMETHODCALLTYPE _SendChildren(
479         HWND hwndBar, BOOL fBroadcast, UINT uMsg, WPARAM wParam, LPARAM lParam);
480     virtual HRESULT STDMETHODCALLTYPE GetFolderSetData(struct tagFolderSetData *pfsd);
481     virtual HRESULT STDMETHODCALLTYPE _OnFocusChange(UINT itb);
482     virtual HRESULT STDMETHODCALLTYPE v_ShowHideChildWindows(BOOL fChildOnly);
483     virtual UINT STDMETHODCALLTYPE _get_itbLastFocus();
484     virtual HRESULT STDMETHODCALLTYPE _put_itbLastFocus(UINT itbLastFocus);
485     virtual HRESULT STDMETHODCALLTYPE _UIActivateView(UINT uState);
486     virtual HRESULT STDMETHODCALLTYPE _GetViewBorderRect(RECT *prc);
487     virtual HRESULT STDMETHODCALLTYPE _UpdateViewRectSize();
488     virtual HRESULT STDMETHODCALLTYPE _ResizeNextBorder(UINT itb);
489     virtual HRESULT STDMETHODCALLTYPE _ResizeView();
490     virtual HRESULT STDMETHODCALLTYPE _GetEffectiveClientArea(LPRECT lprectBorder, HMONITOR hmon);
491     virtual IStream *STDMETHODCALLTYPE v_GetViewStream(LPCITEMIDLIST pidl, DWORD grfMode, LPCWSTR pwszName);
492     virtual LRESULT STDMETHODCALLTYPE ForwardViewMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);
493     virtual HRESULT STDMETHODCALLTYPE SetAcceleratorMenu(HACCEL hacc);
494     virtual int STDMETHODCALLTYPE _GetToolbarCount();
495     virtual LPTOOLBARITEM STDMETHODCALLTYPE _GetToolbarItem(int itb);
496     virtual HRESULT STDMETHODCALLTYPE _SaveToolbars(IStream *pstm);
497     virtual HRESULT STDMETHODCALLTYPE _LoadToolbars(IStream *pstm);
498     virtual HRESULT STDMETHODCALLTYPE _CloseAndReleaseToolbars(BOOL fClose);
499     virtual HRESULT STDMETHODCALLTYPE v_MayGetNextToolbarFocus(LPMSG lpMsg, UINT itbNext,
500         int citb, LPTOOLBARITEM *pptbi, HWND *phwnd);
501     virtual HRESULT STDMETHODCALLTYPE _ResizeNextBorderHelper(UINT itb, BOOL bUseHmonitor);
502     virtual UINT STDMETHODCALLTYPE _FindTBar(IUnknown *punkSrc);
503     virtual HRESULT STDMETHODCALLTYPE _SetFocus(LPTOOLBARITEM ptbi, HWND hwnd, LPMSG lpMsg);
504     virtual HRESULT STDMETHODCALLTYPE v_MayTranslateAccelerator(MSG *pmsg);
505     virtual HRESULT STDMETHODCALLTYPE _GetBorderDWHelper(IUnknown *punkSrc, LPRECT lprectBorder, BOOL bUseHmonitor);
506     virtual HRESULT STDMETHODCALLTYPE v_CheckZoneCrossing(LPCITEMIDLIST pidl);
507 
508     // *** IWebBrowser methods ***
509     virtual HRESULT STDMETHODCALLTYPE GoBack();
510     virtual HRESULT STDMETHODCALLTYPE GoForward();
511     virtual HRESULT STDMETHODCALLTYPE GoHome();
512     virtual HRESULT STDMETHODCALLTYPE GoSearch();
513     virtual HRESULT STDMETHODCALLTYPE Navigate(BSTR URL, VARIANT *Flags, VARIANT *TargetFrameName,
514         VARIANT *PostData, VARIANT *Headers);
515     virtual HRESULT STDMETHODCALLTYPE Refresh();
516     virtual HRESULT STDMETHODCALLTYPE Refresh2(VARIANT *Level);
517     virtual HRESULT STDMETHODCALLTYPE Stop();
518     virtual HRESULT STDMETHODCALLTYPE get_Application(IDispatch **ppDisp);
519     virtual HRESULT STDMETHODCALLTYPE get_Parent(IDispatch **ppDisp);
520     virtual HRESULT STDMETHODCALLTYPE get_Container(IDispatch **ppDisp);
521     virtual HRESULT STDMETHODCALLTYPE get_Document(IDispatch **ppDisp);
522     virtual HRESULT STDMETHODCALLTYPE get_TopLevelContainer(VARIANT_BOOL *pBool);
523     virtual HRESULT STDMETHODCALLTYPE get_Type(BSTR *Type);
524     virtual HRESULT STDMETHODCALLTYPE get_Left(long *pl);
525     virtual HRESULT STDMETHODCALLTYPE put_Left(long Left);
526     virtual HRESULT STDMETHODCALLTYPE get_Top(long *pl);
527     virtual HRESULT STDMETHODCALLTYPE put_Top(long Top);
528     virtual HRESULT STDMETHODCALLTYPE get_Width(long *pl);
529     virtual HRESULT STDMETHODCALLTYPE put_Width(long Width);
530     virtual HRESULT STDMETHODCALLTYPE get_Height(long *pl);
531     virtual HRESULT STDMETHODCALLTYPE put_Height(long Height);
532     virtual HRESULT STDMETHODCALLTYPE get_LocationName(BSTR *LocationName);
533     virtual HRESULT STDMETHODCALLTYPE get_LocationURL(BSTR *LocationURL);
534     virtual HRESULT STDMETHODCALLTYPE get_Busy(VARIANT_BOOL *pBool);
535 
536     // *** IWebBrowserApp methods ***
537     virtual HRESULT STDMETHODCALLTYPE Quit();
538     virtual HRESULT STDMETHODCALLTYPE ClientToWindow(int *pcx, int *pcy);
539     virtual HRESULT STDMETHODCALLTYPE PutProperty(BSTR Property, VARIANT vtValue);
540     virtual HRESULT STDMETHODCALLTYPE GetProperty(BSTR Property, VARIANT *pvtValue);
541     virtual HRESULT STDMETHODCALLTYPE get_Name(BSTR *Name);
542     virtual HRESULT STDMETHODCALLTYPE get_HWND(SHANDLE_PTR *pHWND);
543     virtual HRESULT STDMETHODCALLTYPE get_FullName(BSTR *FullName);
544     virtual HRESULT STDMETHODCALLTYPE get_Path(BSTR *Path);
545     virtual HRESULT STDMETHODCALLTYPE get_Visible(VARIANT_BOOL *pBool);
546     virtual HRESULT STDMETHODCALLTYPE put_Visible(VARIANT_BOOL Value);
547     virtual HRESULT STDMETHODCALLTYPE get_StatusBar(VARIANT_BOOL *pBool);
548     virtual HRESULT STDMETHODCALLTYPE put_StatusBar(VARIANT_BOOL Value);
549     virtual HRESULT STDMETHODCALLTYPE get_StatusText(BSTR *StatusText);
550     virtual HRESULT STDMETHODCALLTYPE put_StatusText(BSTR StatusText);
551     virtual HRESULT STDMETHODCALLTYPE get_ToolBar(int *Value);
552     virtual HRESULT STDMETHODCALLTYPE put_ToolBar(int Value);
553     virtual HRESULT STDMETHODCALLTYPE get_MenuBar(VARIANT_BOOL *Value);
554     virtual HRESULT STDMETHODCALLTYPE put_MenuBar(VARIANT_BOOL Value);
555     virtual HRESULT STDMETHODCALLTYPE get_FullScreen(VARIANT_BOOL *pbFullScreen);
556     virtual HRESULT STDMETHODCALLTYPE put_FullScreen(VARIANT_BOOL bFullScreen);
557 
558     // *** IWebBrowser2 methods ***
559     virtual HRESULT STDMETHODCALLTYPE Navigate2(VARIANT *URL, VARIANT *Flags, VARIANT *TargetFrameName,
560         VARIANT *PostData, VARIANT *Headers);
561     virtual HRESULT STDMETHODCALLTYPE QueryStatusWB(OLECMDID cmdID, OLECMDF *pcmdf);
562     virtual HRESULT STDMETHODCALLTYPE ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt,
563         VARIANT *pvaIn, VARIANT *pvaOut);
564     virtual HRESULT STDMETHODCALLTYPE ShowBrowserBar(VARIANT *pvaClsid, VARIANT *pvarShow, VARIANT *pvarSize);
565     virtual HRESULT STDMETHODCALLTYPE get_ReadyState(READYSTATE *plReadyState);
566     virtual HRESULT STDMETHODCALLTYPE get_Offline(VARIANT_BOOL *pbOffline);
567     virtual HRESULT STDMETHODCALLTYPE put_Offline(VARIANT_BOOL bOffline);
568     virtual HRESULT STDMETHODCALLTYPE get_Silent(VARIANT_BOOL *pbSilent);
569     virtual HRESULT STDMETHODCALLTYPE put_Silent(VARIANT_BOOL bSilent);
570     virtual HRESULT STDMETHODCALLTYPE get_RegisterAsBrowser(VARIANT_BOOL *pbRegister);
571     virtual HRESULT STDMETHODCALLTYPE put_RegisterAsBrowser(VARIANT_BOOL bRegister);
572     virtual HRESULT STDMETHODCALLTYPE get_RegisterAsDropTarget(VARIANT_BOOL *pbRegister);
573     virtual HRESULT STDMETHODCALLTYPE put_RegisterAsDropTarget(VARIANT_BOOL bRegister);
574     virtual HRESULT STDMETHODCALLTYPE get_TheaterMode(VARIANT_BOOL *pbRegister);
575     virtual HRESULT STDMETHODCALLTYPE put_TheaterMode(VARIANT_BOOL bRegister);
576     virtual HRESULT STDMETHODCALLTYPE get_AddressBar(VARIANT_BOOL *Value);
577     virtual HRESULT STDMETHODCALLTYPE put_AddressBar(VARIANT_BOOL Value);
578     virtual HRESULT STDMETHODCALLTYPE get_Resizable(VARIANT_BOOL *Value);
579     virtual HRESULT STDMETHODCALLTYPE put_Resizable(VARIANT_BOOL Value);
580 
581     // *** ITravelLogClient methods ***
582     virtual HRESULT STDMETHODCALLTYPE FindWindowByIndex(DWORD dwID, IUnknown **ppunk);
583     virtual HRESULT STDMETHODCALLTYPE GetWindowData(IStream *pStream, LPWINDOWDATA pWinData);
584     virtual HRESULT STDMETHODCALLTYPE LoadHistoryPosition(LPWSTR pszUrlLocation, DWORD dwPosition);
585 
586     // *** IPersist methods ***
587     virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
588 
589     // *** IPersistHistory methods ***
590     virtual HRESULT STDMETHODCALLTYPE LoadHistory(IStream *pStream, IBindCtx *pbc);
591     virtual HRESULT STDMETHODCALLTYPE SaveHistory(IStream *pStream);
592     virtual HRESULT STDMETHODCALLTYPE SetPositionCookie(DWORD dwPositioncookie);
593     virtual HRESULT STDMETHODCALLTYPE GetPositionCookie(DWORD *pdwPositioncookie);
594 
595     // message handlers
596     LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
597     LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
598     LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
599     LRESULT OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
600     LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
601     LRESULT RelayMsgToShellView(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
602     LRESULT PropagateMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
603     LRESULT OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
604     LRESULT OnFolderOptions(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
605     LRESULT OnMapNetworkDrive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
606     LRESULT OnDisconnectNetworkDrive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
607     LRESULT OnAboutReactOS(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
608     LRESULT OnGoBack(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
609     LRESULT OnGoForward(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
610     LRESULT OnGoUpLevel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
611     LRESULT OnBackspace(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
612     LRESULT OnGoHome(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
613     LRESULT OnOrganizeFavorites(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
614     LRESULT OnToggleStatusBarVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
615     LRESULT OnToggleToolbarLock(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
616     LRESULT OnToggleToolbarBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
617     LRESULT OnToggleAddressBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
618     LRESULT OnToggleLinksBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
619     LRESULT OnToggleTextLabels(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
620     LRESULT OnToolbarCustomize(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
621     LRESULT OnGoTravel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
622     LRESULT OnRefresh(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
623     LRESULT OnExplorerBar(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
624     LRESULT RelayCommands(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
625     HRESULT OnSearch();
626 
627     static ATL::CWndClassInfo& GetWndClassInfo()
628     {
629         static ATL::CWndClassInfo wc =
630         {
631             { sizeof(WNDCLASSEX), CS_DBLCLKS, StartWindowProc,
632               0, 0, NULL, LoadIcon(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDI_CABINET)),
633               LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_WINDOW + 1), NULL, szCabinetWndClass, NULL },
634             NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
635         };
636         return wc;
637     }
638 
639     BEGIN_MSG_MAP(CShellBrowser)
640         MESSAGE_HANDLER(WM_CREATE, OnCreate)
641         MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
642         MESSAGE_HANDLER(WM_SIZE, OnSize)
643         MESSAGE_HANDLER(WM_INITMENUPOPUP, OnInitMenuPopup)
644         MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
645         MESSAGE_HANDLER(WM_MEASUREITEM, RelayMsgToShellView)
646         MESSAGE_HANDLER(WM_DRAWITEM, RelayMsgToShellView)
647         MESSAGE_HANDLER(WM_MENUSELECT, RelayMsgToShellView)
648         MESSAGE_HANDLER(WM_WININICHANGE, PropagateMessage)
649         COMMAND_ID_HANDLER(IDM_FILE_CLOSE, OnClose)
650         COMMAND_ID_HANDLER(IDM_TOOLS_FOLDEROPTIONS, OnFolderOptions)
651         COMMAND_ID_HANDLER(IDM_TOOLS_MAPNETWORKDRIVE, OnMapNetworkDrive)
652         COMMAND_ID_HANDLER(IDM_TOOLS_DISCONNECTNETWORKDRIVE, OnDisconnectNetworkDrive)
653         COMMAND_ID_HANDLER(IDM_HELP_ABOUT, OnAboutReactOS)
654         COMMAND_ID_HANDLER(IDM_GOTO_BACK, OnGoBack)
655         COMMAND_ID_HANDLER(IDM_GOTO_FORWARD, OnGoForward)
656         COMMAND_ID_HANDLER(IDM_GOTO_UPONELEVEL, OnGoUpLevel)
657         COMMAND_ID_HANDLER(IDM_GOTO_HOMEPAGE, OnGoHome)
658         COMMAND_ID_HANDLER(IDM_FAVORITES_ORGANIZEFAVORITES, OnOrganizeFavorites)
659         COMMAND_ID_HANDLER(IDM_VIEW_STATUSBAR, OnToggleStatusBarVisible)
660         COMMAND_ID_HANDLER(IDM_VIEW_REFRESH, OnRefresh)
661         COMMAND_ID_HANDLER(IDM_TOOLBARS_LOCKTOOLBARS, OnToggleToolbarLock)
662         COMMAND_ID_HANDLER(IDM_TOOLBARS_STANDARDBUTTONS, OnToggleToolbarBandVisible)
663         COMMAND_ID_HANDLER(IDM_TOOLBARS_ADDRESSBAR, OnToggleAddressBandVisible)
664         COMMAND_ID_HANDLER(IDM_TOOLBARS_LINKSBAR, OnToggleLinksBandVisible)
665         COMMAND_ID_HANDLER(IDM_TOOLBARS_TEXTLABELS, OnToggleTextLabels)
666         COMMAND_ID_HANDLER(IDM_TOOLBARS_CUSTOMIZE, OnToolbarCustomize)
667         COMMAND_ID_HANDLER(IDM_EXPLORERBAR_SEARCH, OnExplorerBar)
668         COMMAND_ID_HANDLER(IDM_EXPLORERBAR_FOLDERS, OnExplorerBar)
669         COMMAND_ID_HANDLER(IDM_EXPLORERBAR_HISTORY, OnExplorerBar)
670         COMMAND_ID_HANDLER(IDM_EXPLORERBAR_FAVORITES, OnExplorerBar)
671         COMMAND_ID_HANDLER(IDM_BACKSPACE, OnBackspace)
672         COMMAND_RANGE_HANDLER(IDM_GOTO_TRAVEL_FIRSTTARGET, IDM_GOTO_TRAVEL_LASTTARGET, OnGoTravel)
673         COMMAND_RANGE_HANDLER(IDM_EXPLORERBAND_BEGINCUSTOM, IDM_EXPLORERBAND_ENDCUSTOM, OnExplorerBar)
674         MESSAGE_HANDLER(WM_COMMAND, RelayCommands)
675     END_MSG_MAP()
676 
677     BEGIN_CONNECTION_POINT_MAP(CShellBrowser)
678         CONNECTION_POINT_ENTRY(DIID_DWebBrowserEvents2)
679         CONNECTION_POINT_ENTRY(DIID_DWebBrowserEvents)
680     END_CONNECTION_POINT_MAP()
681 
682     BEGIN_COM_MAP(CShellBrowser)
683         COM_INTERFACE_ENTRY_IID(IID_IDockingWindowSite, IDockingWindowSite)
684         COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
685         COM_INTERFACE_ENTRY2_IID(IID_IOleWindow, IOleWindow, IDockingWindowSite)
686         COM_INTERFACE_ENTRY_IID(IID_IShellBrowser, IShellBrowser)
687         COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget)
688         COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
689         COM_INTERFACE_ENTRY_IID(IID_IProfferService, IProfferService)
690         COM_INTERFACE_ENTRY_IID(IID_IShellBrowserService, IShellBrowserService)
691         COM_INTERFACE_ENTRY_IID(IID_IDispatch, IDispatch)
692         COM_INTERFACE_ENTRY_IID(IID_IConnectionPointContainer, IConnectionPointContainer)
693         COM_INTERFACE_ENTRY_IID(IID_IWebBrowser, IWebBrowser)
694         COM_INTERFACE_ENTRY_IID(IID_IWebBrowserApp, IWebBrowserApp)
695         COM_INTERFACE_ENTRY_IID(IID_IWebBrowser2, IWebBrowser2)
696         COM_INTERFACE_ENTRY_IID(IID_ITravelLogClient, ITravelLogClient)
697         COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist)
698         COM_INTERFACE_ENTRY_IID(IID_IPersistHistory, IPersistHistory)
699         COM_INTERFACE_ENTRY_IID(IID_IBrowserService, IBrowserService)
700         COM_INTERFACE_ENTRY_IID(IID_IBrowserService2, IBrowserService2)
701     END_COM_MAP()
702 };
703 
704 extern HRESULT CreateProgressDialog(REFIID riid, void **ppv);
705 
706 CShellBrowser::CShellBrowser()
707 {
708     fCurrentShellViewWindow = NULL;
709     fCurrentDirectoryPIDL = NULL;
710     fStatusBar = NULL;
711     fStatusBarVisible = true;
712     fCurrentMenuBar = NULL;
713     fHistoryObject = NULL;
714     fHistoryStream = NULL;
715     fHistoryBindContext = NULL;
716 }
717 
718 CShellBrowser::~CShellBrowser()
719 {
720     if (menuDsa)
721         DSA_Destroy(menuDsa);
722 }
723 
724 HRESULT CShellBrowser::Initialize(LPITEMIDLIST pidl, DWORD dwFlags)
725 {
726     CComPtr<IPersistStreamInit>             persistStreamInit;
727     HRESULT                                 hResult;
728     CComPtr<IUnknown> clientBar;
729 
730     _AtlInitialConstruct();
731 
732     menuDsa = DSA_Create(sizeof(MenuBandInfo), 5);
733     if (!menuDsa)
734         return E_OUTOFMEMORY;
735 
736     fCabinetState.cLength = sizeof(fCabinetState);
737     if (ReadCabinetState(&fCabinetState, sizeof(fCabinetState)) == FALSE)
738     {
739     }
740 
741     // create window
742     Create(HWND_DESKTOP);
743     if (m_hWnd == NULL)
744         return E_FAIL;
745 
746     hResult = CInternetToolbar_CreateInstance(IID_PPV_ARG(IUnknown, &clientBar));
747     if (FAILED_UNEXPECTEDLY(hResult))
748         return hResult;
749 
750     fClientBars[BIInternetToolbar].clientBar = clientBar;
751 
752     // create interfaces
753     hResult = clientBar->QueryInterface(IID_PPV_ARG(IPersistStreamInit, &persistStreamInit));
754     if (FAILED_UNEXPECTEDLY(hResult))
755         return hResult;
756 
757     hResult = IUnknown_SetSite(clientBar, static_cast<IShellBrowser *>(this));
758     if (FAILED_UNEXPECTEDLY(hResult))
759         return hResult;
760 
761     hResult = IUnknown_Exec(clientBar, CGID_PrivCITCommands, 1, 1 /* or 0 */, NULL, NULL);
762     if (FAILED_UNEXPECTEDLY(hResult))
763         return hResult;
764 
765     // TODO: create settingsStream from registry entry
766     //if (settingsStream.p)
767     //{
768     //    hResult = persistStreamInit->Load(settingsStream);
769     //    if (FAILED_UNEXPECTEDLY(hResult))
770     //        return hResult;
771     //}
772     //else
773     {
774         hResult = persistStreamInit->InitNew();
775         if (FAILED_UNEXPECTEDLY(hResult))
776             return hResult;
777     }
778 
779     hResult = IUnknown_ShowDW(clientBar, TRUE);
780     if (FAILED_UNEXPECTEDLY(hResult))
781         return hResult;
782 
783     fToolbarProxy.Initialize(m_hWnd, clientBar);
784 
785 
786     // create status bar
787     fStatusBar = CreateWindow(STATUSCLASSNAMEW, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
788                     SBT_NOBORDERS | SBT_TOOLTIPS, 0, 0, 500, 20, m_hWnd, (HMENU)0xa001,
789                     _AtlBaseModule.GetModuleInstance(), 0);
790     fStatusBarVisible = true;
791 
792 
793     // browse
794     hResult = BrowseToPIDL(pidl, BTP_UPDATE_NEXT_HISTORY);
795     if (FAILED_UNEXPECTEDLY(hResult))
796         return hResult;
797 
798     if ((dwFlags & SBSP_EXPLOREMODE) != NULL)
799         ShowBand(CLSID_ExplorerBand, true);
800 
801     ShowWindow(SW_SHOWNORMAL);
802 
803     return S_OK;
804 }
805 
806 HRESULT CShellBrowser::BrowseToPIDL(LPCITEMIDLIST pidl, long flags)
807 {
808     CComPtr<IShellFolder>                   newFolder;
809     FOLDERSETTINGS                          newFolderSettings;
810     HRESULT                                 hResult;
811 
812     // called by shell view to browse to new folder
813     // also called by explorer band to navigate to new folder
814     hResult = SHBindToFolder(pidl, &newFolder);
815     if (FAILED_UNEXPECTEDLY(hResult))
816         return hResult;
817 
818     newFolderSettings.ViewMode = FVM_ICON;
819     newFolderSettings.fFlags = 0;
820     hResult = BrowseToPath(newFolder, pidl, &newFolderSettings, flags);
821     if (FAILED_UNEXPECTEDLY(hResult))
822         return hResult;
823     return S_OK;
824 }
825 
826 BOOL WINAPI _ILIsPidlSimple(LPCITEMIDLIST pidl)
827 {
828     LPCITEMIDLIST                           pidlnext;
829     WORD                                    length;
830     BOOL                                    ret;
831 
832     ret = TRUE;
833     if (! _ILIsDesktop(pidl))
834     {
835         length = pidl->mkid.cb;
836         pidlnext =
837             reinterpret_cast<LPCITEMIDLIST>(
838                 reinterpret_cast<const BYTE *>(pidl) + length);
839         if (pidlnext->mkid.cb != 0)
840             ret = FALSE;
841     }
842     return ret;
843 }
844 
845 HRESULT WINAPI SHBindToFolderIDListParent(IShellFolder *unused, LPCITEMIDLIST pidl,
846     const IID *riid, LPVOID *ppv, LPITEMIDLIST *ppidlLast)
847 {
848     CComPtr<IShellFolder>                   psf;
849     LPITEMIDLIST                            pidlChild;
850     LPITEMIDLIST                            pidlParent;
851     HRESULT                                 hResult;
852 
853     hResult = E_FAIL;
854     if (ppv == NULL)
855         return E_POINTER;
856     *ppv = NULL;
857     if (ppidlLast != NULL)
858         *ppidlLast = NULL;
859     if (_ILIsPidlSimple(pidl))
860     {
861         if (ppidlLast != NULL)
862             *ppidlLast = ILClone(pidl);
863         hResult = SHGetDesktopFolder((IShellFolder **)ppv);
864     }
865     else
866     {
867         pidlChild = ILClone(ILFindLastID(pidl));
868         pidlParent = ILClone(pidl);
869         ILRemoveLastID(pidlParent);
870         hResult = SHGetDesktopFolder(&psf);
871         if (SUCCEEDED(hResult))
872             hResult = psf->BindToObject(pidlParent, NULL, *riid, ppv);
873         if (SUCCEEDED(hResult) && ppidlLast != NULL)
874             *ppidlLast = pidlChild;
875         else
876             ILFree(pidlChild);
877         ILFree(pidlParent);
878     }
879     return hResult;
880 }
881 
882 HRESULT IEGetNameAndFlagsEx(LPITEMIDLIST pidl, SHGDNF uFlags, long param10,
883     LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
884 {
885     CComPtr<IShellFolder>                   parentFolder;
886     LPITEMIDLIST                            childPIDL = NULL;
887     STRRET                                  L108;
888     HRESULT                                 hResult;
889 
890     hResult = SHBindToFolderIDListParent(NULL, pidl, &IID_PPV_ARG(IShellFolder, &parentFolder), &childPIDL);
891     if (FAILED(hResult))
892         goto cleanup;
893 
894     hResult = parentFolder->GetDisplayNameOf(childPIDL, uFlags, &L108);
895     if (FAILED(hResult))
896         goto cleanup;
897 
898     StrRetToBufW(&L108, childPIDL, pszBuf, cchBuf);
899     if (rgfInOut)
900     {
901         hResult = parentFolder->GetAttributesOf(1, const_cast<LPCITEMIDLIST *>(&childPIDL), rgfInOut);
902         if (FAILED(hResult))
903             goto cleanup;
904     }
905 
906     hResult = S_OK;
907 
908 cleanup:
909     if (childPIDL)
910         ILFree(childPIDL);
911     return hResult;
912 }
913 
914 long IEGetNameAndFlags(LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
915 {
916     return IEGetNameAndFlagsEx(pidl, uFlags, 0, pszBuf, cchBuf, rgfInOut);
917 }
918 
919 HRESULT CShellBrowser::BrowseToPath(IShellFolder *newShellFolder,
920     LPCITEMIDLIST absolutePIDL, FOLDERSETTINGS *folderSettings, long flags)
921 {
922     CComPtr<IObjectWithSite>                objectWithSite;
923     CComPtr<IShellFolder>                   saveCurrentShellFolder;
924     CComPtr<IShellView>                     saveCurrentShellView;
925     CComPtr<IShellView>                     newShellView;
926     CComPtr<ITravelLog>                     travelLog;
927     HWND                                    newShellViewWindow;
928     BOOL                                    windowUpdateIsLocked;
929     RECT                                    shellViewWindowBounds;
930     HWND                                    previousView;
931     HCURSOR                                 saveCursor;
932     wchar_t                                 newTitle[MAX_PATH];
933     SHGDNF                                  nameFlags;
934     HRESULT                                 hResult;
935 
936     if (newShellFolder == NULL)
937         return E_INVALIDARG;
938 
939     hResult = GetTravelLog(&travelLog);
940     if (FAILED_UNEXPECTEDLY(hResult))
941         return hResult;
942 
943     // update history
944     if (flags & BTP_UPDATE_CUR_HISTORY)
945     {
946         if (travelLog->CountEntries(static_cast<IDropTarget *>(this)) > 0)
947             hResult = travelLog->UpdateEntry(static_cast<IDropTarget *>(this), FALSE);
948         // what to do with error? Do we want to halt browse because state save failed?
949     }
950 
951     if (fCurrentShellView)
952     {
953         fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
954     }
955 
956     // create view object
957     hResult = newShellFolder->CreateViewObject(m_hWnd, IID_PPV_ARG(IShellView, &newShellView));
958     if (FAILED_UNEXPECTEDLY(hResult))
959         return hResult;
960     previousView = fCurrentShellViewWindow;
961 
962     // enter updating section
963     saveCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
964     windowUpdateIsLocked = LockWindowUpdate(TRUE);
965     if (fCurrentShellView != NULL)
966         ::SendMessage(fCurrentShellViewWindow, WM_SETREDRAW, 0, 0);
967 
968     // set site
969     hResult = IUnknown_SetSite(newShellView, static_cast<IDropTarget *>(this));
970 
971     // update folder and view
972     saveCurrentShellFolder = fCurrentShellFolder;
973     saveCurrentShellView = fCurrentShellView;
974     fCurrentShellFolder = newShellFolder;
975     fCurrentShellView = newShellView;
976 
977     // get boundary
978     if (previousView != NULL)
979         ::GetWindowRect(previousView, &shellViewWindowBounds);
980     else
981         ZeroMemory(&shellViewWindowBounds, sizeof(shellViewWindowBounds));
982     ::MapWindowPoints(0, m_hWnd, reinterpret_cast<POINT *>(&shellViewWindowBounds), 2);
983 
984     // create view window
985     hResult = newShellView->CreateViewWindow(saveCurrentShellView, folderSettings,
986         this, &shellViewWindowBounds, &newShellViewWindow);
987     if (FAILED_UNEXPECTEDLY(hResult) || newShellViewWindow == NULL)
988     {
989         fCurrentShellView = saveCurrentShellView;
990         fCurrentShellFolder = saveCurrentShellFolder;
991         ::SendMessage(fCurrentShellViewWindow, WM_SETREDRAW, 1, 0);
992         if (windowUpdateIsLocked)
993             LockWindowUpdate(FALSE);
994         SetCursor(saveCursor);
995         return hResult;
996     }
997 
998     if (objectWithSite.p != NULL)
999         hResult = objectWithSite->SetSite(NULL);
1000 
1001     // update current pidl
1002     ILFree(fCurrentDirectoryPIDL);
1003     fCurrentDirectoryPIDL = ILClone(absolutePIDL);
1004 
1005     // update view window
1006     if (saveCurrentShellView != NULL)
1007         saveCurrentShellView->DestroyViewWindow();
1008     fCurrentShellViewWindow = newShellViewWindow;
1009 
1010     // no use
1011     saveCurrentShellView.Release();
1012     saveCurrentShellFolder.Release();
1013 
1014     hResult = newShellView->UIActivate(SVUIA_ACTIVATE_FOCUS);
1015 
1016     // leave updating section
1017     if (windowUpdateIsLocked)
1018         LockWindowUpdate(FALSE);
1019     SetCursor(saveCursor);
1020 
1021     // update history
1022     if (flags & BTP_UPDATE_NEXT_HISTORY)
1023     {
1024         hResult = travelLog->AddEntry(static_cast<IDropTarget *>(this), FALSE);
1025         hResult = travelLog->UpdateEntry(static_cast<IDropTarget *>(this), FALSE);
1026     }
1027 
1028     // completed
1029     nameFlags = SHGDN_FORADDRESSBAR | SHGDN_FORPARSING;
1030     hResult = IEGetNameAndFlags(fCurrentDirectoryPIDL, nameFlags, newTitle,
1031         sizeof(newTitle) / sizeof(wchar_t), NULL);
1032     if (SUCCEEDED(hResult))
1033     {
1034         FireNavigateComplete(newTitle);
1035     }
1036     else
1037     {
1038         FireNavigateComplete(L"ERROR");
1039     }
1040 
1041     if (fCabinetState.fFullPathTitle)
1042         nameFlags = SHGDN_FORADDRESSBAR | SHGDN_FORPARSING;
1043     else
1044         nameFlags = SHGDN_FORADDRESSBAR;
1045     hResult = IEGetNameAndFlags(fCurrentDirectoryPIDL, nameFlags, newTitle,
1046         sizeof(newTitle) / sizeof(wchar_t), NULL);
1047     if (SUCCEEDED(hResult))
1048     {
1049         SetWindowText(newTitle);
1050 
1051         LPCITEMIDLIST pidlChild;
1052         INT index, indexOpen;
1053         HIMAGELIST himlSmall, himlLarge;
1054 
1055         CComPtr<IShellFolder> sf;
1056         hResult = SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
1057         if (SUCCEEDED(hResult))
1058         {
1059             index = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
1060 
1061             Shell_GetImageLists(&himlLarge, &himlSmall);
1062 
1063             HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
1064             HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
1065 
1066             /* Hack to make it possible to release the old icons */
1067             /* Something seems to go wrong with WM_SETICON */
1068             HICON oldSmall = (HICON)SendMessage(WM_GETICON, ICON_SMALL, 0);
1069             HICON oldLarge = (HICON)SendMessage(WM_GETICON, ICON_BIG,   0);
1070 
1071             SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icSmall));
1072             SendMessage(WM_SETICON, ICON_BIG,   reinterpret_cast<LPARAM>(icLarge));
1073 
1074             DestroyIcon(oldSmall);
1075             DestroyIcon(oldLarge);
1076         }
1077     }
1078 
1079     FireCommandStateChangeAll();
1080     hResult = UpdateForwardBackState();
1081     hResult = UpdateUpState();
1082     return S_OK;
1083 }
1084 
1085 HRESULT CShellBrowser::GetMenuBand(REFIID riid, void **shellMenu)
1086 {
1087     CComPtr<IBandSite>                      bandSite;
1088     CComPtr<IDeskBand>                      deskBand;
1089     HRESULT                                 hResult;
1090 
1091     if (!fClientBars[BIInternetToolbar].clientBar)
1092         return E_FAIL;
1093 
1094     hResult = IUnknown_QueryService(fClientBars[BIInternetToolbar].clientBar, SID_IBandSite, IID_PPV_ARG(IBandSite, &bandSite));
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 
1105 HRESULT 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)
1115         cache = &fClientBars[BIVerticalBaseBar].clientBar.p;
1116     else
1117         cache = &fClientBars[BIHorizontalBaseBar].clientBar.p;
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         newBaseBar->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 
1156 BOOL 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 
1205 HRESULT 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");
1233             hResult = CExplorerBand_CreateInstance(IID_PPV_ARG(IUnknown, &newBand));
1234             if (FAILED_UNEXPECTEDLY(hResult))
1235                 return hResult;
1236         }
1237         else
1238         {
1239             TRACE("A different CLSID requested, using CoCreateInstance.\n");
1240             hResult = CoCreateInstance(classID, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IUnknown, &newBand));
1241             if (FAILED_UNEXPECTEDLY(hResult))
1242                 return hResult;
1243         }
1244     }
1245     else
1246     {
1247         CComPtr<IBandSite>                  pBandSite;
1248 
1249         hResult = baseBarSite->QueryInterface(IID_PPV_ARG(IBandSite, &pBandSite));
1250         if (!SUCCEEDED(hResult))
1251         {
1252             ERR("Can't get IBandSite interface\n");
1253             return E_FAIL;
1254         }
1255         hResult = pBandSite->GetBandObject(dwBandID, IID_PPV_ARG(IUnknown, &newBand));
1256         if (!SUCCEEDED(hResult))
1257         {
1258             ERR("Can't find band object\n");
1259             return E_FAIL;
1260         }
1261 
1262         // It's hackish, but we should be able to show the wanted band until we
1263         // find the proper way to do this (but it seems to work to add a new band)
1264         // Here we'll just re-add the existing band to the site, causing it to display.
1265     }
1266     V_VT(&vaIn) = VT_UNKNOWN;
1267     V_UNKNOWN(&vaIn) = newBand.p;
1268     hResult = IUnknown_Exec(baseBarSite, CGID_IDeskBand, 1, 1, &vaIn, NULL);
1269     if (FAILED_UNEXPECTEDLY(hResult))
1270     {
1271         return hResult;
1272     }
1273 
1274     hResult = dockingWindow->ShowDW(TRUE);
1275     if (FAILED_UNEXPECTEDLY(hResult))
1276         return hResult;
1277 
1278     return S_OK;
1279 }
1280 
1281 HRESULT CShellBrowser::NavigateToParent()
1282 {
1283     LPITEMIDLIST newDirectory = ILClone(fCurrentDirectoryPIDL);
1284     if (newDirectory == NULL)
1285         return E_OUTOFMEMORY;
1286     if (_ILIsDesktop(newDirectory))
1287     {
1288         ILFree(newDirectory);
1289         return E_INVALIDARG;
1290     }
1291     ILRemoveLastID(newDirectory);
1292     HRESULT hResult = BrowseToPIDL(newDirectory, BTP_UPDATE_CUR_HISTORY | BTP_UPDATE_NEXT_HISTORY);
1293     ILFree(newDirectory);
1294     if (FAILED_UNEXPECTEDLY(hResult))
1295         return hResult;
1296     return S_OK;
1297 }
1298 
1299 BOOL CALLBACK AddFolderOptionsPage(HPROPSHEETPAGE thePage, LPARAM lParam)
1300 {
1301     PROPSHEETHEADER* sheetInfo = reinterpret_cast<PROPSHEETHEADER*>(lParam);
1302     if (sheetInfo->nPages >= folderOptionsPageCountMax)
1303         return FALSE;
1304     sheetInfo->phpage[sheetInfo->nPages] = thePage;
1305     sheetInfo->nPages++;
1306     return TRUE;
1307 }
1308 
1309 HRESULT CShellBrowser::DoFolderOptions()
1310 {
1311     CComPtr<IShellPropSheetExt>             folderOptionsSheet;
1312     PROPSHEETHEADER                         m_PropSheet;
1313     HPROPSHEETPAGE                          m_psp[folderOptionsPageCountMax];
1314 //    CComPtr<IGlobalFolderSettings>          globalSettings;
1315 //    SHELLSTATE2                             shellState;
1316     HRESULT                                 hResult;
1317 
1318     memset(m_psp, 0, sizeof(m_psp));
1319     memset(&m_PropSheet, 0, sizeof(m_PropSheet));
1320 
1321     // create sheet object
1322     hResult = CoCreateInstance(CLSID_ShellFldSetExt, NULL, CLSCTX_INPROC_SERVER,
1323         IID_PPV_ARG(IShellPropSheetExt, &folderOptionsSheet));
1324     if (FAILED_UNEXPECTEDLY(hResult))
1325         return E_FAIL;
1326 
1327     // must set site in order for Apply to all Folders on Advanced page to be enabled
1328     hResult = IUnknown_SetSite(folderOptionsSheet, static_cast<IDispatch *>(this));
1329     m_PropSheet.phpage = m_psp;
1330 
1331 #if 0
1332     hResult = CoCreateInstance(CLSID_GlobalFolderSettings, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IGlobalFolderSettings, &globalSettings));
1333     if (FAILED_UNEXPECTEDLY(hResult))
1334         return E_FAIL;
1335     hResult = globalSettings->Get(&shellState, sizeof(shellState));
1336     if (FAILED_UNEXPECTEDLY(hResult))
1337         return E_FAIL;
1338 #endif
1339 
1340     // add pages
1341     hResult = folderOptionsSheet->AddPages(AddFolderOptionsPage, reinterpret_cast<LPARAM>(&m_PropSheet));
1342     if (FAILED_UNEXPECTEDLY(hResult))
1343         return E_FAIL;
1344 
1345 // CORE-11140 : Disabled this bit, because it prevents the folder options from showing.
1346 //              It returns 'E_NOTIMPL'
1347 #if 0
1348     if (fCurrentShellView != NULL)
1349     {
1350         hResult = fCurrentShellView->AddPropertySheetPages(
1351             0, AddFolderOptionsPage, reinterpret_cast<LPARAM>(&m_PropSheet));
1352         if (FAILED_UNEXPECTEDLY(hResult))
1353             return E_FAIL;
1354     }
1355 #endif
1356 
1357     // show sheet
1358     m_PropSheet.dwSize = sizeof(PROPSHEETHEADER);
1359     m_PropSheet.dwFlags = 0;
1360     m_PropSheet.hwndParent = m_hWnd;
1361     m_PropSheet.hInstance = _AtlBaseModule.GetResourceInstance();
1362     m_PropSheet.pszCaption = _T("Folder Options");
1363     m_PropSheet.nStartPage = 0;
1364     PropertySheet(&m_PropSheet);
1365     return S_OK;
1366 }
1367 
1368 LRESULT CALLBACK CShellBrowser::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1369 {
1370     CShellBrowser                           *pThis = reinterpret_cast<CShellBrowser *>(hWnd);
1371     _ATL_MSG                                msg(pThis->m_hWnd, uMsg, wParam, lParam);
1372     LRESULT                                 lResult;
1373     const _ATL_MSG                          *previousMessage;
1374     BOOL                                    handled;
1375     WNDPROC                                 saveWindowProc;
1376     HRESULT                                 hResult;
1377 
1378     hWnd = pThis->m_hWnd;
1379     previousMessage = pThis->m_pCurrentMsg;
1380     pThis->m_pCurrentMsg = &msg;
1381 
1382     /* If the shell browser is initialized, let the menu band preprocess the messages */
1383     if (pThis->fCurrentDirectoryPIDL)
1384     {
1385         CComPtr<IMenuBand> menuBand;
1386         hResult = pThis->GetMenuBand(IID_PPV_ARG(IMenuBand, &menuBand));
1387         if (SUCCEEDED(hResult) && menuBand.p != NULL)
1388         {
1389             hResult = menuBand->TranslateMenuMessage(&msg, &lResult);
1390             if (hResult == S_OK)
1391                 return lResult;
1392             uMsg = msg.message;
1393             wParam = msg.wParam;
1394             lParam = msg.lParam;
1395         }
1396         menuBand.Release();
1397     }
1398 
1399     handled = pThis->ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, 0);
1400     ATLASSERT(pThis->m_pCurrentMsg == &msg);
1401     if (handled == FALSE)
1402     {
1403         if (uMsg == WM_NCDESTROY)
1404         {
1405             saveWindowProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hWnd, GWLP_WNDPROC));
1406             lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1407             if (saveWindowProc == reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hWnd, GWLP_WNDPROC)))
1408                 ::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)pThis->m_pfnSuperWindowProc);
1409             pThis->m_dwState |= WINSTATE_DESTROYED;
1410         }
1411         else
1412             lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1413     }
1414     pThis->m_pCurrentMsg = previousMessage;
1415     if (previousMessage == NULL && (pThis->m_dwState & WINSTATE_DESTROYED) != 0)
1416     {
1417         pThis->m_dwState &= ~WINSTATE_DESTROYED;
1418         pThis->m_hWnd = NULL;
1419         pThis->OnFinalMessage(hWnd);
1420     }
1421     return lResult;
1422 }
1423 
1424 void CShellBrowser::RepositionBars()
1425 {
1426     RECT                                    clientRect;
1427     RECT                                    statusRect;
1428     int                                     x;
1429 
1430     GetClientRect(&clientRect);
1431 
1432     if (fStatusBarVisible && fStatusBar)
1433     {
1434         ::GetWindowRect(fStatusBar, &statusRect);
1435         ::SetWindowPos(fStatusBar, NULL, clientRect.left, clientRect.bottom - (statusRect.bottom - statusRect.top),
1436                             clientRect.right - clientRect.left,
1437                             statusRect.bottom - statusRect.top, SWP_NOOWNERZORDER | SWP_NOZORDER);
1438         clientRect.bottom -= statusRect.bottom - statusRect.top;
1439     }
1440 
1441     for (x = 0; x < 3; x++)
1442     {
1443         HWND hwnd = fClientBars[x].hwnd;
1444         RECT borderSpace = fClientBars[x].borderSpace;
1445         if (hwnd == NULL && fClientBars[x].clientBar != NULL)
1446         {
1447             IUnknown_GetWindow(fClientBars[x].clientBar, &hwnd);
1448             fClientBars[x].hwnd = hwnd;
1449         }
1450         if (hwnd != NULL)
1451         {
1452             RECT toolbarRect = clientRect;
1453             if (borderSpace.top != 0)
1454             {
1455                 toolbarRect.bottom = toolbarRect.top + borderSpace.top;
1456             }
1457             else if (borderSpace.bottom != 0)
1458             {
1459                 toolbarRect.top = toolbarRect.bottom - borderSpace.bottom;
1460             }
1461             else if (borderSpace.left != 0)
1462             {
1463                 toolbarRect.right = toolbarRect.left + borderSpace.left;
1464             }
1465             else if (borderSpace.right != 0)
1466             {
1467                 toolbarRect.left = toolbarRect.right - borderSpace.right;
1468             }
1469 
1470             ::SetWindowPos(hwnd, NULL,
1471                 toolbarRect.left,
1472                 toolbarRect.top,
1473                 toolbarRect.right - toolbarRect.left,
1474                 toolbarRect.bottom - toolbarRect.top,
1475                 SWP_NOOWNERZORDER | SWP_NOZORDER);
1476 
1477             if (borderSpace.top != 0)
1478             {
1479                 clientRect.top = toolbarRect.bottom;
1480             }
1481             else if (borderSpace.bottom != 0)
1482             {
1483                 clientRect.bottom = toolbarRect.top;
1484             }
1485             else if (borderSpace.left != 0)
1486             {
1487                 clientRect.left = toolbarRect.right;
1488             }
1489             else if (borderSpace.right != 0)
1490             {
1491                 clientRect.right = toolbarRect.left;
1492             }
1493         }
1494     }
1495     ::SetWindowPos(fCurrentShellViewWindow, NULL, clientRect.left, clientRect.top,
1496                         clientRect.right - clientRect.left,
1497                         clientRect.bottom - clientRect.top, SWP_NOOWNERZORDER | SWP_NOZORDER);
1498 }
1499 
1500 HRESULT CShellBrowser::FireEvent(DISPID dispIdMember, int argCount, VARIANT *arguments)
1501 {
1502     DISPPARAMS                          params;
1503     CComDynamicUnkArray                 &vec = IConnectionPointImpl<CShellBrowser, &DIID_DWebBrowserEvents2>::m_vec;
1504     CComDynamicUnkArray                 &vec2 = IConnectionPointImpl<CShellBrowser, &DIID_DWebBrowserEvents>::m_vec;
1505     HRESULT                             hResult;
1506 
1507     params.rgvarg = arguments;
1508     params.rgdispidNamedArgs = NULL;
1509     params.cArgs = argCount;
1510     params.cNamedArgs = 0;
1511     IUnknown** pp = vec.begin();
1512     while (pp < vec.end())
1513     {
1514         if (*pp != NULL)
1515         {
1516             CComPtr<IDispatch>          theDispatch;
1517 
1518             hResult = (*pp)->QueryInterface(IID_PPV_ARG(IDispatch, &theDispatch));
1519             hResult = theDispatch->Invoke(dispIdMember, GUID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, NULL);
1520         }
1521         pp++;
1522     }
1523     pp = vec2.begin();
1524     while (pp < vec2.end())
1525     {
1526         if (*pp != NULL)
1527         {
1528             CComPtr<IDispatch>          theDispatch;
1529 
1530             hResult = (*pp)->QueryInterface(IID_PPV_ARG(IDispatch, &theDispatch));
1531             hResult = theDispatch->Invoke(dispIdMember, GUID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, NULL);
1532         }
1533         pp++;
1534     }
1535     return S_OK;
1536 }
1537 
1538 HRESULT CShellBrowser::FireNavigateComplete(const wchar_t *newDirectory)
1539 {
1540     // these two variants intentionally to do use CComVariant because it would double free/release
1541     // or does not need to dispose at all
1542     VARIANT                             varArg[2];
1543     VARIANT                             varArgs;
1544     CComBSTR                            tempString(newDirectory);
1545 
1546     V_VT(&varArgs) = VT_BSTR;
1547     V_BSTR(&varArgs) = tempString.m_str;
1548 
1549     V_VT(&varArg[0]) = VT_VARIANT | VT_BYREF;
1550     V_VARIANTREF(&varArg[0]) = &varArgs;
1551     V_VT(&varArg[1]) = VT_DISPATCH;
1552     V_DISPATCH(&varArg[1]) = (IDispatch *)this;
1553 
1554     return FireEvent(DISPID_NAVIGATECOMPLETE2, 2, varArg);
1555 }
1556 
1557 HRESULT CShellBrowser::FireCommandStateChange(bool newState, int commandID)
1558 {
1559     VARIANT                             varArg[2];
1560 
1561     V_VT(&varArg[0]) = VT_BOOL;
1562     V_BOOL(&varArg[0]) = newState ? VARIANT_TRUE : VARIANT_FALSE;
1563     V_VT(&varArg[1]) = VT_I4;
1564     V_I4(&varArg[1]) = commandID;
1565 
1566     return FireEvent(DISPID_COMMANDSTATECHANGE, 2, varArg);
1567 }
1568 
1569 HRESULT CShellBrowser::FireCommandStateChangeAll()
1570 {
1571     return FireCommandStateChange(false, -1);
1572 }
1573 
1574 HRESULT CShellBrowser::UpdateForwardBackState()
1575 {
1576     CComPtr<ITravelLog>                     travelLog;
1577     CComPtr<ITravelEntry>                   unusedEntry;
1578     bool                                    canGoBack;
1579     bool                                    canGoForward;
1580     HRESULT                                 hResult;
1581 
1582     canGoBack = false;
1583     canGoForward = false;
1584     hResult = GetTravelLog(&travelLog);
1585     if (FAILED_UNEXPECTEDLY(hResult))
1586         return hResult;
1587     hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this), TLOG_BACK, &unusedEntry);
1588     if (SUCCEEDED(hResult))
1589     {
1590         canGoBack = true;
1591         unusedEntry.Release();
1592     }
1593     hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this), TLOG_FORE, &unusedEntry);
1594     if (SUCCEEDED(hResult))
1595     {
1596         canGoForward = true;
1597         unusedEntry.Release();
1598     }
1599     hResult = FireCommandStateChange(canGoBack, 2);
1600     hResult = FireCommandStateChange(canGoForward, 1);
1601     return S_OK;
1602 }
1603 
1604 HRESULT CShellBrowser::UpdateUpState()
1605 {
1606     bool canGoUp;
1607     HRESULT hResult;
1608 
1609     canGoUp = true;
1610     if (_ILIsDesktop(fCurrentDirectoryPIDL))
1611         canGoUp = false;
1612     hResult = FireCommandStateChange(canGoUp, 3);
1613     return S_OK;
1614 }
1615 
1616 void CShellBrowser::UpdateGotoMenu(HMENU theMenu)
1617 {
1618     CComPtr<ITravelLog>                     travelLog;
1619     CComPtr<ITravelEntry>                   unusedEntry;
1620     int                                     position;
1621     MENUITEMINFO                            menuItemInfo;
1622     HRESULT                                 hResult;
1623 
1624     DeleteMenuItems(theMenu, IDM_GOTO_TRAVEL_FIRST, IDM_GOTO_TRAVEL_LAST);
1625 
1626     position = GetMenuItemCount(theMenu);
1627     hResult = GetTravelLog(&travelLog);
1628     if (FAILED_UNEXPECTEDLY(hResult))
1629         return;
1630 
1631     hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this),
1632                                         TLOG_BACK,
1633                                         &unusedEntry);
1634 
1635     if (SUCCEEDED(hResult))
1636     {
1637         SHEnableMenuItem(theMenu, IDM_GOTO_BACK, TRUE);
1638         unusedEntry.Release();
1639     }
1640     else
1641         SHEnableMenuItem(theMenu, IDM_GOTO_BACK, FALSE);
1642 
1643     hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this),
1644                                         TLOG_FORE,
1645                                         &unusedEntry);
1646 
1647     if (SUCCEEDED(hResult))
1648     {
1649         SHEnableMenuItem(theMenu, IDM_GOTO_FORWARD, TRUE);
1650         unusedEntry.Release();
1651     }
1652     else
1653         SHEnableMenuItem(theMenu, IDM_GOTO_FORWARD, FALSE);
1654 
1655     SHEnableMenuItem(theMenu,
1656                      IDM_GOTO_UPONELEVEL,
1657                      !_ILIsDesktop(fCurrentDirectoryPIDL));
1658 
1659     hResult = travelLog->InsertMenuEntries(static_cast<IDropTarget *>(this), theMenu, position,
1660         IDM_GOTO_TRAVEL_FIRSTTARGET, IDM_GOTO_TRAVEL_LASTTARGET, TLMENUF_BACKANDFORTH | TLMENUF_CHECKCURRENT);
1661     if (SUCCEEDED(hResult))
1662     {
1663         menuItemInfo.cbSize = sizeof(menuItemInfo);
1664         menuItemInfo.fMask = MIIM_TYPE | MIIM_ID;
1665         menuItemInfo.fType = MF_SEPARATOR;
1666         menuItemInfo.wID = IDM_GOTO_TRAVEL_SEP;
1667         InsertMenuItem(theMenu, position, TRUE, &menuItemInfo);
1668     }
1669 }
1670 
1671 void CShellBrowser::UpdateViewMenu(HMENU theMenu)
1672 {
1673     CComPtr<ITravelLog>                     travelLog;
1674     HMENU                                   gotoMenu;
1675     OLECMD                                  commandList[5];
1676     HMENU                                   toolbarMenuBar;
1677     HMENU                                   toolbarMenu;
1678     MENUITEMINFO                            menuItemInfo;
1679     HRESULT                                 hResult;
1680 
1681     gotoMenu = SHGetMenuFromID(theMenu, FCIDM_MENU_EXPLORE);
1682     if (gotoMenu != NULL)
1683         UpdateGotoMenu(gotoMenu);
1684 
1685     commandList[0].cmdID = ITID_TOOLBARBANDSHOWN;
1686     commandList[1].cmdID = ITID_ADDRESSBANDSHOWN;
1687     commandList[2].cmdID = ITID_LINKSBANDSHOWN;
1688     commandList[3].cmdID = ITID_TOOLBARLOCKED;
1689     commandList[4].cmdID = ITID_CUSTOMIZEENABLED;
1690 
1691     hResult = IUnknown_QueryStatus(fClientBars[BIInternetToolbar].clientBar,
1692                                    CGID_PrivCITCommands, 5, commandList, NULL);
1693     if (FAILED_UNEXPECTEDLY(hResult))
1694         DeleteMenu(theMenu, IDM_VIEW_TOOLBARS, MF_BYCOMMAND);
1695     else
1696     {
1697         menuItemInfo.cbSize = sizeof(menuItemInfo);
1698         menuItemInfo.fMask = MIIM_SUBMENU;
1699         GetMenuItemInfo(theMenu, IDM_VIEW_TOOLBARS, FALSE, &menuItemInfo);
1700         DestroyMenu(menuItemInfo.hSubMenu);
1701 
1702         toolbarMenuBar = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_CONTEXTMENU));
1703         toolbarMenu = GetSubMenu(toolbarMenuBar, 0);
1704         RemoveMenu(toolbarMenuBar, 0, MF_BYPOSITION);
1705         DestroyMenu(toolbarMenuBar);
1706 
1707         // TODO: Implement
1708         SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_STANDARDBUTTONS, commandList[0].cmdf & OLECMDF_ENABLED);
1709         SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_ADDRESSBAR, commandList[1].cmdf & OLECMDF_ENABLED);
1710         SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_LINKSBAR, commandList[2].cmdf & OLECMDF_ENABLED);
1711         SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_CUSTOMIZE, commandList[4].cmdf & OLECMDF_ENABLED);
1712 
1713         SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_STANDARDBUTTONS, commandList[0].cmdf & OLECMDF_LATCHED);
1714         SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_ADDRESSBAR, commandList[1].cmdf & OLECMDF_LATCHED);
1715         SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_LINKSBAR, commandList[2].cmdf & OLECMDF_LATCHED);
1716         SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_LOCKTOOLBARS, commandList[3].cmdf & OLECMDF_LATCHED);
1717         if ((commandList[4].cmdf & OLECMDF_ENABLED) == 0)
1718             DeleteMenu(toolbarMenu, IDM_TOOLBARS_CUSTOMIZE, MF_BYCOMMAND);
1719         DeleteMenu(toolbarMenu, IDM_TOOLBARS_TEXTLABELS, MF_BYCOMMAND);
1720         DeleteMenu(toolbarMenu, IDM_TOOLBARS_GOBUTTON, MF_BYCOMMAND);
1721 
1722         menuItemInfo.cbSize = sizeof(menuItemInfo);
1723         menuItemInfo.fMask = MIIM_SUBMENU;
1724         menuItemInfo.hSubMenu = toolbarMenu;
1725         SetMenuItemInfo(theMenu, IDM_VIEW_TOOLBARS, FALSE, &menuItemInfo);
1726     }
1727     SHCheckMenuItem(theMenu, IDM_VIEW_STATUSBAR, fStatusBarVisible ? TRUE : FALSE);
1728 }
1729 
1730 HRESULT CShellBrowser::BuildExplorerBandMenu()
1731 {
1732     HMENU                                   hBandsMenu;
1733     UINT                                    nbFound;
1734 
1735     hBandsMenu = SHGetMenuFromID(fCurrentMenuBar, IDM_VIEW_EXPLORERBAR);
1736     if (!hBandsMenu)
1737     {
1738         OutputDebugString(L"No menu !\n");
1739         return E_FAIL;
1740     }
1741     DSA_DeleteAllItems(menuDsa);
1742     BuildExplorerBandCategory(hBandsMenu, CATID_InfoBand, 4, NULL);
1743     BuildExplorerBandCategory(hBandsMenu, CATID_CommBand, 20, &nbFound);
1744     if (!nbFound)
1745     {
1746         // Remove separator
1747         DeleteMenu(hBandsMenu, IDM_EXPLORERBAR_SEPARATOR, MF_BYCOMMAND);
1748     }
1749     // Remove media menu since XP does it (according to API Monitor)
1750     DeleteMenu(hBandsMenu, IDM_EXPLORERBAR_MEDIA, MF_BYCOMMAND);
1751     return S_OK;
1752 }
1753 
1754 HRESULT CShellBrowser::BuildExplorerBandCategory(HMENU hBandsMenu, CATID category, DWORD dwPos, UINT *nbFound)
1755 {
1756     HRESULT                                 hr;
1757     CComPtr<IEnumGUID>                      pEnumGUID;
1758     WCHAR                                   wszBandName[MAX_PATH];
1759     WCHAR                                   wszBandGUID[MAX_PATH];
1760     WCHAR                                   wRegKey[MAX_PATH];
1761     UINT                                    cBands;
1762     DWORD                                   dwRead;
1763     DWORD                                   dwDataSize;
1764     GUID                                    iter;
1765     MenuBandInfo                            mbi;
1766 
1767     mbi.fVertical = IsEqualGUID(category, CATID_InfoBand);
1768     cBands = 0;
1769     hr = SHEnumClassesOfCategories(1, &category, 0, NULL, &pEnumGUID);
1770     if (FAILED_UNEXPECTEDLY(hr))
1771     {
1772         return hr;
1773     }
1774     do
1775     {
1776         pEnumGUID->Next(1, &iter, &dwRead);
1777         if (dwRead)
1778         {
1779             // Get the band name
1780             if (IsBuiltinBand(iter))
1781                 continue;
1782             if (!StringFromGUID2(iter, wszBandGUID, MAX_PATH))
1783                 continue;
1784             StringCchPrintfW(wRegKey, MAX_PATH, L"CLSID\\%s", wszBandGUID);
1785             dwDataSize = MAX_PATH;
1786             SHGetValue(HKEY_CLASSES_ROOT, wRegKey, NULL, NULL, wszBandName, &dwDataSize);
1787 
1788             mbi.barGuid = iter;
1789             InsertMenu(hBandsMenu, dwPos + cBands, MF_BYPOSITION, IDM_EXPLORERBAND_BEGINCUSTOM + DSA_GetItemCount(menuDsa), wszBandName);
1790             DSA_AppendItem(menuDsa, &mbi);
1791             cBands++;
1792         }
1793     }
1794     while (dwRead > 0);
1795     if (nbFound)
1796         *nbFound = cBands;
1797     return S_OK;
1798 }
1799 
1800 BOOL CShellBrowser::IsBuiltinBand(CLSID &bandID)
1801 {
1802     if (IsEqualCLSID(bandID, CLSID_ExplorerBand))
1803         return TRUE;
1804     if (IsEqualCLSID(bandID, CLSID_SH_SearchBand) || IsEqualCLSID(bandID, CLSID_SearchBand))
1805         return TRUE;
1806     if (IsEqualCLSID(bandID, CLSID_IE_SearchBand) || IsEqualCLSID(bandID, CLSID_FileSearchBand))
1807         return TRUE;
1808     if (IsEqualCLSID(bandID, CLSID_SH_HistBand))
1809         return TRUE;
1810     if (IsEqualCLSID(bandID, CLSID_SH_FavBand))
1811         return TRUE;
1812     if (IsEqualCLSID(bandID, CLSID_ChannelsBand))
1813         return TRUE;
1814     return FALSE;
1815 }
1816 
1817 HRESULT CShellBrowser::OnSearch()
1818 {
1819     CComPtr<IObjectWithSite>                objectWithSite;
1820     CComPtr<IContextMenu>                   contextMenu;
1821     CMINVOKECOMMANDINFO                     commandInfo;
1822     const char                              *searchGUID = "{169A0691-8DF9-11d1-A1C4-00C04FD75D13}";
1823     HRESULT                                 hResult;
1824 
1825     // TODO: Query shell if this command is enabled first
1826 
1827     memset(&commandInfo, 0, sizeof(commandInfo));
1828     commandInfo.cbSize = sizeof(commandInfo);
1829     commandInfo.hwnd = m_hWnd;
1830     commandInfo.lpParameters = searchGUID;
1831     commandInfo.nShow = SW_SHOWNORMAL;
1832 
1833     hResult = CoCreateInstance(CLSID_ShellSearchExt, NULL, CLSCTX_INPROC_SERVER,
1834         IID_PPV_ARG(IContextMenu, &contextMenu));
1835     if (FAILED_UNEXPECTEDLY(hResult))
1836         return 0;
1837     hResult = contextMenu->QueryInterface(IID_PPV_ARG(IObjectWithSite, &objectWithSite));
1838     if (FAILED_UNEXPECTEDLY(hResult))
1839         return 0;
1840     hResult = objectWithSite->SetSite(dynamic_cast<IShellBrowser*>(this));
1841     if (FAILED_UNEXPECTEDLY(hResult))
1842         return 0;
1843     hResult = contextMenu->InvokeCommand(&commandInfo);
1844     hResult = objectWithSite->SetSite(NULL);
1845     return hResult;
1846 }
1847 
1848 bool IUnknownIsEqual(IUnknown *int1, IUnknown *int2)
1849 {
1850     CComPtr<IUnknown>                       int1Retry;
1851     CComPtr<IUnknown>                       int2Retry;
1852     HRESULT                                 hResult;
1853 
1854     if (int1 == int2)
1855         return true;
1856     if (int1 == NULL || int2 == NULL)
1857         return false;
1858     hResult = int1->QueryInterface(IID_PPV_ARG(IUnknown, &int1Retry));
1859     if (FAILED_UNEXPECTEDLY(hResult))
1860         return false;
1861     hResult = int2->QueryInterface(IID_PPV_ARG(IUnknown, &int2Retry));
1862     if (FAILED_UNEXPECTEDLY(hResult))
1863         return false;
1864     if (int1Retry == int2Retry)
1865         return true;
1866     return false;
1867 }
1868 
1869 HRESULT STDMETHODCALLTYPE CShellBrowser::GetBorderDW(IUnknown *punkObj, LPRECT prcBorder)
1870 {
1871     static const INT excludeItems[] = { 1, 1, 1, 0xa001, 0, 0 };
1872 
1873     RECT availableBounds;
1874 
1875     GetEffectiveClientRect(m_hWnd, &availableBounds, excludeItems);
1876     for (INT x = 0; x < 3; x++)
1877     {
1878         if (fClientBars[x].clientBar.p != NULL && !IUnknownIsEqual(fClientBars[x].clientBar, punkObj))
1879         {
1880             availableBounds.top += fClientBars[x].borderSpace.top;
1881             availableBounds.left += fClientBars[x].borderSpace.left;
1882             availableBounds.bottom -= fClientBars[x].borderSpace.bottom;
1883             availableBounds.right -= fClientBars[x].borderSpace.right;
1884         }
1885     }
1886     *prcBorder = availableBounds;
1887     return S_OK;
1888 }
1889 
1890 HRESULT STDMETHODCALLTYPE CShellBrowser::RequestBorderSpaceDW(IUnknown* punkObj, LPCBORDERWIDTHS pbw)
1891 {
1892     return S_OK;
1893 }
1894 
1895 HRESULT STDMETHODCALLTYPE CShellBrowser::SetBorderSpaceDW(IUnknown* punkObj, LPCBORDERWIDTHS pbw)
1896 {
1897     for (INT x = 0; x < 3; x++)
1898     {
1899         if (IUnknownIsEqual(fClientBars[x].clientBar, punkObj))
1900         {
1901             fClientBars[x].borderSpace = *pbw;
1902             // if this bar changed size, it cascades and forces all subsequent bars to resize
1903             RepositionBars();
1904             return S_OK;
1905         }
1906     }
1907     return E_INVALIDARG;
1908 }
1909 
1910 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryStatus(const GUID *pguidCmdGroup,
1911     ULONG cCmds, OLECMD prgCmds[  ], OLECMDTEXT *pCmdText)
1912 {
1913     CComPtr<IOleCommandTarget>              commandTarget;
1914     HRESULT                                 hResult;
1915 
1916     if (prgCmds == NULL)
1917         return E_INVALIDARG;
1918     if (pguidCmdGroup == NULL)
1919     {
1920         if (fCurrentShellView.p != NULL)
1921         {
1922             hResult = fCurrentShellView->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &commandTarget));
1923             if (SUCCEEDED(hResult) && commandTarget.p != NULL)
1924                 return commandTarget->QueryStatus(NULL, 1, prgCmds, pCmdText);
1925         }
1926         while (cCmds != 0)
1927         {
1928             prgCmds->cmdf = 0;
1929             prgCmds++;
1930             cCmds--;
1931         }
1932     }
1933     else if (IsEqualIID(*pguidCmdGroup, CGID_Explorer))
1934     {
1935         while (cCmds != 0)
1936         {
1937             switch (prgCmds->cmdID)
1938             {
1939                 case 0x1c:  // search
1940                     prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
1941                     break;
1942                 case 0x1d:  // history
1943                     prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
1944                     break;
1945                 case 0x1e:  // favorites
1946                     prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
1947                     break;
1948                 case 0x23:  // folders
1949                     prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED | OLECMDF_LATCHED;
1950                     break;
1951                 default:
1952                     prgCmds->cmdf = 0;
1953                     break;
1954             }
1955             prgCmds++;
1956             cCmds--;
1957         }
1958     }
1959     else if (IsEqualIID(*pguidCmdGroup, CGID_ShellBrowser))
1960     {
1961         while (cCmds != 0)
1962         {
1963             switch (prgCmds->cmdID)
1964             {
1965                 case 0xa022:    // up level
1966                     prgCmds->cmdf = OLECMDF_SUPPORTED;
1967                     if (fCurrentDirectoryPIDL->mkid.cb != 0)
1968                         prgCmds->cmdf |= OLECMDF_ENABLED;
1969                     break;
1970             }
1971             prgCmds++;
1972             cCmds--;
1973         }
1974     }
1975     return S_OK;
1976 }
1977 
1978 HRESULT STDMETHODCALLTYPE CShellBrowser::Exec(const GUID *pguidCmdGroup, DWORD nCmdID,
1979     DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
1980 {
1981     HRESULT                                 hResult;
1982 
1983     if (!pguidCmdGroup)
1984     {
1985         TRACE("Unhandled null CGID %d %d %p %p\n", nCmdID, nCmdexecopt, pvaIn, pvaOut);
1986         return E_NOTIMPL;
1987     }
1988     if (IsEqualIID(*pguidCmdGroup, CGID_Explorer))
1989     {
1990         switch (nCmdID)
1991         {
1992             case 0x23:
1993                 hResult = ShowBand(CLSID_ExplorerBand, true);
1994                 return S_OK;
1995             case 0x27:
1996                 if (nCmdexecopt == 1)
1997                 {
1998                     // pvaIn is a VT_UNKNOWN with a band that is being hidden
1999                 }
2000                 else
2001                 {
2002                     // update zones part of the status bar
2003                 }
2004                 return S_OK;
2005             case 0x35: // don't do this, and the internet toolbar doesn't create a menu band
2006                 V_VT(pvaOut) = VT_INT_PTR;
2007                 V_INTREF(pvaOut) = reinterpret_cast<INT *>(
2008                     LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU)));
2009                 return S_OK;
2010             case 0x38:
2011                 // indicate if this cabinet was opened as a browser
2012                 return S_FALSE;
2013             default:
2014                 return E_NOTIMPL;
2015         }
2016     }
2017     else if (IsEqualIID(*pguidCmdGroup, CGID_InternetButtons))
2018     {
2019         switch (nCmdID)
2020         {
2021             case 0x23:
2022                 // placeholder
2023                 return S_OK;
2024         }
2025     }
2026     else if (IsEqualIID(*pguidCmdGroup, CGID_Theater))
2027     {
2028         switch (nCmdID)
2029         {
2030             case 6:
2031                 // what is theater mode and why do we receive this?
2032                 return E_NOTIMPL;
2033         }
2034     }
2035     else if (IsEqualIID(*pguidCmdGroup, CGID_MenuBand))
2036     {
2037         switch (nCmdID)
2038         {
2039             case 14:
2040                 // initialize favorites menu
2041                 return S_OK;
2042         }
2043     }
2044     else if (IsEqualIID(*pguidCmdGroup, CGID_ShellDocView))
2045     {
2046         switch (nCmdID)
2047         {
2048             case 0x12:
2049                 // refresh on toolbar clicked
2050                 return S_OK;
2051             case 0x26:
2052                 // called for unknown bands ?
2053                 return S_OK;
2054             case 0x4d:
2055                 // tell the view if it should hide the task pane or not
2056                 return (fClientBars[BIVerticalBaseBar].clientBar.p == NULL) ? S_FALSE : S_OK;
2057         }
2058     }
2059     else if (IsEqualIID(*pguidCmdGroup, CGID_ShellBrowser))
2060     {
2061         switch (nCmdID)
2062         {
2063             case 40994:
2064                 return NavigateToParent();
2065         }
2066     }
2067     else if (IsEqualIID(*pguidCmdGroup, CGID_IExplorerToolbar))
2068     {
2069         switch (nCmdID)
2070         {
2071             case 0x7063:
2072                 return DoFolderOptions();
2073         }
2074     }
2075     else if (IsEqualIID(*pguidCmdGroup, CGID_DefView))
2076     {
2077         switch (nCmdID)
2078         {
2079             case 1:
2080                 // Reset All Folders option in Folder Options
2081                 break;
2082         }
2083     }
2084     else if (IsEqualIID(*pguidCmdGroup, CLSID_CommonButtons))
2085     {
2086         // Windows seems to use this as proxy for toolbar buttons.
2087         // We use it for search band for now to remove code duplication,
2088         // let's see if it could be useful in the future.
2089         switch (nCmdID)
2090         {
2091             case 0x123:
2092                 // Show search band from toolbar
2093                 OnSearch();
2094                 return S_OK;
2095         }
2096         return E_NOTIMPL;
2097     }
2098     else
2099     {
2100         return E_NOTIMPL;
2101     }
2102     return E_NOTIMPL;
2103 }
2104 
2105 HRESULT STDMETHODCALLTYPE CShellBrowser::GetWindow(HWND *lphwnd)
2106 {
2107     if (lphwnd == NULL)
2108         return E_POINTER;
2109     *lphwnd = m_hWnd;
2110     return S_OK;
2111 }
2112 
2113 HRESULT STDMETHODCALLTYPE CShellBrowser::ContextSensitiveHelp(BOOL fEnterMode)
2114 {
2115     return E_NOTIMPL;
2116 }
2117 
2118 HRESULT STDMETHODCALLTYPE CShellBrowser::InsertMenusSB(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
2119 {
2120     HMENU mainMenu = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU));
2121 
2122     Shell_MergeMenus(hmenuShared, mainMenu, 0, 0, FCIDM_BROWSERLAST, MM_SUBMENUSHAVEIDS);
2123 
2124     int GCCU(itemCount3) = GetMenuItemCount(hmenuShared);
2125     Unused(itemCount3);
2126 
2127     DestroyMenu(mainMenu);
2128 
2129     lpMenuWidths->width[0] = 2;
2130     lpMenuWidths->width[2] = 3;
2131     lpMenuWidths->width[4] = 1;
2132     return S_OK;
2133 }
2134 
2135 HRESULT STDMETHODCALLTYPE CShellBrowser::SetMenuSB(HMENU hmenuShared, HOLEMENU holemenuRes, HWND hwndActiveObject)
2136 {
2137     CComPtr<IShellMenu>                     shellMenu;
2138     HRESULT                                 hResult;
2139 
2140     if (hmenuShared && IsMenu(hmenuShared) == FALSE)
2141         return E_FAIL;
2142     hResult = GetMenuBand(IID_PPV_ARG(IShellMenu, &shellMenu));
2143     if (FAILED_UNEXPECTEDLY(hResult))
2144         return hResult;
2145 
2146     if (!hmenuShared)
2147     {
2148         hmenuShared = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU));
2149     }
2150     // FIXME: Figure out the proper way to do this.
2151     HMENU hMenuFavs = GetSubMenu(hmenuShared, 3);
2152     if (hMenuFavs)
2153     {
2154         DeleteMenu(hMenuFavs, IDM_FAVORITES_EMPTY, MF_BYCOMMAND);
2155     }
2156 
2157     hResult = shellMenu->SetMenu(hmenuShared, m_hWnd, SMSET_DONTOWN);
2158     if (FAILED_UNEXPECTEDLY(hResult))
2159         return hResult;
2160     fCurrentMenuBar = hmenuShared;
2161     BuildExplorerBandMenu();
2162     return S_OK;
2163 }
2164 
2165 HRESULT STDMETHODCALLTYPE CShellBrowser::RemoveMenusSB(HMENU hmenuShared)
2166 {
2167     if (hmenuShared == fCurrentMenuBar)
2168     {
2169         //DestroyMenu(fCurrentMenuBar);
2170         SetMenuSB(NULL, NULL, NULL);
2171     }
2172     return S_OK;
2173 }
2174 
2175 HRESULT STDMETHODCALLTYPE CShellBrowser::SetStatusTextSB(LPCOLESTR pszStatusText)
2176 {
2177     //
2178     if (pszStatusText)
2179     {
2180         ::SetWindowText(fStatusBar, pszStatusText);
2181     }
2182     else
2183     {
2184 
2185     }
2186     return S_OK;
2187 }
2188 
2189 HRESULT STDMETHODCALLTYPE CShellBrowser::EnableModelessSB(BOOL fEnable)
2190 {
2191     return E_NOTIMPL;
2192 }
2193 
2194 HRESULT STDMETHODCALLTYPE CShellBrowser::TranslateAcceleratorSB(MSG *pmsg, WORD wID)
2195 {
2196     if (!::TranslateAcceleratorW(m_hWnd, m_hAccel, pmsg))
2197         return S_FALSE;
2198     return S_OK;
2199 }
2200 
2201 HRESULT STDMETHODCALLTYPE CShellBrowser::BrowseObject(LPCITEMIDLIST pidl, UINT wFlags)
2202 {
2203     if ((wFlags & SBSP_EXPLOREMODE) != NULL)
2204         ShowBand(CLSID_ExplorerBand, true);
2205 
2206     return BrowseToPIDL(pidl, BTP_UPDATE_CUR_HISTORY | BTP_UPDATE_NEXT_HISTORY);
2207 }
2208 
2209 HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewStateStream(DWORD grfMode, IStream **ppStrm)
2210 {
2211     return E_NOTIMPL;
2212 }
2213 
2214 HRESULT STDMETHODCALLTYPE CShellBrowser::GetControlWindow(UINT id, HWND *lphwnd)
2215 {
2216     if (lphwnd == NULL)
2217         return E_POINTER;
2218     *lphwnd = NULL;
2219     switch (id)
2220     {
2221         case FCW_TOOLBAR:
2222             *lphwnd = fToolbarProxy.m_hWnd;
2223             return S_OK;
2224         case FCW_STATUS:
2225             *lphwnd = fStatusBar;
2226             return S_OK;
2227         case FCW_TREE:
2228             // find the directory browser and return it
2229             // this should be used only to determine if a tree is present
2230             return S_OK;
2231         case FCW_PROGRESS:
2232             // is this a progress dialog?
2233             return S_OK;
2234     }
2235     return S_OK;
2236 }
2237 
2238 HRESULT STDMETHODCALLTYPE CShellBrowser::SendControlMsg(
2239     UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pret)
2240 {
2241     LPARAM                                  result;
2242 
2243     if (pret != NULL)
2244         *pret = 0;
2245     switch (id)
2246     {
2247         case FCW_TOOLBAR:
2248             result = fToolbarProxy.SendMessage(uMsg, wParam, lParam);
2249             if (pret != NULL)
2250                 *pret = result;
2251             break;
2252         case FCW_STATUS:
2253             result = SendMessage(fStatusBar, uMsg, wParam, lParam);
2254             if (pret != NULL)
2255                 *pret = result;
2256             break;
2257     }
2258     return S_OK;
2259 }
2260 
2261 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryActiveShellView(IShellView **ppshv)
2262 {
2263     if (ppshv == NULL)
2264         return E_POINTER;
2265     *ppshv = fCurrentShellView;
2266     if (fCurrentShellView.p != NULL)
2267         fCurrentShellView.p->AddRef();
2268     return S_OK;
2269 }
2270 
2271 HRESULT STDMETHODCALLTYPE CShellBrowser::OnViewWindowActive(IShellView *ppshv)
2272 {
2273     return E_NOTIMPL;
2274 }
2275 
2276 HRESULT STDMETHODCALLTYPE CShellBrowser::SetToolbarItems(LPTBBUTTON lpButtons, UINT nButtons, UINT uFlags)
2277 {
2278     return E_NOTIMPL;
2279 }
2280 
2281 HRESULT STDMETHODCALLTYPE CShellBrowser::DragEnter(
2282     IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2283 {
2284     return E_NOTIMPL;
2285 }
2286 
2287 HRESULT STDMETHODCALLTYPE CShellBrowser::DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2288 {
2289     return E_NOTIMPL;
2290 }
2291 
2292 HRESULT STDMETHODCALLTYPE CShellBrowser::DragLeave()
2293 {
2294     return E_NOTIMPL;
2295 }
2296 
2297 HRESULT STDMETHODCALLTYPE CShellBrowser::Drop(
2298     IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2299 {
2300     return E_NOTIMPL;
2301 }
2302 
2303 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
2304 {
2305     // view does a query for SID_STopLevelBrowser, IID_IShellBrowserService
2306     // the returned interface has a method GetPropertyBag on it
2307     if (IsEqualIID(guidService, SID_STopLevelBrowser))
2308         return this->QueryInterface(riid, ppvObject);
2309     if (IsEqualIID(guidService, SID_SShellBrowser))
2310         return this->QueryInterface(riid, ppvObject);
2311     if (IsEqualIID(guidService, SID_ITargetFrame2))
2312         return this->QueryInterface(riid, ppvObject);
2313     if (IsEqualIID(guidService, SID_IWebBrowserApp))        // without this, the internet toolbar won't reflect notifications
2314         return this->QueryInterface(riid, ppvObject);
2315     if (IsEqualIID(guidService, SID_SProxyBrowser))
2316         return this->QueryInterface(riid, ppvObject);
2317     if (IsEqualIID(guidService, SID_IExplorerToolbar))
2318         return fClientBars[BIInternetToolbar].clientBar->QueryInterface(riid, ppvObject);
2319     if (IsEqualIID(riid, IID_IShellBrowser))
2320         return this->QueryInterface(riid, ppvObject);
2321     return E_NOINTERFACE;
2322 }
2323 
2324 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPropertyBag(long flags, REFIID riid, void **ppvObject)
2325 {
2326     if (ppvObject == NULL)
2327         return E_POINTER;
2328     *ppvObject = NULL;
2329     return E_NOTIMPL;
2330 }
2331 
2332 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTypeInfoCount(UINT *pctinfo)
2333 {
2334     return E_NOTIMPL;
2335 }
2336 
2337 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
2338 {
2339     return E_NOTIMPL;
2340 }
2341 
2342 HRESULT STDMETHODCALLTYPE CShellBrowser::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames,
2343     UINT cNames, LCID lcid, DISPID *rgDispId)
2344 {
2345     return E_NOTIMPL;
2346 }
2347 
2348 HRESULT STDMETHODCALLTYPE CShellBrowser::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
2349     WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2350 {
2351     return E_NOTIMPL;
2352 }
2353 
2354 HRESULT STDMETHODCALLTYPE CShellBrowser::GetParentSite(IOleInPlaceSite **ppipsite)
2355 {
2356     return E_NOTIMPL;
2357 }
2358 
2359 HRESULT STDMETHODCALLTYPE CShellBrowser::SetTitle(IShellView *psv, LPCWSTR pszName)
2360 {
2361     return E_NOTIMPL;
2362 }
2363 
2364 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTitle(IShellView *psv, LPWSTR pszName, DWORD cchName)
2365 {
2366     return E_NOTIMPL;
2367 }
2368 
2369 HRESULT STDMETHODCALLTYPE CShellBrowser::GetOleObject(IOleObject **ppobjv)
2370 {
2371     return E_NOTIMPL;
2372 }
2373 
2374 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTravelLog(ITravelLog **pptl)
2375 {
2376     HRESULT                                 hResult;
2377 
2378     // called by toolbar when displaying tooltips
2379     if (pptl == NULL)
2380         return E_FAIL;
2381 
2382     *pptl = NULL;
2383     if (fTravelLog.p == NULL)
2384     {
2385         hResult = CTravelLog_CreateInstance(IID_PPV_ARG(ITravelLog, &fTravelLog));
2386         if (FAILED_UNEXPECTEDLY(hResult))
2387             return hResult;
2388     }
2389     *pptl = fTravelLog.p;
2390     fTravelLog.p->AddRef();
2391     return S_OK;
2392 }
2393 
2394 HRESULT STDMETHODCALLTYPE CShellBrowser::ShowControlWindow(UINT id, BOOL fShow)
2395 {
2396     return E_NOTIMPL;
2397 }
2398 
2399 HRESULT STDMETHODCALLTYPE CShellBrowser::IsControlWindowShown(UINT id, BOOL *pfShown)
2400 {
2401     return E_NOTIMPL;
2402 }
2403 
2404 HRESULT STDMETHODCALLTYPE CShellBrowser::IEGetDisplayName(LPCITEMIDLIST pidl, LPWSTR pwszName, UINT uFlags)
2405 {
2406     return E_NOTIMPL;
2407 }
2408 
2409 HRESULT STDMETHODCALLTYPE CShellBrowser::IEParseDisplayName(UINT uiCP, LPCWSTR pwszPath, LPITEMIDLIST *ppidlOut)
2410 {
2411     return E_NOTIMPL;
2412 }
2413 
2414 HRESULT STDMETHODCALLTYPE CShellBrowser::DisplayParseError(HRESULT hres, LPCWSTR pwszPath)
2415 {
2416     return E_NOTIMPL;
2417 }
2418 
2419 HRESULT STDMETHODCALLTYPE CShellBrowser::NavigateToPidl(LPCITEMIDLIST pidl, DWORD grfHLNF)
2420 {
2421     return E_NOTIMPL;
2422 }
2423 
2424 HRESULT STDMETHODCALLTYPE CShellBrowser::SetNavigateState(BNSTATE bnstate)
2425 {
2426     return E_NOTIMPL;
2427 }
2428 
2429 HRESULT STDMETHODCALLTYPE CShellBrowser::GetNavigateState(BNSTATE *pbnstate)
2430 {
2431     return E_NOTIMPL;
2432 }
2433 
2434 HRESULT STDMETHODCALLTYPE CShellBrowser::NotifyRedirect(IShellView *psv, LPCITEMIDLIST pidl, BOOL *pfDidBrowse)
2435 {
2436     return E_NOTIMPL;
2437 }
2438 
2439 HRESULT STDMETHODCALLTYPE CShellBrowser::UpdateWindowList()
2440 {
2441     return E_NOTIMPL;
2442 }
2443 
2444 HRESULT STDMETHODCALLTYPE CShellBrowser::UpdateBackForwardState()
2445 {
2446     return E_NOTIMPL;
2447 }
2448 
2449 HRESULT STDMETHODCALLTYPE CShellBrowser::SetFlags(DWORD dwFlags, DWORD dwFlagMask)
2450 {
2451     return E_NOTIMPL;
2452 }
2453 
2454 HRESULT STDMETHODCALLTYPE CShellBrowser::GetFlags(DWORD *pdwFlags)
2455 {
2456     return E_NOTIMPL;
2457 }
2458 
2459 HRESULT STDMETHODCALLTYPE CShellBrowser::CanNavigateNow()
2460 {
2461     return E_NOTIMPL;
2462 }
2463 
2464 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPidl(LPITEMIDLIST *ppidl)
2465 {
2466     // called by explorer bar to get current pidl
2467     if (ppidl == NULL)
2468         return E_POINTER;
2469     *ppidl = ILClone(fCurrentDirectoryPIDL);
2470     return S_OK;
2471 }
2472 
2473 HRESULT STDMETHODCALLTYPE CShellBrowser::SetReferrer(LPCITEMIDLIST pidl)
2474 {
2475     return E_NOTIMPL;
2476 }
2477 
2478 DWORD STDMETHODCALLTYPE CShellBrowser::GetBrowserIndex()
2479 {
2480     return -1;
2481 }
2482 
2483 HRESULT STDMETHODCALLTYPE CShellBrowser::GetBrowserByIndex(DWORD dwID, IUnknown **ppunk)
2484 {
2485     return E_NOTIMPL;
2486 }
2487 
2488 HRESULT STDMETHODCALLTYPE CShellBrowser::GetHistoryObject(IOleObject **ppole, IStream **pstm, IBindCtx **ppbc)
2489 {
2490     if (ppole == NULL || pstm == NULL || ppbc == NULL)
2491         return E_INVALIDARG;
2492     *ppole = fHistoryObject;
2493     if (fHistoryObject != NULL)
2494         fHistoryObject->AddRef();
2495     *pstm = fHistoryStream;
2496     if (fHistoryStream != NULL)
2497         fHistoryStream->AddRef();
2498     *ppbc = fHistoryBindContext;
2499     if (fHistoryBindContext != NULL)
2500         fHistoryBindContext->AddRef();
2501     fHistoryObject = NULL;
2502     fHistoryStream = NULL;
2503     fHistoryBindContext = NULL;
2504     if (*ppole == NULL)
2505         return E_FAIL;
2506     return S_OK;
2507 }
2508 
2509 HRESULT STDMETHODCALLTYPE CShellBrowser::SetHistoryObject(IOleObject *pole, BOOL fIsLocalAnchor)
2510 {
2511     return E_NOTIMPL;
2512 }
2513 
2514 HRESULT STDMETHODCALLTYPE CShellBrowser::CacheOLEServer(IOleObject *pole)
2515 {
2516     return E_NOTIMPL;
2517 }
2518 
2519 HRESULT STDMETHODCALLTYPE CShellBrowser::GetSetCodePage(VARIANT *pvarIn, VARIANT *pvarOut)
2520 {
2521     return E_NOTIMPL;
2522 }
2523 
2524 HRESULT STDMETHODCALLTYPE CShellBrowser::OnHttpEquiv(
2525     IShellView *psv, BOOL fDone, VARIANT *pvarargIn, VARIANT *pvarargOut)
2526 {
2527     return E_NOTIMPL;
2528 }
2529 
2530 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPalette(HPALETTE *hpal)
2531 {
2532     return E_NOTIMPL;
2533 }
2534 
2535 HRESULT STDMETHODCALLTYPE CShellBrowser::RegisterWindow(BOOL fForceRegister, int swc)
2536 {
2537     return E_NOTIMPL;
2538 }
2539 
2540 LRESULT STDMETHODCALLTYPE CShellBrowser::WndProcBS(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2541 {
2542     return E_NOTIMPL;
2543 }
2544 
2545 HRESULT STDMETHODCALLTYPE CShellBrowser::SetAsDefFolderSettings()
2546 {
2547     return E_NOTIMPL;
2548 }
2549 
2550 HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewRect(RECT *prc)
2551 {
2552     return E_NOTIMPL;
2553 }
2554 
2555 HRESULT STDMETHODCALLTYPE CShellBrowser::OnSize(WPARAM wParam)
2556 {
2557     return E_NOTIMPL;
2558 }
2559 
2560 HRESULT STDMETHODCALLTYPE CShellBrowser::OnCreate(struct tagCREATESTRUCTW *pcs)
2561 {
2562     m_hAccel = LoadAcceleratorsW(GetModuleHandle(L"browseui.dll"), MAKEINTRESOURCEW(256));
2563     return S_OK;
2564 }
2565 
2566 LRESULT STDMETHODCALLTYPE CShellBrowser::OnCommand(WPARAM wParam, LPARAM lParam)
2567 {
2568     return 0;
2569 }
2570 
2571 HRESULT STDMETHODCALLTYPE CShellBrowser::OnDestroy()
2572 {
2573     return E_NOTIMPL;
2574 }
2575 
2576 LRESULT STDMETHODCALLTYPE CShellBrowser::OnNotify(struct tagNMHDR *pnm)
2577 {
2578     return 0;
2579 }
2580 
2581 HRESULT STDMETHODCALLTYPE CShellBrowser::OnSetFocus()
2582 {
2583     return E_NOTIMPL;
2584 }
2585 
2586 HRESULT STDMETHODCALLTYPE CShellBrowser::OnFrameWindowActivateBS(BOOL fActive)
2587 {
2588     return E_NOTIMPL;
2589 }
2590 
2591 HRESULT STDMETHODCALLTYPE CShellBrowser::ReleaseShellView()
2592 {
2593     return E_NOTIMPL;
2594 }
2595 
2596 HRESULT STDMETHODCALLTYPE CShellBrowser::ActivatePendingView()
2597 {
2598     return E_NOTIMPL;
2599 }
2600 
2601 HRESULT STDMETHODCALLTYPE CShellBrowser::CreateViewWindow(
2602     IShellView *psvNew, IShellView *psvOld, LPRECT prcView, HWND *phwnd)
2603 {
2604     return E_NOTIMPL;
2605 }
2606 
2607 HRESULT STDMETHODCALLTYPE CShellBrowser::CreateBrowserPropSheetExt(REFIID riid, void **ppv)
2608 {
2609     return E_NOTIMPL;
2610 }
2611 
2612 HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewWindow(HWND *phwndView)
2613 {
2614     return E_NOTIMPL;
2615 }
2616 
2617 HRESULT STDMETHODCALLTYPE CShellBrowser::GetBaseBrowserData(LPCBASEBROWSERDATA *pbbd)
2618 {
2619     return E_NOTIMPL;
2620 }
2621 
2622 LPBASEBROWSERDATA STDMETHODCALLTYPE CShellBrowser::PutBaseBrowserData()
2623 {
2624     return NULL;
2625 }
2626 
2627 HRESULT STDMETHODCALLTYPE CShellBrowser::InitializeTravelLog(ITravelLog *ptl, DWORD dw)
2628 {
2629     return E_NOTIMPL;
2630 }
2631 
2632 HRESULT STDMETHODCALLTYPE CShellBrowser::SetTopBrowser()
2633 {
2634     return E_NOTIMPL;
2635 }
2636 
2637 HRESULT STDMETHODCALLTYPE CShellBrowser::Offline(int iCmd)
2638 {
2639     return E_NOTIMPL;
2640 }
2641 
2642 HRESULT STDMETHODCALLTYPE CShellBrowser::AllowViewResize(BOOL f)
2643 {
2644     return E_NOTIMPL;
2645 }
2646 
2647 HRESULT STDMETHODCALLTYPE CShellBrowser::SetActivateState(UINT u)
2648 {
2649     return E_NOTIMPL;
2650 }
2651 
2652 HRESULT STDMETHODCALLTYPE CShellBrowser::UpdateSecureLockIcon(int eSecureLock)
2653 {
2654     return E_NOTIMPL;
2655 }
2656 
2657 HRESULT STDMETHODCALLTYPE CShellBrowser::InitializeDownloadManager()
2658 {
2659     return E_NOTIMPL;
2660 }
2661 
2662 HRESULT STDMETHODCALLTYPE CShellBrowser::InitializeTransitionSite()
2663 {
2664     return E_NOTIMPL;
2665 }
2666 
2667 HRESULT STDMETHODCALLTYPE CShellBrowser::_Initialize(HWND hwnd, IUnknown *pauto)
2668 {
2669     return E_NOTIMPL;
2670 }
2671 
2672 HRESULT STDMETHODCALLTYPE CShellBrowser::_CancelPendingNavigationAsync()
2673 {
2674     return E_NOTIMPL;
2675 }
2676 
2677 HRESULT STDMETHODCALLTYPE CShellBrowser::_CancelPendingView()
2678 {
2679     return E_NOTIMPL;
2680 }
2681 
2682 HRESULT STDMETHODCALLTYPE CShellBrowser::_MaySaveChanges()
2683 {
2684     return E_NOTIMPL;
2685 }
2686 
2687 HRESULT STDMETHODCALLTYPE CShellBrowser::_PauseOrResumeView(BOOL fPaused)
2688 {
2689     return E_NOTIMPL;
2690 }
2691 
2692 HRESULT STDMETHODCALLTYPE CShellBrowser::_DisableModeless()
2693 {
2694     return E_NOTIMPL;
2695 }
2696 
2697 HRESULT STDMETHODCALLTYPE CShellBrowser::_NavigateToPidl(LPCITEMIDLIST pidl, DWORD grfHLNF, DWORD dwFlags)
2698 {
2699     return E_NOTIMPL;
2700 }
2701 
2702 HRESULT STDMETHODCALLTYPE CShellBrowser::_TryShell2Rename(IShellView *psv, LPCITEMIDLIST pidlNew)
2703 {
2704     return E_NOTIMPL;
2705 }
2706 
2707 HRESULT STDMETHODCALLTYPE CShellBrowser::_SwitchActivationNow()
2708 {
2709     return E_NOTIMPL;
2710 }
2711 
2712 HRESULT STDMETHODCALLTYPE CShellBrowser::_ExecChildren(IUnknown *punkBar, BOOL fBroadcast,
2713     const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut)
2714 {
2715     return E_NOTIMPL;
2716 }
2717 
2718 HRESULT STDMETHODCALLTYPE CShellBrowser::_SendChildren(
2719     HWND hwndBar, BOOL fBroadcast, UINT uMsg, WPARAM wParam, LPARAM lParam)
2720 {
2721     return E_NOTIMPL;
2722 }
2723 
2724 HRESULT STDMETHODCALLTYPE CShellBrowser::GetFolderSetData(struct tagFolderSetData *pfsd)
2725 {
2726     return E_NOTIMPL;
2727 }
2728 
2729 HRESULT STDMETHODCALLTYPE CShellBrowser::_OnFocusChange(UINT itb)
2730 {
2731     return E_NOTIMPL;
2732 }
2733 
2734 HRESULT STDMETHODCALLTYPE CShellBrowser::v_ShowHideChildWindows(BOOL fChildOnly)
2735 {
2736     return E_NOTIMPL;
2737 }
2738 
2739 UINT STDMETHODCALLTYPE CShellBrowser::_get_itbLastFocus()
2740 {
2741     return 0;
2742 }
2743 
2744 HRESULT STDMETHODCALLTYPE CShellBrowser::_put_itbLastFocus(UINT itbLastFocus)
2745 {
2746     return E_NOTIMPL;
2747 }
2748 
2749 HRESULT STDMETHODCALLTYPE CShellBrowser::_UIActivateView(UINT uState)
2750 {
2751     return E_NOTIMPL;
2752 }
2753 
2754 HRESULT STDMETHODCALLTYPE CShellBrowser::_GetViewBorderRect(RECT *prc)
2755 {
2756     return E_NOTIMPL;
2757 }
2758 
2759 HRESULT STDMETHODCALLTYPE CShellBrowser::_UpdateViewRectSize()
2760 {
2761     return E_NOTIMPL;
2762 }
2763 
2764 HRESULT STDMETHODCALLTYPE CShellBrowser::_ResizeNextBorder(UINT itb)
2765 {
2766     return E_NOTIMPL;
2767 }
2768 
2769 HRESULT STDMETHODCALLTYPE CShellBrowser::_ResizeView()
2770 {
2771     return E_NOTIMPL;
2772 }
2773 
2774 HRESULT STDMETHODCALLTYPE CShellBrowser::_GetEffectiveClientArea(LPRECT lprectBorder, HMONITOR hmon)
2775 {
2776     return E_NOTIMPL;
2777 }
2778 
2779 IStream *STDMETHODCALLTYPE CShellBrowser::v_GetViewStream(LPCITEMIDLIST pidl, DWORD grfMode, LPCWSTR pwszName)
2780 {
2781     return NULL;
2782 }
2783 
2784 LRESULT STDMETHODCALLTYPE CShellBrowser::ForwardViewMsg(UINT uMsg, WPARAM wParam, LPARAM lParam)
2785 {
2786     return 0;
2787 }
2788 
2789 HRESULT STDMETHODCALLTYPE CShellBrowser::SetAcceleratorMenu(HACCEL hacc)
2790 {
2791     return E_NOTIMPL;
2792 }
2793 
2794 int STDMETHODCALLTYPE CShellBrowser::_GetToolbarCount()
2795 {
2796     return 0;
2797 }
2798 
2799 LPTOOLBARITEM STDMETHODCALLTYPE CShellBrowser::_GetToolbarItem(int itb)
2800 {
2801     return NULL;
2802 }
2803 
2804 HRESULT STDMETHODCALLTYPE CShellBrowser::_SaveToolbars(IStream *pstm)
2805 {
2806     return E_NOTIMPL;
2807 }
2808 
2809 HRESULT STDMETHODCALLTYPE CShellBrowser::_LoadToolbars(IStream *pstm)
2810 {
2811     return E_NOTIMPL;
2812 }
2813 
2814 HRESULT STDMETHODCALLTYPE CShellBrowser::_CloseAndReleaseToolbars(BOOL fClose)
2815 {
2816     return E_NOTIMPL;
2817 }
2818 
2819 HRESULT STDMETHODCALLTYPE CShellBrowser::v_MayGetNextToolbarFocus(
2820     LPMSG lpMsg, UINT itbNext, int citb, LPTOOLBARITEM *pptbi, HWND *phwnd)
2821 {
2822     return E_NOTIMPL;
2823 }
2824 
2825 HRESULT STDMETHODCALLTYPE CShellBrowser::_ResizeNextBorderHelper(UINT itb, BOOL bUseHmonitor)
2826 {
2827     return E_NOTIMPL;
2828 }
2829 
2830 UINT STDMETHODCALLTYPE CShellBrowser::_FindTBar(IUnknown *punkSrc)
2831 {
2832     return 0;
2833 }
2834 
2835 HRESULT STDMETHODCALLTYPE CShellBrowser::_SetFocus(LPTOOLBARITEM ptbi, HWND hwnd, LPMSG lpMsg)
2836 {
2837     return E_NOTIMPL;
2838 }
2839 
2840 HRESULT STDMETHODCALLTYPE CShellBrowser::v_MayTranslateAccelerator(MSG *pmsg)
2841 {
2842     for (int i = 0; i < 3; i++)
2843     {
2844         if (IUnknown_TranslateAcceleratorIO(fClientBars[i].clientBar, pmsg) == S_OK)
2845             return S_OK;
2846     }
2847 
2848     if (!fCurrentShellView)
2849         return S_FALSE;
2850 
2851     return fCurrentShellView->TranslateAcceleratorW(pmsg);
2852 }
2853 
2854 HRESULT STDMETHODCALLTYPE CShellBrowser::_GetBorderDWHelper(IUnknown *punkSrc, LPRECT lprectBorder, BOOL bUseHmonitor)
2855 {
2856     return E_NOTIMPL;
2857 }
2858 
2859 HRESULT STDMETHODCALLTYPE CShellBrowser::v_CheckZoneCrossing(LPCITEMIDLIST pidl)
2860 {
2861     return E_NOTIMPL;
2862 }
2863 
2864 HRESULT STDMETHODCALLTYPE CShellBrowser::GoBack()
2865 {
2866     CComPtr<ITravelLog> travelLog;
2867     HRESULT hResult = GetTravelLog(&travelLog);
2868     if (FAILED_UNEXPECTEDLY(hResult))
2869         return hResult;
2870     return travelLog->Travel(static_cast<IDropTarget *>(this), TLOG_BACK);
2871 }
2872 
2873 HRESULT STDMETHODCALLTYPE CShellBrowser::GoForward()
2874 {
2875     CComPtr<ITravelLog> travelLog;
2876     HRESULT hResult = GetTravelLog(&travelLog);
2877     if (FAILED_UNEXPECTEDLY(hResult))
2878         return hResult;
2879     return travelLog->Travel(static_cast<IDropTarget *>(this), TLOG_FORE);
2880 }
2881 
2882 HRESULT STDMETHODCALLTYPE CShellBrowser::GoHome()
2883 {
2884     return E_NOTIMPL;
2885 }
2886 
2887 HRESULT STDMETHODCALLTYPE CShellBrowser::GoSearch()
2888 {
2889     return E_NOTIMPL;
2890 }
2891 
2892 HRESULT STDMETHODCALLTYPE CShellBrowser::Navigate(BSTR URL, VARIANT *Flags,
2893     VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
2894 {
2895     CComHeapPtr<ITEMIDLIST> pidl;
2896     HRESULT hResult;
2897     CComPtr<IShellFolder> pDesktop;
2898 
2899     hResult = SHGetDesktopFolder(&pDesktop);
2900     if (FAILED_UNEXPECTEDLY(hResult))
2901         return hResult;
2902     hResult = pDesktop->ParseDisplayName(NULL, NULL, URL, NULL, &pidl, NULL);
2903     if (FAILED_UNEXPECTEDLY(hResult))
2904         return hResult;
2905     return BrowseObject(pidl, 1);
2906 }
2907 
2908 HRESULT STDMETHODCALLTYPE CShellBrowser::Refresh()
2909 {
2910     VARIANT                                 level;
2911 
2912     V_VT(&level) = VT_I4;
2913     V_I4(&level) = 4;
2914     return Refresh2(&level);
2915 }
2916 
2917 HRESULT STDMETHODCALLTYPE CShellBrowser::Refresh2(VARIANT *Level)
2918 {
2919     CComPtr<IOleCommandTarget>              oleCommandTarget;
2920     HRESULT                                 hResult;
2921 
2922     hResult = fCurrentShellView->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &oleCommandTarget));
2923     if (FAILED_UNEXPECTEDLY(hResult))
2924         return hResult;
2925     return oleCommandTarget->Exec(NULL, 22, 1, Level, NULL);
2926 }
2927 
2928 HRESULT STDMETHODCALLTYPE CShellBrowser::Stop()
2929 {
2930     return E_NOTIMPL;
2931 }
2932 
2933 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Application(IDispatch **ppDisp)
2934 {
2935     return E_NOTIMPL;
2936 }
2937 
2938 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Parent(IDispatch **ppDisp)
2939 {
2940     return E_NOTIMPL;
2941 }
2942 
2943 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Container(IDispatch **ppDisp)
2944 {
2945     return E_NOTIMPL;
2946 }
2947 
2948 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Document(IDispatch **ppDisp)
2949 {
2950     return E_NOTIMPL;
2951 }
2952 
2953 HRESULT STDMETHODCALLTYPE CShellBrowser::get_TopLevelContainer(VARIANT_BOOL *pBool)
2954 {
2955     return E_NOTIMPL;
2956 }
2957 
2958 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Type(BSTR *Type)
2959 {
2960     return E_NOTIMPL;
2961 }
2962 #ifdef __exdisp_h__
2963 #define long LONG
2964 #endif
2965 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Left(long *pl)
2966 {
2967     return E_NOTIMPL;
2968 }
2969 
2970 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Left(long Left)
2971 {
2972     return E_NOTIMPL;
2973 }
2974 
2975 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Top(long *pl)
2976 {
2977     return E_NOTIMPL;
2978 }
2979 
2980 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Top(long Top)
2981 {
2982     return E_NOTIMPL;
2983 }
2984 
2985 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Width(long *pl)
2986 {
2987     return E_NOTIMPL;
2988 }
2989 
2990 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Width(long Width)
2991 {
2992     return E_NOTIMPL;
2993 }
2994 
2995 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Height(long *pl)
2996 {
2997     return E_NOTIMPL;
2998 }
2999 
3000 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Height(long Height)
3001 {
3002     return E_NOTIMPL;
3003 }
3004 #ifdef __exdisp_h__
3005 #undef long
3006 #endif
3007 HRESULT STDMETHODCALLTYPE CShellBrowser::get_LocationName(BSTR *LocationName)
3008 {
3009     return E_NOTIMPL;
3010 }
3011 
3012 HRESULT STDMETHODCALLTYPE CShellBrowser::get_LocationURL(BSTR *LocationURL)
3013 {
3014     return E_NOTIMPL;
3015 }
3016 
3017 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Busy(VARIANT_BOOL *pBool)
3018 {
3019     return E_NOTIMPL;
3020 }
3021 
3022 HRESULT STDMETHODCALLTYPE CShellBrowser::Quit()
3023 {
3024     return E_NOTIMPL;
3025 }
3026 
3027 HRESULT STDMETHODCALLTYPE CShellBrowser::ClientToWindow(int *pcx, int *pcy)
3028 {
3029     return E_NOTIMPL;
3030 }
3031 
3032 HRESULT STDMETHODCALLTYPE CShellBrowser::PutProperty(BSTR Property, VARIANT vtValue)
3033 {
3034     return E_NOTIMPL;
3035 }
3036 
3037 HRESULT STDMETHODCALLTYPE CShellBrowser::GetProperty(BSTR Property, VARIANT *pvtValue)
3038 {
3039     return E_NOTIMPL;
3040 }
3041 
3042 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Name(BSTR *Name)
3043 {
3044     return E_NOTIMPL;
3045 }
3046 
3047 HRESULT STDMETHODCALLTYPE CShellBrowser::get_HWND(SHANDLE_PTR *pHWND)
3048 {
3049     return E_NOTIMPL;
3050 }
3051 
3052 HRESULT STDMETHODCALLTYPE CShellBrowser::get_FullName(BSTR *FullName)
3053 {
3054     return E_NOTIMPL;
3055 }
3056 
3057 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Path(BSTR *Path)
3058 {
3059     return E_NOTIMPL;
3060 }
3061 
3062 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Visible(VARIANT_BOOL *pBool)
3063 {
3064     return E_NOTIMPL;
3065 }
3066 
3067 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Visible(VARIANT_BOOL Value)
3068 {
3069     return E_NOTIMPL;
3070 }
3071 
3072 HRESULT STDMETHODCALLTYPE CShellBrowser::get_StatusBar(VARIANT_BOOL *pBool)
3073 {
3074     return E_NOTIMPL;
3075 }
3076 
3077 HRESULT STDMETHODCALLTYPE CShellBrowser::put_StatusBar(VARIANT_BOOL Value)
3078 {
3079     return E_NOTIMPL;
3080 }
3081 
3082 HRESULT STDMETHODCALLTYPE CShellBrowser::get_StatusText(BSTR *StatusText)
3083 {
3084     return E_NOTIMPL;
3085 }
3086 
3087 HRESULT STDMETHODCALLTYPE CShellBrowser::put_StatusText(BSTR StatusText)
3088 {
3089     return E_NOTIMPL;
3090 }
3091 
3092 HRESULT STDMETHODCALLTYPE CShellBrowser::get_ToolBar(int *Value)
3093 {
3094     return E_NOTIMPL;
3095 }
3096 
3097 HRESULT STDMETHODCALLTYPE CShellBrowser::put_ToolBar(int Value)
3098 {
3099     return E_NOTIMPL;
3100 }
3101 
3102 HRESULT STDMETHODCALLTYPE CShellBrowser::get_MenuBar(VARIANT_BOOL *Value)
3103 {
3104     return E_NOTIMPL;
3105 }
3106 
3107 HRESULT STDMETHODCALLTYPE CShellBrowser::put_MenuBar(VARIANT_BOOL Value)
3108 {
3109     return E_NOTIMPL;
3110 }
3111 
3112 HRESULT STDMETHODCALLTYPE CShellBrowser::get_FullScreen(VARIANT_BOOL *pbFullScreen)
3113 {
3114     return E_NOTIMPL;
3115 }
3116 
3117 HRESULT STDMETHODCALLTYPE CShellBrowser::put_FullScreen(VARIANT_BOOL bFullScreen)
3118 {
3119     return E_NOTIMPL;
3120 }
3121 
3122 HRESULT STDMETHODCALLTYPE CShellBrowser::Navigate2(VARIANT *URL, VARIANT *Flags,
3123     VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
3124 {
3125     LPITEMIDLIST pidl = NULL;
3126     HRESULT hResult;
3127     // called from drive combo box to navigate to a directory
3128     // Also called by search band to display shell results folder view
3129 
3130     if (V_VT(URL) == VT_BSTR)
3131     {
3132         return this->Navigate(V_BSTR(URL), Flags, TargetFrameName, PostData, Headers);
3133     }
3134     if (V_VT(URL) == (VT_ARRAY | VT_UI1))
3135     {
3136         if (V_ARRAY(URL)->cDims != 1 || V_ARRAY(URL)->cbElements != 1)
3137             return E_INVALIDARG;
3138 
3139         pidl = static_cast<LPITEMIDLIST>(V_ARRAY(URL)->pvData);
3140     }
3141     hResult = BrowseToPIDL(pidl, BTP_UPDATE_CUR_HISTORY | BTP_UPDATE_NEXT_HISTORY);
3142     if (FAILED_UNEXPECTEDLY(hResult))
3143         return hResult;
3144     return S_OK;
3145 }
3146 
3147 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryStatusWB(OLECMDID cmdID, OLECMDF *pcmdf)
3148 {
3149     return E_NOTIMPL;
3150 }
3151 
3152 HRESULT STDMETHODCALLTYPE CShellBrowser::ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt,
3153     VARIANT *pvaIn, VARIANT *pvaOut)
3154 {
3155     return E_NOTIMPL;
3156 }
3157 
3158 HRESULT STDMETHODCALLTYPE CShellBrowser::ShowBrowserBar(VARIANT *pvaClsid, VARIANT *pvarShow, VARIANT *pvarSize)
3159 {
3160     CLSID                                   classID;
3161     bool                                    vertical;
3162 
3163     // called to show search bar
3164     if (V_VT(pvaClsid) != VT_BSTR)
3165         return E_INVALIDARG;
3166     CLSIDFromString(V_BSTR(pvaClsid), &classID);
3167     // TODO: properly compute the value of vertical
3168     vertical = true;
3169     return ShowBand(classID, vertical);
3170 }
3171 
3172 HRESULT STDMETHODCALLTYPE CShellBrowser::get_ReadyState(READYSTATE *plReadyState)
3173 {
3174     return E_NOTIMPL;
3175 }
3176 
3177 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Offline(VARIANT_BOOL *pbOffline)
3178 {
3179     return E_NOTIMPL;
3180 }
3181 
3182 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Offline(VARIANT_BOOL bOffline)
3183 {
3184     return E_NOTIMPL;
3185 }
3186 
3187 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Silent(VARIANT_BOOL *pbSilent)
3188 {
3189     return E_NOTIMPL;
3190 }
3191 
3192 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Silent(VARIANT_BOOL bSilent)
3193 {
3194     return E_NOTIMPL;
3195 }
3196 
3197 HRESULT STDMETHODCALLTYPE CShellBrowser::get_RegisterAsBrowser(VARIANT_BOOL *pbRegister)
3198 {
3199     return E_NOTIMPL;
3200 }
3201 
3202 HRESULT STDMETHODCALLTYPE CShellBrowser::put_RegisterAsBrowser(VARIANT_BOOL bRegister)
3203 {
3204     return E_NOTIMPL;
3205 }
3206 
3207 HRESULT STDMETHODCALLTYPE CShellBrowser::get_RegisterAsDropTarget(VARIANT_BOOL *pbRegister)
3208 {
3209     return E_NOTIMPL;
3210 }
3211 
3212 HRESULT STDMETHODCALLTYPE CShellBrowser::put_RegisterAsDropTarget(VARIANT_BOOL bRegister)
3213 {
3214     return E_NOTIMPL;
3215 }
3216 
3217 HRESULT STDMETHODCALLTYPE CShellBrowser::get_TheaterMode(VARIANT_BOOL *pbRegister)
3218 {
3219     return E_NOTIMPL;
3220 }
3221 
3222 HRESULT STDMETHODCALLTYPE CShellBrowser::put_TheaterMode(VARIANT_BOOL bRegister)
3223 {
3224     return E_NOTIMPL;
3225 }
3226 
3227 HRESULT STDMETHODCALLTYPE CShellBrowser::get_AddressBar(VARIANT_BOOL *Value)
3228 {
3229     return E_NOTIMPL;
3230 }
3231 
3232 HRESULT STDMETHODCALLTYPE CShellBrowser::put_AddressBar(VARIANT_BOOL Value)
3233 {
3234     return E_NOTIMPL;
3235 }
3236 
3237 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Resizable(VARIANT_BOOL *Value)
3238 {
3239     return E_NOTIMPL;
3240 }
3241 
3242 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Resizable(VARIANT_BOOL Value)
3243 {
3244     return E_NOTIMPL;
3245 }
3246 
3247 HRESULT STDMETHODCALLTYPE CShellBrowser::FindWindowByIndex(DWORD dwID, IUnknown **ppunk)
3248 {
3249     return E_NOTIMPL;
3250 }
3251 
3252 HRESULT STDMETHODCALLTYPE CShellBrowser::GetWindowData(IStream *pStream, LPWINDOWDATA pWinData)
3253 {
3254     if (pWinData == NULL)
3255         return E_POINTER;
3256 
3257     pWinData->dwWindowID = -1;
3258     pWinData->uiCP = 0;
3259     pWinData->pidl = ILClone(fCurrentDirectoryPIDL);
3260     pWinData->lpszUrl = NULL;
3261     pWinData->lpszUrlLocation = NULL;
3262     pWinData->lpszTitle = NULL;
3263     return S_OK;
3264 }
3265 
3266 HRESULT STDMETHODCALLTYPE CShellBrowser::LoadHistoryPosition(LPWSTR pszUrlLocation, DWORD dwPosition)
3267 {
3268     return E_NOTIMPL;
3269 }
3270 
3271 HRESULT STDMETHODCALLTYPE CShellBrowser::GetClassID(CLSID *pClassID)
3272 {
3273     return E_NOTIMPL;
3274 }
3275 
3276 HRESULT STDMETHODCALLTYPE CShellBrowser::LoadHistory(IStream *pStream, IBindCtx *pbc)
3277 {
3278     CComPtr<IPersistHistory>                viewPersistHistory;
3279     CComPtr<IOleObject>                     viewHistoryObject;
3280     persistState                            oldState;
3281     ULONG                                   numRead;
3282     LPITEMIDLIST                            pidl;
3283     HRESULT                                 hResult;
3284 
3285     hResult = pStream->Read(&oldState, sizeof(oldState), &numRead);
3286     if (FAILED_UNEXPECTEDLY(hResult))
3287         return hResult;
3288     if (numRead != sizeof(oldState) || oldState.dwSize != sizeof(oldState))
3289         return E_FAIL;
3290     if (oldState.browseType != 2)
3291         return E_FAIL;
3292     pidl = static_cast<LPITEMIDLIST>(CoTaskMemAlloc(oldState.pidlSize));
3293     if (pidl == NULL)
3294         return E_OUTOFMEMORY;
3295     hResult = pStream->Read(pidl, oldState.pidlSize, &numRead);
3296     if (FAILED_UNEXPECTEDLY(hResult))
3297     {
3298         ILFree(pidl);
3299         return hResult;
3300     }
3301     if (numRead != oldState.pidlSize)
3302     {
3303         ILFree(pidl);
3304         return E_FAIL;
3305     }
3306     hResult = CoCreateInstance(oldState.persistClass, NULL, CLSCTX_LOCAL_SERVER | CLSCTX_INPROC_SERVER,
3307         IID_PPV_ARG(IOleObject, &viewHistoryObject));
3308     fHistoryObject = viewHistoryObject;
3309     fHistoryStream = pStream;
3310     fHistoryBindContext = pbc;
3311     hResult = BrowseToPIDL(pidl, BTP_DONT_UPDATE_HISTORY);
3312     fHistoryObject = NULL;
3313     fHistoryStream = NULL;
3314     fHistoryBindContext = NULL;
3315     ILFree(pidl);
3316     if (FAILED_UNEXPECTEDLY(hResult))
3317         return hResult;
3318     return S_OK;
3319 }
3320 
3321 HRESULT STDMETHODCALLTYPE CShellBrowser::SaveHistory(IStream *pStream)
3322 {
3323     CComPtr<IPersistHistory>                viewPersistHistory;
3324     persistState                            newState;
3325     HRESULT                                 hResult;
3326 
3327     hResult = fCurrentShellView->GetItemObject(
3328         SVGIO_BACKGROUND, IID_PPV_ARG(IPersistHistory, &viewPersistHistory));
3329     memset(&newState, 0, sizeof(newState));
3330     newState.dwSize = sizeof(newState);
3331     newState.browseType = 2;
3332     newState.browserIndex = GetBrowserIndex();
3333     if (viewPersistHistory.p != NULL)
3334     {
3335         hResult = viewPersistHistory->GetClassID(&newState.persistClass);
3336         if (FAILED_UNEXPECTEDLY(hResult))
3337             return hResult;
3338     }
3339     newState.pidlSize = ILGetSize(fCurrentDirectoryPIDL);
3340     hResult = pStream->Write(&newState, sizeof(newState), NULL);
3341     if (FAILED_UNEXPECTEDLY(hResult))
3342         return hResult;
3343     hResult = pStream->Write(fCurrentDirectoryPIDL, newState.pidlSize, NULL);
3344     if (FAILED_UNEXPECTEDLY(hResult))
3345         return hResult;
3346     if (viewPersistHistory.p != NULL)
3347     {
3348         hResult = viewPersistHistory->SaveHistory(pStream);
3349         if (FAILED_UNEXPECTEDLY(hResult))
3350             return hResult;
3351     }
3352     return S_OK;
3353 }
3354 
3355 HRESULT STDMETHODCALLTYPE CShellBrowser::SetPositionCookie(DWORD dwPositioncookie)
3356 {
3357     return E_NOTIMPL;
3358 }
3359 
3360 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPositionCookie(DWORD *pdwPositioncookie)
3361 {
3362     return E_NOTIMPL;
3363 }
3364 
3365 LRESULT CShellBrowser::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3366 {
3367     OnCreate(reinterpret_cast<LPCREATESTRUCT> (lParam));
3368     return 0;
3369 }
3370 
3371 LRESULT CShellBrowser::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3372 {
3373     HRESULT hr;
3374 
3375     /* The current thread is about to go down so render any IDataObject that may be left in the clipboard */
3376     OleFlushClipboard();
3377 
3378     // TODO: rip down everything
3379     {
3380         fToolbarProxy.Destroy();
3381 
3382         fCurrentShellView->DestroyViewWindow();
3383         fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
3384 
3385         for (int i = 0; i < 3; i++)
3386         {
3387             CComPtr<IDockingWindow> pdw;
3388             CComPtr<IDeskBar> bar;
3389             CComPtr<IUnknown> pBarSite;
3390             CComPtr<IDeskBarClient> pClient;
3391 
3392             if (fClientBars[i].clientBar == NULL)
3393                 continue;
3394 
3395             hr = fClientBars[i].clientBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &pdw));
3396             if (FAILED_UNEXPECTEDLY(hr))
3397                 continue;
3398 
3399             /* We should destroy our basebarsite too */
3400             hr = pdw->QueryInterface(IID_PPV_ARG(IDeskBar, &bar));
3401             if (SUCCEEDED(hr))
3402             {
3403                 hr = bar->GetClient(&pBarSite);
3404                 if (SUCCEEDED(hr) && pBarSite)
3405                 {
3406                     hr = pBarSite->QueryInterface(IID_PPV_ARG(IDeskBarClient, &pClient));
3407                     if (SUCCEEDED(hr))
3408                         pClient->SetDeskBarSite(NULL);
3409                 }
3410             }
3411             pdw->CloseDW(0);
3412 
3413             pClient = NULL;
3414             pBarSite = NULL;
3415             pdw = NULL;
3416             bar = NULL;
3417             ReleaseCComPtrExpectZero(fClientBars[i].clientBar);
3418         }
3419         ReleaseCComPtrExpectZero(fCurrentShellView);
3420         ReleaseCComPtrExpectZero(fTravelLog);
3421 
3422         fCurrentShellFolder.Release();
3423         ILFree(fCurrentDirectoryPIDL);
3424         ::DestroyWindow(fStatusBar);
3425         DestroyMenu(fCurrentMenuBar);
3426     }
3427     PostQuitMessage(0);
3428     return 0;
3429 }
3430 
3431 LRESULT CShellBrowser::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3432 {
3433     CComPtr<IDockingWindow>                 dockingWindow;
3434     RECT                                    availableBounds;
3435     static const INT                        excludeItems[] = {1, 1, 1, 0xa001, 0, 0};
3436     HRESULT                                 hResult;
3437 
3438     if (wParam != SIZE_MINIMIZED)
3439     {
3440         GetEffectiveClientRect(m_hWnd, &availableBounds, excludeItems);
3441         for (INT x = 0; x < 3; x++)
3442         {
3443             if (fClientBars[x].clientBar != NULL)
3444             {
3445                 hResult = fClientBars[x].clientBar->QueryInterface(
3446                     IID_PPV_ARG(IDockingWindow, &dockingWindow));
3447                 if (SUCCEEDED(hResult) && dockingWindow != NULL)
3448                 {
3449                     hResult = dockingWindow->ResizeBorderDW(
3450                         &availableBounds, static_cast<IDropTarget *>(this), TRUE);
3451                     break;
3452                 }
3453             }
3454         }
3455         RepositionBars();
3456     }
3457     return 1;
3458 }
3459 
3460 LRESULT CShellBrowser::OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3461 {
3462     HMENU  theMenu;
3463     LPARAM menuIndex = lParam;
3464 
3465     theMenu = reinterpret_cast<HMENU>(wParam);
3466 
3467     if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_FILE))
3468     {
3469         menuIndex = 0;
3470     }
3471     else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_EDIT))
3472     {
3473         menuIndex = 1;
3474     }
3475     else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_VIEW))
3476     {
3477         UpdateViewMenu(theMenu);
3478         menuIndex = 2;
3479     }
3480     else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_FAVORITES))
3481     {
3482         menuIndex = 3;
3483     }
3484     else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_TOOLS))
3485     {
3486         // FIXME: Remove once implemented
3487         SHEnableMenuItem(theMenu, IDM_TOOLS_MAPNETWORKDRIVE, FALSE);
3488         SHEnableMenuItem(theMenu, IDM_TOOLS_DISCONNECTNETWORKDRIVE, FALSE);
3489         SHEnableMenuItem(theMenu, IDM_TOOLS_SYNCHRONIZE, FALSE);
3490         FIXME("Folder options dialog is stubbed: CORE-11141\n");
3491         SHEnableMenuItem(theMenu, IDM_TOOLS_FOLDEROPTIONS, FALSE);  // Remove when CORE-11141 is fixed.
3492         menuIndex = 4;
3493     }
3494     else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_HELP))
3495     {
3496         menuIndex = 5;
3497     }
3498 
3499     LRESULT ret = RelayMsgToShellView(uMsg, wParam, menuIndex, bHandled);
3500 
3501     return ret;
3502 }
3503 
3504 LRESULT CShellBrowser::OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3505 {
3506     ::SetFocus(fCurrentShellViewWindow);
3507     return 0;
3508 }
3509 
3510 LRESULT CShellBrowser::RelayMsgToShellView(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3511 {
3512     if (fCurrentShellViewWindow != NULL)
3513         return SendMessage(fCurrentShellViewWindow, uMsg, wParam, lParam);
3514     return 0;
3515 }
3516 
3517 LRESULT CShellBrowser::PropagateMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3518 {
3519     SHPropagateMessage(m_hWnd, uMsg, wParam, lParam, TRUE);
3520     return 0;
3521 }
3522 
3523 LRESULT CShellBrowser::OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3524 {
3525     return SendMessage(WM_CLOSE);
3526 }
3527 
3528 LRESULT CShellBrowser::OnFolderOptions(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3529 {
3530     HRESULT hResult = DoFolderOptions();
3531     if (FAILED(hResult))
3532         TRACE("DoFolderOptions failed with hResult=%08lx\n", hResult);
3533     return 0;
3534 }
3535 
3536 LRESULT CShellBrowser::OnMapNetworkDrive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3537 {
3538 #ifndef __REACTOS__
3539     WNetConnectionDialog(m_hWnd, RESOURCETYPE_DISK);
3540 #endif /* __REACTOS__ */
3541     return 0;
3542 }
3543 
3544 LRESULT CShellBrowser::OnDisconnectNetworkDrive(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3545 {
3546 #ifndef __REACTOS__
3547     WNetDisconnectDialog(m_hWnd, RESOURCETYPE_DISK);
3548 #endif /* __REACTOS__ */
3549     return 0;
3550 }
3551 
3552 LRESULT CShellBrowser::OnAboutReactOS(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3553 {
3554     ShellAbout(m_hWnd, _T("ReactOS"), _T(""), NULL);
3555     return 0;
3556 }
3557 
3558 LRESULT CShellBrowser::OnGoBack(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3559 {
3560     HRESULT hResult = GoBack();
3561     if (FAILED(hResult))
3562         TRACE("GoBack failed with hResult=%08lx\n", hResult);
3563     return 0;
3564 }
3565 
3566 LRESULT CShellBrowser::OnGoForward(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3567 {
3568     HRESULT hResult = GoForward();
3569     if (FAILED(hResult))
3570         TRACE("GoForward failed with hResult=%08lx\n", hResult);
3571     return 0;
3572 }
3573 
3574 LRESULT CShellBrowser::OnGoUpLevel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3575 {
3576     HRESULT hResult = NavigateToParent();
3577     if (FAILED(hResult))
3578         TRACE("NavigateToParent failed with hResult=%08lx\n", hResult);
3579     return 0;
3580 }
3581 
3582 LRESULT CShellBrowser::OnGoHome(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3583 {
3584     HRESULT hResult = GoHome();
3585     if (FAILED(hResult))
3586         TRACE("GoHome failed with hResult=%08lx\n", hResult);
3587     return 0;
3588 }
3589 
3590 LRESULT CShellBrowser::OnBackspace(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3591 {
3592     // FIXME: This does not appear to be what windows does.
3593     HRESULT hResult = NavigateToParent();
3594     if (FAILED(hResult))
3595         TRACE("NavigateToParent failed with hResult=%08lx\n", hResult);
3596     return 0;
3597 }
3598 
3599 LRESULT CShellBrowser::OnOrganizeFavorites(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3600 {
3601     CComPtr<IShellFolder> psfDesktop;
3602     LPITEMIDLIST pidlFavs;
3603     HRESULT hr;
3604     hr = SHGetSpecialFolderLocation(m_hWnd, CSIDL_FAVORITES, &pidlFavs);
3605     if (FAILED(hr))
3606     {
3607         hr = SHGetSpecialFolderLocation(m_hWnd, CSIDL_COMMON_FAVORITES, &pidlFavs);
3608         if (FAILED(hr))
3609             return 0;
3610     }
3611 
3612     hr = SHGetDesktopFolder(&psfDesktop);
3613     if (FAILED_UNEXPECTEDLY(hr))
3614         return 0;
3615 
3616     hr = SHInvokeDefaultCommand(m_hWnd, psfDesktop, pidlFavs);
3617     if (FAILED_UNEXPECTEDLY(hr))
3618         return 0;
3619 
3620     return 0;
3621 }
3622 
3623 LRESULT CShellBrowser::OnToggleStatusBarVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3624 {
3625     fStatusBarVisible = !fStatusBarVisible;
3626     if (fStatusBar)
3627     {
3628         ::ShowWindow(fStatusBar, fStatusBarVisible ? SW_SHOW : SW_HIDE);
3629         RepositionBars();
3630     }
3631     return 0;
3632 }
3633 
3634 LRESULT CShellBrowser::OnToggleToolbarLock(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3635 {
3636     HRESULT hResult;
3637     hResult = IUnknown_Exec(fClientBars[BIInternetToolbar].clientBar,
3638                             CGID_PrivCITCommands, ITID_TOOLBARLOCKED, 0, NULL, NULL);
3639     return 0;
3640 }
3641 
3642 LRESULT CShellBrowser::OnToggleToolbarBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3643 {
3644     HRESULT hResult;
3645     hResult = IUnknown_Exec(fClientBars[BIInternetToolbar].clientBar,
3646                             CGID_PrivCITCommands, ITID_TOOLBARBANDSHOWN, 0, NULL, NULL);
3647     return 0;
3648 }
3649 
3650 LRESULT CShellBrowser::OnToggleAddressBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3651 {
3652     HRESULT hResult;
3653     hResult = IUnknown_Exec(fClientBars[BIInternetToolbar].clientBar,
3654                             CGID_PrivCITCommands, ITID_ADDRESSBANDSHOWN, 0, NULL, NULL);
3655     return 0;
3656 }
3657 
3658 LRESULT CShellBrowser::OnToggleLinksBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3659 {
3660     HRESULT hResult;
3661     hResult = IUnknown_Exec(fClientBars[BIInternetToolbar].clientBar,
3662                             CGID_PrivCITCommands, ITID_LINKSBANDSHOWN, 0, NULL, NULL);
3663     return 0;
3664 }
3665 
3666 LRESULT CShellBrowser::OnToggleTextLabels(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3667 {
3668     HRESULT hResult;
3669     hResult = IUnknown_Exec(fClientBars[BIInternetToolbar].clientBar,
3670                             CGID_PrivCITCommands, ITID_TEXTLABELS, 0, NULL, NULL);
3671     return 0;
3672 }
3673 
3674 LRESULT CShellBrowser::OnToolbarCustomize(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3675 {
3676     HRESULT hResult;
3677     hResult = IUnknown_Exec(fClientBars[BIInternetToolbar].clientBar,
3678                             CGID_PrivCITCommands, ITID_CUSTOMIZEENABLED, 0, NULL, NULL);
3679     return 0;
3680 }
3681 
3682 LRESULT CShellBrowser::OnRefresh(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3683 {
3684     if (fCurrentShellView)
3685         fCurrentShellView->Refresh();
3686     return 0;
3687 }
3688 
3689 LRESULT CShellBrowser::OnGoTravel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3690 {
3691     return 0;
3692 }
3693 
3694 LRESULT CShellBrowser::OnExplorerBar(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
3695 {
3696     // TODO: HACK ! use the proper mechanism to show the band (i.e. pass the BSTR to basebar)
3697     if (wID >= IDM_EXPLORERBAND_BEGINCUSTOM && wID <= IDM_EXPLORERBAND_ENDCUSTOM)
3698     {
3699         MenuBandInfo *mbi;
3700         mbi = (MenuBandInfo*)DSA_GetItemPtr(menuDsa, (wID - IDM_EXPLORERBAND_BEGINCUSTOM));
3701         if (!mbi)
3702             return 0;
3703         ShowBand(mbi->barGuid, mbi->fVertical);
3704         bHandled = TRUE;
3705         return 1;
3706     }
3707     switch (wID)
3708     {
3709     case IDM_EXPLORERBAR_SEARCH:
3710         Exec(&CLSID_CommonButtons, 0x123, 1, NULL, NULL);
3711         break;
3712     case IDM_EXPLORERBAR_FOLDERS:
3713         ShowBand(CLSID_ExplorerBand, true);
3714         break;
3715     case IDM_EXPLORERBAR_HISTORY:
3716         ShowBand(CLSID_SH_HistBand, true);
3717         break;
3718     case IDM_EXPLORERBAR_FAVORITES:
3719         ShowBand(CLSID_SH_FavBand, true);
3720         break;
3721     default:
3722         WARN("Unknown id %x\n", wID);
3723     }
3724     bHandled = TRUE;
3725     return 1;
3726 }
3727 
3728 LRESULT CShellBrowser::RelayCommands(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3729 {
3730     if (HIWORD(wParam) == 0 && LOWORD(wParam) < FCIDM_SHVIEWLAST && fCurrentShellViewWindow != NULL)
3731         return SendMessage(fCurrentShellViewWindow, uMsg, wParam, lParam);
3732     return 0;
3733 }
3734 
3735 HRESULT CShellBrowser_CreateInstance(LPITEMIDLIST pidl, DWORD dwFlags, REFIID riid, void **ppv)
3736 {
3737     return ShellObjectCreatorInit<CShellBrowser>(pidl, dwFlags, riid, ppv);
3738 }
3739