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