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