[EXPLORER-NEW]
[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 = NULL;
901 STRRET L108;
902 HRESULT hResult;
903
904 hResult = SHBindToFolderIDListParent(NULL, pidl, &IID_PPV_ARG(IShellFolder, &parentFolder), &childPIDL);
905 if (FAILED(hResult))
906 goto cleanup;
907
908 hResult = parentFolder->GetDisplayNameOf(childPIDL, uFlags, &L108);
909 if (FAILED(hResult))
910 goto cleanup;
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 goto cleanup;
918 }
919
920 hResult = S_OK;
921
922 cleanup:
923 if (childPIDL)
924 ILFree(childPIDL);
925 return hResult;
926 }
927
928 long IEGetNameAndFlags(LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
929 {
930 return IEGetNameAndFlagsEx(pidl, uFlags, 0, pszBuf, cchBuf, rgfInOut);
931 }
932
933 HRESULT CShellBrowser::BrowseToPath(IShellFolder *newShellFolder,
934 LPCITEMIDLIST absolutePIDL, FOLDERSETTINGS *folderSettings, long flags)
935 {
936 CComPtr<IObjectWithSite> objectWithSite;
937 CComPtr<IShellFolder> saveCurrentShellFolder;
938 CComPtr<IShellView> saveCurrentShellView;
939 CComPtr<IShellView> newShellView;
940 CComPtr<ITravelLog> travelLog;
941 HWND newShellViewWindow;
942 BOOL windowUpdateIsLocked;
943 RECT shellViewWindowBounds;
944 HWND previousView;
945 HCURSOR saveCursor;
946 wchar_t newTitle[MAX_PATH];
947 SHGDNF nameFlags;
948 HRESULT hResult;
949
950 if (newShellFolder == NULL)
951 return E_INVALIDARG;
952
953 hResult = GetTravelLog(&travelLog);
954 if (FAILED_UNEXPECTEDLY(hResult))
955 return hResult;
956
957 // update history
958 if (flags & BTP_UPDATE_CUR_HISTORY)
959 {
960 if (travelLog->CountEntries(static_cast<IDropTarget *>(this)) > 0)
961 hResult = travelLog->UpdateEntry(static_cast<IDropTarget *>(this), FALSE);
962 // what to do with error? Do we want to halt browse because state save failed?
963 }
964
965 if (fCurrentShellView)
966 {
967 fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
968 }
969
970 // create view object
971 hResult = newShellFolder->CreateViewObject(m_hWnd, IID_PPV_ARG(IShellView, &newShellView));
972 if (FAILED_UNEXPECTEDLY(hResult))
973 return hResult;
974 previousView = fCurrentShellViewWindow;
975
976 // enter updating section
977 saveCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
978 windowUpdateIsLocked = LockWindowUpdate(TRUE);
979 if (fCurrentShellView != NULL)
980 ::SendMessage(fCurrentShellViewWindow, WM_SETREDRAW, 0, 0);
981
982 // set site
983 hResult = newShellView->QueryInterface(IID_PPV_ARG(IObjectWithSite, &objectWithSite));
984 if (SUCCEEDED(hResult) && objectWithSite.p != NULL)
985 hResult = objectWithSite->SetSite(static_cast<IDropTarget *>(this));
986
987 // update folder and view
988 saveCurrentShellFolder = fCurrentShellFolder;
989 saveCurrentShellView = fCurrentShellView;
990 fCurrentShellFolder = newShellFolder;
991 fCurrentShellView = newShellView;
992
993 // get boundary
994 if (previousView != NULL)
995 ::GetWindowRect(previousView, &shellViewWindowBounds);
996 else
997 ZeroMemory(&shellViewWindowBounds, sizeof(shellViewWindowBounds));
998 ::MapWindowPoints(0, m_hWnd, reinterpret_cast<POINT *>(&shellViewWindowBounds), 2);
999
1000 // create view window
1001 hResult = newShellView->CreateViewWindow(saveCurrentShellView, folderSettings,
1002 this, &shellViewWindowBounds, &newShellViewWindow);
1003 if (FAILED_UNEXPECTEDLY(hResult) || newShellViewWindow == NULL)
1004 {
1005 fCurrentShellView = saveCurrentShellView;
1006 fCurrentShellFolder = saveCurrentShellFolder;
1007 ::SendMessage(fCurrentShellViewWindow, WM_SETREDRAW, 1, 0);
1008 if (windowUpdateIsLocked)
1009 LockWindowUpdate(FALSE);
1010 SetCursor(saveCursor);
1011 return hResult;
1012 }
1013
1014 if (objectWithSite.p != NULL)
1015 hResult = objectWithSite->SetSite(NULL);
1016
1017 // update current pidl
1018 ILFree(fCurrentDirectoryPIDL);
1019 fCurrentDirectoryPIDL = ILClone(absolutePIDL);
1020
1021 // update view window
1022 if (saveCurrentShellView != NULL)
1023 saveCurrentShellView->DestroyViewWindow();
1024 fCurrentShellViewWindow = newShellViewWindow;
1025
1026 // no use
1027 saveCurrentShellView.Release();
1028 saveCurrentShellFolder.Release();
1029
1030 hResult = newShellView->UIActivate(SVUIA_ACTIVATE_FOCUS);
1031
1032 // leave updating section
1033 if (windowUpdateIsLocked)
1034 LockWindowUpdate(FALSE);
1035 SetCursor(saveCursor);
1036
1037 // update history
1038 if (flags & BTP_UPDATE_NEXT_HISTORY)
1039 {
1040 hResult = travelLog->AddEntry(static_cast<IDropTarget *>(this), FALSE);
1041 hResult = travelLog->UpdateEntry(static_cast<IDropTarget *>(this), FALSE);
1042 }
1043
1044 // completed
1045 nameFlags = SHGDN_FORADDRESSBAR | SHGDN_FORPARSING;
1046 hResult = IEGetNameAndFlags(fCurrentDirectoryPIDL, nameFlags, newTitle,
1047 sizeof(newTitle) / sizeof(wchar_t), NULL);
1048 if (SUCCEEDED(hResult))
1049 {
1050 FireNavigateComplete(newTitle);
1051 }
1052 else
1053 {
1054 FireNavigateComplete(L"ERROR");
1055 }
1056
1057 if (fCabinetState.fFullPathTitle)
1058 nameFlags = SHGDN_FORADDRESSBAR | SHGDN_FORPARSING;
1059 else
1060 nameFlags = SHGDN_FORADDRESSBAR;
1061 hResult = IEGetNameAndFlags(fCurrentDirectoryPIDL, nameFlags, newTitle,
1062 sizeof(newTitle) / sizeof(wchar_t), NULL);
1063 if (SUCCEEDED(hResult))
1064 {
1065 SetWindowText(newTitle);
1066
1067 LPCITEMIDLIST pidlChild;
1068 INT index, indexOpen;
1069 HIMAGELIST himlSmall, himlLarge;
1070
1071 CComPtr<IShellFolder> sf;
1072 SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
1073
1074 index = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
1075
1076 Shell_GetImageLists(&himlLarge, &himlSmall);
1077
1078 HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
1079 HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
1080
1081 /* Hack to make it possible to release the old icons */
1082 /* Something seems to go wrong with WM_SETICON */
1083 HICON oldSmall = (HICON)SendMessage(WM_GETICON, ICON_SMALL, 0);
1084 HICON oldLarge = (HICON)SendMessage(WM_GETICON, ICON_BIG, 0);
1085
1086 SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icSmall));
1087 SendMessage(WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icLarge));
1088
1089 DestroyIcon(oldSmall);
1090 DestroyIcon(oldLarge);
1091 }
1092
1093 FireCommandStateChangeAll();
1094 hResult = UpdateForwardBackState();
1095 return S_OK;
1096 }
1097
1098 HRESULT CShellBrowser::GetMenuBand(REFIID riid, void **shellMenu)
1099 {
1100 CComPtr<IServiceProvider> serviceProvider;
1101 CComPtr<IBandSite> bandSite;
1102 CComPtr<IDeskBand> deskBand;
1103 HRESULT hResult;
1104
1105 if (!fClientBars[BIInternetToolbar].clientBar)
1106 return E_FAIL;
1107
1108 hResult = IUnknown_QueryService(fClientBars[BIInternetToolbar].clientBar, SID_IBandSite, IID_PPV_ARG(IBandSite, &bandSite));
1109 if (FAILED_UNEXPECTEDLY(hResult))
1110 return hResult;
1111
1112 hResult = bandSite->QueryBand(1, &deskBand, NULL, NULL, 0);
1113 if (FAILED_UNEXPECTEDLY(hResult))
1114 return hResult;
1115
1116 return deskBand->QueryInterface(riid, shellMenu);
1117 }
1118
1119 HRESULT CShellBrowser::GetBaseBar(bool vertical, IUnknown **theBaseBar)
1120 {
1121 CComPtr<IUnknown> newBaseBar;
1122 CComPtr<IDeskBar> deskBar;
1123 CComPtr<IUnknown> newBaseBarSite;
1124 CComPtr<IObjectWithSite> objectWithSite;
1125 CComPtr<IDeskBarClient> deskBarClient;
1126 IUnknown **cache;
1127 HRESULT hResult;
1128
1129 if (vertical)
1130 cache = &fClientBars[BIVerticalBaseBar].clientBar.p;
1131 else
1132 cache = &fClientBars[BIHorizontalBaseBar].clientBar.p;
1133 if (*cache == NULL)
1134 {
1135 hResult = CreateBaseBar(IID_PPV_ARG(IUnknown, &newBaseBar));
1136 if (FAILED_UNEXPECTEDLY(hResult))
1137 return hResult;
1138 hResult = CreateBaseBarSite(IID_PPV_ARG(IUnknown, &newBaseBarSite));
1139 if (FAILED_UNEXPECTEDLY(hResult))
1140 return hResult;
1141
1142 // tell the new base bar about the shell browser
1143 hResult = newBaseBar->QueryInterface(IID_PPV_ARG(IObjectWithSite, &objectWithSite));
1144 if (FAILED_UNEXPECTEDLY(hResult))
1145 return hResult;
1146 hResult = objectWithSite->SetSite(static_cast<IDropTarget *>(this));
1147 if (FAILED_UNEXPECTEDLY(hResult))
1148 return hResult;
1149
1150 // tell the new base bar about the new base bar site
1151 hResult = newBaseBar->QueryInterface(IID_PPV_ARG(IDeskBar, &deskBar));
1152 if (FAILED_UNEXPECTEDLY(hResult))
1153 return hResult;
1154 hResult = deskBar->SetClient(newBaseBarSite);
1155 if (FAILED_UNEXPECTEDLY(hResult))
1156 return hResult;
1157
1158 // tell the new base bar site about the new base bar
1159 hResult = newBaseBarSite->QueryInterface(IID_PPV_ARG(IDeskBarClient, &deskBarClient));
1160 if (FAILED_UNEXPECTEDLY(hResult))
1161 return hResult;
1162 hResult = deskBarClient->SetDeskBarSite(newBaseBar);
1163 if (FAILED_UNEXPECTEDLY(hResult))
1164 return hResult;
1165
1166 *cache = newBaseBar.Detach();
1167 }
1168 return (*cache)->QueryInterface(IID_PPV_ARG(IUnknown, theBaseBar));
1169 }
1170
1171 HRESULT CShellBrowser::ShowBand(const CLSID &classID, bool vertical)
1172 {
1173 CComPtr<IDockingWindow> dockingWindow;
1174 CComPtr<IOleCommandTarget> oleCommandTarget;
1175 CComPtr<IUnknown> baseBarSite;
1176 CComPtr<IUnknown> newBand;
1177 CComPtr<IUnknown> theBaseBar;
1178 CComPtr<IDeskBar> deskBar;
1179 VARIANT vaIn;
1180 HRESULT hResult;
1181
1182 __debugbreak();
1183
1184 hResult = GetBaseBar(vertical, (IUnknown **)&theBaseBar);
1185 if (FAILED_UNEXPECTEDLY(hResult))
1186 return hResult;
1187 hResult = CoCreateInstance(classID, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IUnknown, &newBand));
1188 if (FAILED_UNEXPECTEDLY(hResult))
1189 return hResult;
1190 hResult = theBaseBar->QueryInterface(IID_PPV_ARG(IDeskBar, &deskBar));
1191 if (FAILED_UNEXPECTEDLY(hResult))
1192 return hResult;
1193 hResult = deskBar->GetClient(&baseBarSite);
1194 if (FAILED_UNEXPECTEDLY(hResult))
1195 return hResult;
1196 hResult = theBaseBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
1197 if (FAILED_UNEXPECTEDLY(hResult))
1198 return hResult;
1199 hResult = baseBarSite->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &oleCommandTarget));
1200 if (FAILED_UNEXPECTEDLY(hResult))
1201 return hResult;
1202 V_VT(&vaIn) = VT_UNKNOWN;
1203 V_UNKNOWN(&vaIn) = newBand.p;
1204 hResult = oleCommandTarget->Exec(&CGID_IDeskBand, 1, 1, &vaIn, NULL);
1205 if (FAILED_UNEXPECTEDLY(hResult))
1206 return hResult;
1207 hResult = dockingWindow->ShowDW(TRUE);
1208 if (FAILED_UNEXPECTEDLY(hResult))
1209 return hResult;
1210 return S_OK;
1211 }
1212
1213 HRESULT CShellBrowser::NavigateToParent()
1214 {
1215 LPITEMIDLIST newDirectory;
1216 HRESULT hResult;
1217
1218 newDirectory = ILClone(fCurrentDirectoryPIDL);
1219 if (newDirectory == NULL)
1220 return E_OUTOFMEMORY;
1221 ILRemoveLastID(newDirectory);
1222 hResult = BrowseToPIDL(newDirectory, BTP_UPDATE_CUR_HISTORY | BTP_UPDATE_NEXT_HISTORY);
1223 ILFree(newDirectory);
1224 if (FAILED_UNEXPECTEDLY(hResult))
1225 return hResult;
1226 return S_OK;
1227 }
1228
1229 BOOL CALLBACK AddFolderOptionsPage(HPROPSHEETPAGE thePage, LPARAM lParam)
1230 {
1231 PROPSHEETHEADER *sheetInfo;
1232
1233 sheetInfo = (PROPSHEETHEADER *)lParam;
1234 if (sheetInfo->nPages >= folderOptionsPageCountMax)
1235 return FALSE;
1236 sheetInfo->phpage[sheetInfo->nPages] = thePage;
1237 sheetInfo->nPages++;
1238 return TRUE;
1239 }
1240
1241 HRESULT CShellBrowser::DoFolderOptions()
1242 {
1243 CComPtr<IShellPropSheetExt> folderOptionsSheet;
1244 CComPtr<IObjectWithSite> objectWithSite;
1245 PROPSHEETHEADER m_PropSheet;
1246 HPROPSHEETPAGE m_psp[folderOptionsPageCountMax];
1247 // CComPtr<IGlobalFolderSettings> globalSettings;
1248 // SHELLSTATE2 shellState;
1249 HRESULT hResult;
1250
1251 memset(m_psp, 0, sizeof(m_psp));
1252 memset(&m_PropSheet, 0, sizeof(m_PropSheet));
1253
1254 // create sheet object
1255 hResult = CoCreateInstance(CLSID_ShellFldSetExt, NULL, CLSCTX_INPROC_SERVER,
1256 IID_PPV_ARG(IShellPropSheetExt, &folderOptionsSheet));
1257 if (FAILED_UNEXPECTEDLY(hResult))
1258 return E_FAIL;
1259
1260 // must set site in order for Apply to all Folders on Advanced page to be enabled
1261 hResult = folderOptionsSheet->QueryInterface(IID_PPV_ARG(IObjectWithSite, &objectWithSite));
1262 if (SUCCEEDED(hResult) && objectWithSite.p != NULL)
1263 hResult = objectWithSite->SetSite(static_cast<IDispatch *>(this));
1264 m_PropSheet.phpage = m_psp;
1265
1266 #if 0
1267 hResult = CoCreateInstance(CLSID_GlobalFolderSettings, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IGlobalFolderSettings, &globalSettings));
1268 if (FAILED_UNEXPECTEDLY(hResult))
1269 return E_FAIL;
1270 hResult = globalSettings->Get(&shellState, sizeof(shellState));
1271 if (FAILED_UNEXPECTEDLY(hResult))
1272 return E_FAIL;
1273 #endif
1274
1275 // add pages
1276 hResult = folderOptionsSheet->AddPages(AddFolderOptionsPage, reinterpret_cast<LPARAM>(&m_PropSheet));
1277 if (FAILED_UNEXPECTEDLY(hResult))
1278 return E_FAIL;
1279
1280 if (fCurrentShellView != NULL)
1281 {
1282 hResult = fCurrentShellView->AddPropertySheetPages(
1283 0, AddFolderOptionsPage, reinterpret_cast<LPARAM>(&m_PropSheet));
1284 if (FAILED_UNEXPECTEDLY(hResult))
1285 return E_FAIL;
1286 }
1287
1288 // show sheet
1289 m_PropSheet.dwSize = sizeof(PROPSHEETHEADER);
1290 m_PropSheet.dwFlags = 0;
1291 m_PropSheet.hwndParent = m_hWnd;
1292 m_PropSheet.hInstance = _AtlBaseModule.GetResourceInstance();
1293 m_PropSheet.pszCaption = _T("Folder Options");
1294 m_PropSheet.nStartPage = 0;
1295 PropertySheet(&m_PropSheet);
1296 return S_OK;
1297 }
1298
1299 LRESULT CALLBACK CShellBrowser::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1300 {
1301 CShellBrowser *pThis = reinterpret_cast<CShellBrowser *>(hWnd);
1302 _ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
1303 LRESULT lResult;
1304 const _ATL_MSG *previousMessage;
1305 BOOL handled;
1306 WNDPROC saveWindowProc;
1307 HRESULT hResult;
1308
1309 hWnd = pThis->m_hWnd;
1310 previousMessage = pThis->m_pCurrentMsg;
1311 pThis->m_pCurrentMsg = &msg;
1312
1313 CComPtr<IMenuBand> menuBand;
1314 hResult = pThis->GetMenuBand(IID_PPV_ARG(IMenuBand, &menuBand));
1315 if (SUCCEEDED(hResult) && menuBand.p != NULL)
1316 {
1317 hResult = menuBand->TranslateMenuMessage(&msg, &lResult);
1318 if (hResult == S_OK)
1319 return lResult;
1320 uMsg = msg.message;
1321 wParam = msg.wParam;
1322 lParam = msg.lParam;
1323 }
1324 menuBand.Release();
1325
1326 handled = pThis->ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, 0);
1327 ATLASSERT(pThis->m_pCurrentMsg == &msg);
1328 if (handled == FALSE)
1329 {
1330 if (uMsg == WM_NCDESTROY)
1331 {
1332 saveWindowProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hWnd, GWL_WNDPROC));
1333 lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1334 if (saveWindowProc == reinterpret_cast<WNDPROC>(GetWindowLongPtr(hWnd, GWL_WNDPROC)))
1335 SetWindowLongPtr(hWnd, GWL_WNDPROC, (LONG_PTR)pThis->m_pfnSuperWindowProc);
1336 pThis->m_dwState |= WINSTATE_DESTROYED;
1337 }
1338 else
1339 lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1340 }
1341 pThis->m_pCurrentMsg = previousMessage;
1342 if (previousMessage == NULL && (pThis->m_dwState & WINSTATE_DESTROYED) != 0)
1343 {
1344 pThis->m_dwState &= ~WINSTATE_DESTROYED;
1345 pThis->m_hWnd = NULL;
1346 pThis->OnFinalMessage(hWnd);
1347 }
1348 return lResult;
1349 }
1350
1351 void CShellBrowser::RepositionBars()
1352 {
1353 RECT clientRect;
1354 RECT statusRect;
1355 int x;
1356
1357 GetClientRect(&clientRect);
1358
1359 if (fStatusBarVisible && fStatusBar)
1360 {
1361 ::GetWindowRect(fStatusBar, &statusRect);
1362 ::SetWindowPos(fStatusBar, NULL, clientRect.left, clientRect.bottom - (statusRect.bottom - statusRect.top),
1363 clientRect.right - clientRect.left,
1364 statusRect.bottom - statusRect.top, SWP_NOOWNERZORDER | SWP_NOZORDER);
1365 clientRect.bottom -= statusRect.bottom - statusRect.top;
1366 }
1367
1368 for (x = 0; x < 3; x++)
1369 {
1370 HWND hwnd = fClientBars[x].hwnd;
1371 RECT borderSpace = fClientBars[x].borderSpace;
1372 if (hwnd == NULL && fClientBars[x].clientBar != NULL)
1373 {
1374 IUnknown_GetWindow(fClientBars[x].clientBar, &hwnd);
1375 fClientBars[x].hwnd = hwnd;
1376 }
1377 if (hwnd != NULL)
1378 {
1379 RECT toolbarRect = clientRect;
1380 if (borderSpace.top != 0)
1381 {
1382 toolbarRect.bottom = toolbarRect.top + borderSpace.top;
1383 }
1384 else if (borderSpace.bottom != 0)
1385 {
1386 toolbarRect.top = toolbarRect.bottom - borderSpace.bottom;
1387 }
1388 else if (borderSpace.left != 0)
1389 {
1390 toolbarRect.right = toolbarRect.left + borderSpace.left;
1391 }
1392 else if (borderSpace.right != 0)
1393 {
1394 toolbarRect.left = toolbarRect.right - borderSpace.right;
1395 }
1396
1397 ::SetWindowPos(hwnd, NULL,
1398 toolbarRect.left,
1399 toolbarRect.top,
1400 toolbarRect.right - toolbarRect.left,
1401 toolbarRect.bottom - toolbarRect.top,
1402 SWP_NOOWNERZORDER | SWP_NOZORDER);
1403
1404 if (borderSpace.top != 0)
1405 {
1406 clientRect.top = toolbarRect.bottom;
1407 }
1408 else if (borderSpace.bottom != 0)
1409 {
1410 clientRect.bottom = toolbarRect.top;
1411 }
1412 else if (borderSpace.left != 0)
1413 {
1414 clientRect.left = toolbarRect.right;
1415 }
1416 else if (borderSpace.right != 0)
1417 {
1418 clientRect.right = toolbarRect.left;
1419 }
1420 }
1421 }
1422 ::SetWindowPos(fCurrentShellViewWindow, NULL, clientRect.left, clientRect.top,
1423 clientRect.right - clientRect.left,
1424 clientRect.bottom - clientRect.top, SWP_NOOWNERZORDER | SWP_NOZORDER);
1425 }
1426
1427 HRESULT CShellBrowser::FireEvent(DISPID dispIdMember, int argCount, VARIANT *arguments)
1428 {
1429 DISPPARAMS params;
1430 CComDynamicUnkArray &vec = IConnectionPointImpl<CShellBrowser, &DIID_DWebBrowserEvents2>::m_vec;
1431 CComDynamicUnkArray &vec2 = IConnectionPointImpl<CShellBrowser, &DIID_DWebBrowserEvents>::m_vec;
1432 HRESULT hResult;
1433
1434 params.rgvarg = arguments;
1435 params.rgdispidNamedArgs = NULL;
1436 params.cArgs = argCount;
1437 params.cNamedArgs = 0;
1438 IUnknown** pp = vec.begin();
1439 while (pp < vec.end())
1440 {
1441 if (*pp != NULL)
1442 {
1443 CComPtr<IDispatch> theDispatch;
1444
1445 hResult = (*pp)->QueryInterface(IID_PPV_ARG(IDispatch, &theDispatch));
1446 hResult = theDispatch->Invoke(dispIdMember, GUID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, NULL);
1447 }
1448 pp++;
1449 }
1450 pp = vec2.begin();
1451 while (pp < vec2.end())
1452 {
1453 if (*pp != NULL)
1454 {
1455 CComPtr<IDispatch> theDispatch;
1456
1457 hResult = (*pp)->QueryInterface(IID_PPV_ARG(IDispatch, &theDispatch));
1458 hResult = theDispatch->Invoke(dispIdMember, GUID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, NULL);
1459 }
1460 pp++;
1461 }
1462 return S_OK;
1463 }
1464
1465 HRESULT CShellBrowser::FireNavigateComplete(const wchar_t *newDirectory)
1466 {
1467 // these two variants intentionally to do use CComVariant because it would double free/release
1468 // or does not need to dispose at all
1469 VARIANT varArg[2];
1470 VARIANT varArgs;
1471 CComBSTR tempString(newDirectory);
1472
1473 V_VT(&varArgs) = VT_BSTR;
1474 V_BSTR(&varArgs) = tempString.m_str;
1475
1476 V_VT(&varArg[0]) = VT_VARIANT | VT_BYREF;
1477 V_VARIANTREF(&varArg[0]) = &varArgs;
1478 V_VT(&varArg[1]) = VT_DISPATCH;
1479 V_DISPATCH(&varArg[1]) = (IDispatch *)this;
1480
1481 return FireEvent(DISPID_NAVIGATECOMPLETE2, 2, varArg);
1482 }
1483
1484 HRESULT CShellBrowser::FireCommandStateChange(bool newState, int commandID)
1485 {
1486 VARIANT varArg[2];
1487
1488 V_VT(&varArg[0]) = VT_BOOL;
1489 V_BOOL(&varArg[0]) = newState ? VARIANT_TRUE : VARIANT_FALSE;
1490 V_VT(&varArg[1]) = VT_I4;
1491 V_I4(&varArg[1]) = commandID;
1492
1493 return FireEvent(DISPID_COMMANDSTATECHANGE, 2, varArg);
1494 }
1495
1496 HRESULT CShellBrowser::FireCommandStateChangeAll()
1497 {
1498 return FireCommandStateChange(false, -1);
1499 }
1500
1501 HRESULT CShellBrowser::UpdateForwardBackState()
1502 {
1503 CComPtr<ITravelLog> travelLog;
1504 CComPtr<ITravelEntry> unusedEntry;
1505 bool canGoBack;
1506 bool canGoForward;
1507 HRESULT hResult;
1508
1509 canGoBack = false;
1510 canGoForward = false;
1511 hResult = GetTravelLog(&travelLog);
1512 if (FAILED_UNEXPECTEDLY(hResult))
1513 return hResult;
1514 hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this), TLOG_BACK, &unusedEntry);
1515 if (SUCCEEDED(hResult))
1516 {
1517 canGoBack = true;
1518 unusedEntry.Release();
1519 }
1520 hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this), TLOG_FORE, &unusedEntry);
1521 if (SUCCEEDED(hResult))
1522 {
1523 canGoForward = true;
1524 unusedEntry.Release();
1525 }
1526 hResult = FireCommandStateChange(canGoBack, 2);
1527 hResult = FireCommandStateChange(canGoForward, 1);
1528 return S_OK;
1529 }
1530
1531 void CShellBrowser::UpdateGotoMenu(HMENU theMenu)
1532 {
1533 CComPtr<ITravelLog> travelLog;
1534 int position;
1535 MENUITEMINFO menuItemInfo;
1536 HRESULT hResult;
1537
1538 DeleteMenuItems(theMenu, IDM_GOTO_TRAVEL_FIRST, IDM_GOTO_TRAVEL_LAST);
1539
1540 position = GetMenuItemCount(theMenu);
1541 hResult = GetTravelLog(&travelLog);
1542 if (FAILED_UNEXPECTEDLY(hResult))
1543 return;
1544 hResult = travelLog->InsertMenuEntries(static_cast<IDropTarget *>(this), theMenu, position,
1545 IDM_GOTO_TRAVEL_FIRSTTARGET, IDM_GOTO_TRAVEL_LASTTARGET, TLMENUF_BACKANDFORTH | TLMENUF_CHECKCURRENT);
1546 if (SUCCEEDED(hResult))
1547 {
1548 menuItemInfo.cbSize = sizeof(menuItemInfo);
1549 menuItemInfo.fMask = MIIM_TYPE | MIIM_ID;
1550 menuItemInfo.fType = MF_SEPARATOR;
1551 menuItemInfo.wID = IDM_GOTO_TRAVEL_SEP;
1552 InsertMenuItem(theMenu, position, TRUE, &menuItemInfo);
1553 }
1554 }
1555
1556 void CShellBrowser::UpdateViewMenu(HMENU theMenu)
1557 {
1558 CComPtr<IOleCommandTarget> oleCommandTarget;
1559 CComPtr<ITravelLog> travelLog;
1560 HMENU gotoMenu;
1561 OLECMD commandList[5];
1562 HMENU toolbarMenuBar;
1563 HMENU toolbarMenu;
1564 MENUITEMINFO menuItemInfo;
1565 HRESULT hResult;
1566
1567 gotoMenu = SHGetMenuFromID(theMenu, FCIDM_MENU_EXPLORE);
1568 if (gotoMenu != NULL)
1569 UpdateGotoMenu(gotoMenu);
1570
1571 commandList[0].cmdID = ITID_TOOLBARBANDSHOWN;
1572 commandList[1].cmdID = ITID_ADDRESSBANDSHOWN;
1573 commandList[2].cmdID = ITID_LINKSBANDSHOWN;
1574 commandList[3].cmdID = ITID_TOOLBARLOCKED;
1575 commandList[4].cmdID = ITID_CUSTOMIZEENABLED;
1576
1577 hResult = fClientBars[BIInternetToolbar].clientBar->QueryInterface(
1578 IID_PPV_ARG(IOleCommandTarget, &oleCommandTarget));
1579 if (SUCCEEDED(hResult))
1580 hResult = oleCommandTarget->QueryStatus(&CGID_PrivCITCommands, 5, commandList, NULL);
1581 if (FAILED_UNEXPECTEDLY(hResult))
1582 DeleteMenu(theMenu, IDM_VIEW_TOOLBARS, MF_BYCOMMAND);
1583 else
1584 {
1585 menuItemInfo.cbSize = sizeof(menuItemInfo);
1586 menuItemInfo.fMask = MIIM_SUBMENU;
1587 GetMenuItemInfo(theMenu, IDM_VIEW_TOOLBARS, FALSE, &menuItemInfo);
1588 DestroyMenu(menuItemInfo.hSubMenu);
1589
1590 toolbarMenuBar = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_CONTEXTMENU));
1591 toolbarMenu = GetSubMenu(toolbarMenuBar, 0);
1592 RemoveMenu(toolbarMenuBar, 0, MF_BYPOSITION);
1593 DestroyMenu(toolbarMenuBar);
1594
1595 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_STANDARDBUTTONS, commandList[0].cmdf);
1596 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_ADDRESSBAR, commandList[1].cmdf & OLECMDF_ENABLED);
1597 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_LINKSBAR, commandList[2].cmdf & OLECMDF_ENABLED);
1598 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_LOCKTOOLBARS, commandList[3].cmdf & OLECMDF_ENABLED);
1599 if ((commandList[4].cmdf & OLECMDF_ENABLED) == 0)
1600 DeleteMenu(toolbarMenu, IDM_TOOLBARS_CUSTOMIZE, MF_BYCOMMAND);
1601 DeleteMenu(toolbarMenu, IDM_TOOLBARS_TEXTLABELS, MF_BYCOMMAND);
1602 DeleteMenu(toolbarMenu, IDM_TOOLBARS_GOBUTTON, MF_BYCOMMAND);
1603
1604 menuItemInfo.cbSize = sizeof(menuItemInfo);
1605 menuItemInfo.fMask = MIIM_SUBMENU;
1606 menuItemInfo.hSubMenu = toolbarMenu;
1607 SetMenuItemInfo(theMenu, IDM_VIEW_TOOLBARS, FALSE, &menuItemInfo);
1608 }
1609 SHCheckMenuItem(theMenu, IDM_VIEW_STATUSBAR, fStatusBarVisible ? TRUE : FALSE);
1610 }
1611
1612 bool IUnknownIsEqual(IUnknown *int1, IUnknown *int2)
1613 {
1614 CComPtr<IUnknown> int1Retry;
1615 CComPtr<IUnknown> int2Retry;
1616 HRESULT hResult;
1617
1618 if (int1 == int2)
1619 return true;
1620 if (int1 == NULL || int2 == NULL)
1621 return false;
1622 hResult = int1->QueryInterface(IID_PPV_ARG(IUnknown, &int1Retry));
1623 if (FAILED_UNEXPECTEDLY(hResult))
1624 return false;
1625 hResult = int2->QueryInterface(IID_PPV_ARG(IUnknown, &int2Retry));
1626 if (FAILED_UNEXPECTEDLY(hResult))
1627 return false;
1628 if (int1Retry == int2Retry)
1629 return true;
1630 return false;
1631 }
1632
1633 HRESULT STDMETHODCALLTYPE CShellBrowser::GetBorderDW(IUnknown *punkObj, LPRECT prcBorder)
1634 {
1635 static const INT excludeItems[] = { 1, 1, 1, 0xa001, 0, 0 };
1636
1637 RECT availableBounds;
1638
1639 GetEffectiveClientRect(m_hWnd, &availableBounds, excludeItems);
1640 for (INT x = 0; x < 3; x++)
1641 {
1642 if (fClientBars[x].clientBar.p != NULL && !IUnknownIsEqual(fClientBars[x].clientBar, punkObj))
1643 {
1644 availableBounds.top += fClientBars[x].borderSpace.top;
1645 availableBounds.left += fClientBars[x].borderSpace.left;
1646 availableBounds.bottom -= fClientBars[x].borderSpace.bottom;
1647 availableBounds.right -= fClientBars[x].borderSpace.right;
1648 }
1649 }
1650 *prcBorder = availableBounds;
1651 return S_OK;
1652 }
1653
1654 HRESULT STDMETHODCALLTYPE CShellBrowser::RequestBorderSpaceDW(IUnknown* punkObj, LPCBORDERWIDTHS pbw)
1655 {
1656 return S_OK;
1657 }
1658
1659 HRESULT STDMETHODCALLTYPE CShellBrowser::SetBorderSpaceDW(IUnknown* punkObj, LPCBORDERWIDTHS pbw)
1660 {
1661 for (INT x = 0; x < 3; x++)
1662 {
1663 if (IUnknownIsEqual(fClientBars[x].clientBar, punkObj))
1664 {
1665 fClientBars[x].borderSpace = *pbw;
1666 // if this bar changed size, it cascades and forces all subsequent bars to resize
1667 RepositionBars();
1668 return S_OK;
1669 }
1670 }
1671 return E_INVALIDARG;
1672 }
1673
1674 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryStatus(const GUID *pguidCmdGroup,
1675 ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT *pCmdText)
1676 {
1677 CComPtr<IOleCommandTarget> commandTarget;
1678 HRESULT hResult;
1679
1680 if (prgCmds == NULL)
1681 return E_INVALIDARG;
1682 if (pguidCmdGroup == NULL)
1683 {
1684 if (fCurrentShellView.p != NULL)
1685 {
1686 hResult = fCurrentShellView->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &commandTarget));
1687 if (SUCCEEDED(hResult) && commandTarget.p != NULL)
1688 return commandTarget->QueryStatus(NULL, 1, prgCmds, pCmdText);
1689 }
1690 while (cCmds != 0)
1691 {
1692 prgCmds->cmdf = 0;
1693 prgCmds++;
1694 cCmds--;
1695 }
1696 }
1697 else if (IsEqualIID(*pguidCmdGroup, CGID_Explorer))
1698 {
1699 while (cCmds != 0)
1700 {
1701 switch (prgCmds->cmdID)
1702 {
1703 case 0x1c: // search
1704 prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
1705 break;
1706 case 0x1d: // history
1707 prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
1708 break;
1709 case 0x1e: // favorites
1710 prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
1711 break;
1712 case 0x23: // folders
1713 prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED | OLECMDF_LATCHED;
1714 break;
1715 default:
1716 prgCmds->cmdf = 0;
1717 break;
1718 }
1719 prgCmds++;
1720 cCmds--;
1721 }
1722 }
1723 else if (IsEqualIID(*pguidCmdGroup, CGID_ShellBrowser))
1724 {
1725 while (cCmds != 0)
1726 {
1727 switch (prgCmds->cmdID)
1728 {
1729 case 0xa022: // up level
1730 prgCmds->cmdf = OLECMDF_SUPPORTED;
1731 if (fCurrentDirectoryPIDL->mkid.cb != 0)
1732 prgCmds->cmdf |= OLECMDF_ENABLED;
1733 break;
1734 }
1735 prgCmds++;
1736 cCmds--;
1737 }
1738 }
1739 return S_OK;
1740 }
1741
1742 HRESULT STDMETHODCALLTYPE CShellBrowser::Exec(const GUID *pguidCmdGroup, DWORD nCmdID,
1743 DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
1744 {
1745 HRESULT hResult;
1746
1747 if (IsEqualIID(*pguidCmdGroup, CGID_Explorer))
1748 {
1749 switch (nCmdID)
1750 {
1751 case 0x23:
1752 hResult = ShowBand(CLSID_ExplorerBand, true);
1753 return S_OK;
1754 case 0x27:
1755 if (nCmdexecopt == 1)
1756 {
1757 // pvaIn is a VT_UNKNOWN with a band that is being hidden
1758 }
1759 else
1760 {
1761 // update zones part of the status bar
1762 }
1763 return S_OK;
1764 case 0x35: // don't do this, and the internet toolbar doesn't create a menu band
1765 V_VT(pvaOut) = VT_INT_PTR;
1766 V_INTREF(pvaOut) = reinterpret_cast<INT *>(
1767 LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU)));
1768 return S_OK;
1769 case 0x38:
1770 // indicate if this cabinet was opened as a browser
1771 return S_FALSE;
1772 default:
1773 return E_NOTIMPL;
1774 }
1775 }
1776 else if (IsEqualIID(*pguidCmdGroup, CGID_InternetButtons))
1777 {
1778 switch (nCmdID)
1779 {
1780 case 0x23:
1781 // placeholder
1782 return S_OK;
1783 }
1784 }
1785 else if (IsEqualIID(*pguidCmdGroup, CGID_Theater))
1786 {
1787 switch (nCmdID)
1788 {
1789 case 6:
1790 // what is theater mode and why do we receive this?
1791 return E_NOTIMPL;
1792 }
1793 }
1794 else if (IsEqualIID(*pguidCmdGroup, CGID_MenuBand))
1795 {
1796 switch (nCmdID)
1797 {
1798 case 14:
1799 // initialize favorites menu
1800 return S_OK;
1801 }
1802 }
1803 else if (IsEqualIID(*pguidCmdGroup, CGID_ShellDocView))
1804 {
1805 switch (nCmdID)
1806 {
1807 case 0x12:
1808 // refresh on toolbar clicked
1809 return S_OK;
1810 case 0x4d:
1811 // tell the view if it should hide the task pane or not
1812 return (fClientBars[BIVerticalBaseBar].clientBar.p == NULL) ? S_FALSE : S_OK;
1813 }
1814 }
1815 else if (IsEqualIID(*pguidCmdGroup, CGID_ShellBrowser))
1816 {
1817 switch (nCmdID)
1818 {
1819 case 40994:
1820 return NavigateToParent();
1821 }
1822 }
1823 else if (IsEqualIID(*pguidCmdGroup, CGID_IExplorerToolbar))
1824 {
1825 switch (nCmdID)
1826 {
1827 case 0x7063:
1828 return DoFolderOptions();
1829 }
1830 }
1831 else if (IsEqualIID(*pguidCmdGroup, CGID_DefView))
1832 {
1833 switch (nCmdID)
1834 {
1835 case 1:
1836 // Reset All Folders option in Folder Options
1837 break;
1838 }
1839 }
1840 else
1841 {
1842 return E_NOTIMPL;
1843 }
1844 return E_NOTIMPL;
1845 }
1846
1847 HRESULT STDMETHODCALLTYPE CShellBrowser::GetWindow(HWND *lphwnd)
1848 {
1849 if (lphwnd == NULL)
1850 return E_POINTER;
1851 *lphwnd = m_hWnd;
1852 return S_OK;
1853 }
1854
1855 HRESULT STDMETHODCALLTYPE CShellBrowser::ContextSensitiveHelp(BOOL fEnterMode)
1856 {
1857 return E_NOTIMPL;
1858 }
1859
1860 HRESULT STDMETHODCALLTYPE CShellBrowser::InsertMenusSB(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
1861 {
1862 HMENU mainMenu = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU));
1863
1864 Shell_MergeMenus(hmenuShared, mainMenu, 0, 0, FCIDM_BROWSERLAST, MM_SUBMENUSHAVEIDS);
1865
1866 int GCCU(itemCount3) = GetMenuItemCount(hmenuShared);
1867 Unused(itemCount3);
1868
1869 DestroyMenu(mainMenu);
1870
1871 lpMenuWidths->width[0] = 2;
1872 lpMenuWidths->width[2] = 3;
1873 lpMenuWidths->width[4] = 1;
1874 return S_OK;
1875 }
1876
1877 HRESULT STDMETHODCALLTYPE CShellBrowser::SetMenuSB(HMENU hmenuShared, HOLEMENU holemenuRes, HWND hwndActiveObject)
1878 {
1879 CComPtr<IShellMenu> shellMenu;
1880 HRESULT hResult;
1881
1882 if (hmenuShared && IsMenu(hmenuShared) == FALSE)
1883 return E_FAIL;
1884 hResult = GetMenuBand(IID_PPV_ARG(IShellMenu, &shellMenu));
1885 if (FAILED_UNEXPECTEDLY(hResult))
1886 return hResult;
1887 hResult = shellMenu->SetMenu(hmenuShared, NULL, SMSET_DONTOWN);
1888 if (FAILED_UNEXPECTEDLY(hResult))
1889 return hResult;
1890 fCurrentMenuBar = hmenuShared;
1891 return S_OK;
1892 }
1893
1894 HRESULT STDMETHODCALLTYPE CShellBrowser::RemoveMenusSB(HMENU hmenuShared)
1895 {
1896 if (hmenuShared == fCurrentMenuBar)
1897 {
1898 //DestroyMenu(fCurrentMenuBar);
1899 SetMenuSB(NULL, NULL, NULL);
1900 }
1901 return S_OK;
1902 }
1903
1904 HRESULT STDMETHODCALLTYPE CShellBrowser::SetStatusTextSB(LPCOLESTR pszStatusText)
1905 {
1906 //
1907 if (pszStatusText)
1908 {
1909 ::SetWindowText(fStatusBar, pszStatusText);
1910 }
1911 else
1912 {
1913
1914 }
1915 return E_NOTIMPL;
1916 }
1917
1918 HRESULT STDMETHODCALLTYPE CShellBrowser::EnableModelessSB(BOOL fEnable)
1919 {
1920 return E_NOTIMPL;
1921 }
1922
1923 HRESULT STDMETHODCALLTYPE CShellBrowser::TranslateAcceleratorSB(MSG *pmsg, WORD wID)
1924 {
1925 if (!::TranslateAcceleratorW(m_hWnd, m_hAccel, pmsg))
1926 return S_FALSE;
1927 return S_OK;
1928 }
1929
1930 HRESULT STDMETHODCALLTYPE CShellBrowser::BrowseObject(LPCITEMIDLIST pidl, UINT wFlags)
1931 {
1932 return BrowseToPIDL(pidl, BTP_UPDATE_CUR_HISTORY | BTP_UPDATE_NEXT_HISTORY);
1933 }
1934
1935 HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewStateStream(DWORD grfMode, IStream **ppStrm)
1936 {
1937 return E_NOTIMPL;
1938 }
1939
1940 HRESULT STDMETHODCALLTYPE CShellBrowser::GetControlWindow(UINT id, HWND *lphwnd)
1941 {
1942 if (lphwnd == NULL)
1943 return E_POINTER;
1944 *lphwnd = NULL;
1945 switch(id)
1946 {
1947 case FCW_TOOLBAR:
1948 *lphwnd = fToolbarProxy.m_hWnd;
1949 return S_OK;
1950 case FCW_STATUS:
1951 *lphwnd = fStatusBar;
1952 return S_OK;
1953 case FCW_TREE:
1954 // find the directory browser and return it
1955 // this should be used only to determine if a tree is present
1956 return S_OK;
1957 case FCW_PROGRESS:
1958 // is this a progress dialog?
1959 return S_OK;
1960 }
1961 return S_OK;
1962 }
1963
1964 HRESULT STDMETHODCALLTYPE CShellBrowser::SendControlMsg(
1965 UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pret)
1966 {
1967 LPARAM result;
1968
1969 if (pret != NULL)
1970 *pret = 0;
1971 switch(id)
1972 {
1973 case FCW_TOOLBAR:
1974 result = fToolbarProxy.SendMessage(uMsg, wParam, lParam);
1975 if (pret != NULL)
1976 *pret = result;
1977 break;
1978 case FCW_STATUS:
1979 result = SendMessage(fStatusBar, uMsg, wParam, lParam);
1980 if (pret != NULL)
1981 *pret = result;
1982 break;
1983 }
1984 return S_OK;
1985 }
1986
1987 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryActiveShellView(IShellView **ppshv)
1988 {
1989 if (ppshv == NULL)
1990 return E_POINTER;
1991 *ppshv = fCurrentShellView;
1992 if (fCurrentShellView.p != NULL)
1993 fCurrentShellView.p->AddRef();
1994 return S_OK;
1995 }
1996
1997 HRESULT STDMETHODCALLTYPE CShellBrowser::OnViewWindowActive(IShellView *ppshv)
1998 {
1999 return E_NOTIMPL;
2000 }
2001
2002 HRESULT STDMETHODCALLTYPE CShellBrowser::SetToolbarItems(LPTBBUTTON lpButtons, UINT nButtons, UINT uFlags)
2003 {
2004 return E_NOTIMPL;
2005 }
2006
2007 HRESULT STDMETHODCALLTYPE CShellBrowser::DragEnter(
2008 IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2009 {
2010 return E_NOTIMPL;
2011 }
2012
2013 HRESULT STDMETHODCALLTYPE CShellBrowser::DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2014 {
2015 return E_NOTIMPL;
2016 }
2017
2018 HRESULT STDMETHODCALLTYPE CShellBrowser::DragLeave()
2019 {
2020 return E_NOTIMPL;
2021 }
2022
2023 HRESULT STDMETHODCALLTYPE CShellBrowser::Drop(
2024 IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2025 {
2026 return E_NOTIMPL;
2027 }
2028
2029 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
2030 {
2031 // view does a query for SID_STopLevelBrowser, IID_IShellBrowserService
2032 // the returned interface has a method GetPropertyBag on it
2033 if (IsEqualIID(guidService, SID_STopLevelBrowser))
2034 return this->QueryInterface(riid, ppvObject);
2035 if (IsEqualIID(guidService, SID_SShellBrowser))
2036 return this->QueryInterface(riid, ppvObject);
2037 if (IsEqualIID(guidService, SID_ITargetFrame2))
2038 return this->QueryInterface(riid, ppvObject);
2039 if (IsEqualIID(guidService, SID_IWebBrowserApp)) // without this, the internet toolbar won't reflect notifications
2040 return this->QueryInterface(riid, ppvObject);
2041 if (IsEqualIID(guidService, SID_SProxyBrowser))
2042 return this->QueryInterface(riid, ppvObject);
2043 if (IsEqualIID(guidService, SID_IExplorerToolbar))
2044 return fClientBars[BIInternetToolbar].clientBar->QueryInterface(riid, ppvObject);
2045 if (IsEqualIID(riid, IID_IShellBrowser))
2046 return this->QueryInterface(riid, ppvObject);
2047 return E_NOINTERFACE;
2048 }
2049
2050 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPropertyBag(long flags, REFIID riid, void **ppvObject)
2051 {
2052 if (ppvObject == NULL)
2053 return E_POINTER;
2054 *ppvObject = NULL;
2055 return E_NOTIMPL;
2056 }
2057
2058 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTypeInfoCount(UINT *pctinfo)
2059 {
2060 return E_NOTIMPL;
2061 }
2062
2063 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
2064 {
2065 return E_NOTIMPL;
2066 }
2067
2068 HRESULT STDMETHODCALLTYPE CShellBrowser::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames,
2069 UINT cNames, LCID lcid, DISPID *rgDispId)
2070 {
2071 return E_NOTIMPL;
2072 }
2073
2074 HRESULT STDMETHODCALLTYPE CShellBrowser::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
2075 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2076 {
2077 return E_NOTIMPL;
2078 }
2079
2080 HRESULT STDMETHODCALLTYPE CShellBrowser::GetParentSite(IOleInPlaceSite **ppipsite)
2081 {
2082 return E_NOTIMPL;
2083 }
2084
2085 HRESULT STDMETHODCALLTYPE CShellBrowser::SetTitle(IShellView *psv, LPCWSTR pszName)
2086 {
2087 return E_NOTIMPL;
2088 }
2089
2090 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTitle(IShellView *psv, LPWSTR pszName, DWORD cchName)
2091 {
2092 return E_NOTIMPL;
2093 }
2094
2095 HRESULT STDMETHODCALLTYPE CShellBrowser::GetOleObject(IOleObject **ppobjv)
2096 {
2097 return E_NOTIMPL;
2098 }
2099
2100 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTravelLog(ITravelLog **pptl)
2101 {
2102 HRESULT hResult;
2103
2104 // called by toolbar when displaying tooltips
2105 if (pptl == NULL)
2106 return E_FAIL;
2107
2108 *pptl = NULL;
2109 if (fTravelLog.p == NULL)
2110 {
2111 hResult = CreateTravelLog(IID_PPV_ARG(ITravelLog, &fTravelLog));
2112 if (FAILED_UNEXPECTEDLY(hResult))
2113 return hResult;
2114 }
2115 *pptl = fTravelLog.p;
2116 fTravelLog.p->AddRef();
2117 return S_OK;
2118 }
2119
2120 HRESULT STDMETHODCALLTYPE CShellBrowser::ShowControlWindow(UINT id, BOOL fShow)
2121 {
2122 return E_NOTIMPL;
2123 }
2124
2125 HRESULT STDMETHODCALLTYPE CShellBrowser::IsControlWindowShown(UINT id, BOOL *pfShown)
2126 {
2127 return E_NOTIMPL;
2128 }
2129
2130 HRESULT STDMETHODCALLTYPE CShellBrowser::IEGetDisplayName(LPCITEMIDLIST pidl, LPWSTR pwszName, UINT uFlags)
2131 {
2132 return E_NOTIMPL;
2133 }
2134
2135 HRESULT STDMETHODCALLTYPE CShellBrowser::IEParseDisplayName(UINT uiCP, LPCWSTR pwszPath, LPITEMIDLIST *ppidlOut)
2136 {
2137 return E_NOTIMPL;
2138 }
2139
2140 HRESULT STDMETHODCALLTYPE CShellBrowser::DisplayParseError(HRESULT hres, LPCWSTR pwszPath)
2141 {
2142 return E_NOTIMPL;
2143 }
2144
2145 HRESULT STDMETHODCALLTYPE CShellBrowser::NavigateToPidl(LPCITEMIDLIST pidl, DWORD grfHLNF)
2146 {
2147 return E_NOTIMPL;
2148 }
2149
2150 HRESULT STDMETHODCALLTYPE CShellBrowser::SetNavigateState(BNSTATE bnstate)
2151 {
2152 return E_NOTIMPL;
2153 }
2154
2155 HRESULT STDMETHODCALLTYPE CShellBrowser::GetNavigateState(BNSTATE *pbnstate)
2156 {
2157 return E_NOTIMPL;
2158 }
2159
2160 HRESULT STDMETHODCALLTYPE CShellBrowser::NotifyRedirect(IShellView *psv, LPCITEMIDLIST pidl, BOOL *pfDidBrowse)
2161 {
2162 return E_NOTIMPL;
2163 }
2164
2165 HRESULT STDMETHODCALLTYPE CShellBrowser::UpdateWindowList()
2166 {
2167 return E_NOTIMPL;
2168 }
2169
2170 HRESULT STDMETHODCALLTYPE CShellBrowser::UpdateBackForwardState()
2171 {
2172 return E_NOTIMPL;
2173 }
2174
2175 HRESULT STDMETHODCALLTYPE CShellBrowser::SetFlags(DWORD dwFlags, DWORD dwFlagMask)
2176 {
2177 return E_NOTIMPL;
2178 }
2179
2180 HRESULT STDMETHODCALLTYPE CShellBrowser::GetFlags(DWORD *pdwFlags)
2181 {
2182 return E_NOTIMPL;
2183 }
2184
2185 HRESULT STDMETHODCALLTYPE CShellBrowser::CanNavigateNow()
2186 {
2187 return E_NOTIMPL;
2188 }
2189
2190 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPidl(LPITEMIDLIST *ppidl)
2191 {
2192 // called by explorer bar to get current pidl
2193 if (ppidl == NULL)
2194 return E_POINTER;
2195 *ppidl = ILClone(fCurrentDirectoryPIDL);
2196 return S_OK;
2197 }
2198
2199 HRESULT STDMETHODCALLTYPE CShellBrowser::SetReferrer(LPCITEMIDLIST pidl)
2200 {
2201 return E_NOTIMPL;
2202 }
2203
2204 DWORD STDMETHODCALLTYPE CShellBrowser::GetBrowserIndex()
2205 {
2206 return -1;
2207 }
2208
2209 HRESULT STDMETHODCALLTYPE CShellBrowser::GetBrowserByIndex(DWORD dwID, IUnknown **ppunk)
2210 {
2211 return E_NOTIMPL;
2212 }
2213
2214 HRESULT STDMETHODCALLTYPE CShellBrowser::GetHistoryObject(IOleObject **ppole, IStream **pstm, IBindCtx **ppbc)
2215 {
2216 if (ppole == NULL || pstm == NULL || ppbc == NULL)
2217 return E_INVALIDARG;
2218 *ppole = fHistoryObject;
2219 if (fHistoryObject != NULL)
2220 fHistoryObject->AddRef();
2221 *pstm = fHistoryStream;
2222 if (fHistoryStream != NULL)
2223 fHistoryStream->AddRef();
2224 *ppbc = fHistoryBindContext;
2225 if (fHistoryBindContext != NULL)
2226 fHistoryBindContext->AddRef();
2227 fHistoryObject = NULL;
2228 fHistoryStream = NULL;
2229 fHistoryBindContext = NULL;
2230 if (*ppole == NULL)
2231 return E_FAIL;
2232 return S_OK;
2233 }
2234
2235 HRESULT STDMETHODCALLTYPE CShellBrowser::SetHistoryObject(IOleObject *pole, BOOL fIsLocalAnchor)
2236 {
2237 return E_NOTIMPL;
2238 }
2239
2240 HRESULT STDMETHODCALLTYPE CShellBrowser::CacheOLEServer(IOleObject *pole)
2241 {
2242 return E_NOTIMPL;
2243 }
2244
2245 HRESULT STDMETHODCALLTYPE CShellBrowser::GetSetCodePage(VARIANT *pvarIn, VARIANT *pvarOut)
2246 {
2247 return E_NOTIMPL;
2248 }
2249
2250 HRESULT STDMETHODCALLTYPE CShellBrowser::OnHttpEquiv(
2251 IShellView *psv, BOOL fDone, VARIANT *pvarargIn, VARIANT *pvarargOut)
2252 {
2253 return E_NOTIMPL;
2254 }
2255
2256 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPalette(HPALETTE *hpal)
2257 {
2258 return E_NOTIMPL;
2259 }
2260
2261 HRESULT STDMETHODCALLTYPE CShellBrowser::RegisterWindow(BOOL fForceRegister, int swc)
2262 {
2263 return E_NOTIMPL;
2264 }
2265
2266 LRESULT STDMETHODCALLTYPE CShellBrowser::WndProcBS(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2267 {
2268 return E_NOTIMPL;
2269 }
2270
2271 HRESULT STDMETHODCALLTYPE CShellBrowser::SetAsDefFolderSettings()
2272 {
2273 return E_NOTIMPL;
2274 }
2275
2276 HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewRect(RECT *prc)
2277 {
2278 return E_NOTIMPL;
2279 }
2280
2281 HRESULT STDMETHODCALLTYPE CShellBrowser::OnSize(WPARAM wParam)
2282 {
2283 return E_NOTIMPL;
2284 }
2285
2286 HRESULT STDMETHODCALLTYPE CShellBrowser::OnCreate(struct tagCREATESTRUCTW *pcs)
2287 {
2288 m_hAccel = LoadAcceleratorsW(GetModuleHandle(L"browseui.dll"), MAKEINTRESOURCEW(256));
2289 return S_OK;
2290 }
2291
2292 LRESULT STDMETHODCALLTYPE CShellBrowser::OnCommand(WPARAM wParam, LPARAM lParam)
2293 {
2294 return 0;
2295 }
2296
2297 HRESULT STDMETHODCALLTYPE CShellBrowser::OnDestroy()
2298 {
2299 return E_NOTIMPL;
2300 }
2301
2302 LRESULT STDMETHODCALLTYPE CShellBrowser::OnNotify(struct tagNMHDR *pnm)
2303 {
2304 return 0;
2305 }
2306
2307 HRESULT STDMETHODCALLTYPE CShellBrowser::OnSetFocus()
2308 {
2309 return E_NOTIMPL;
2310 }
2311
2312 HRESULT STDMETHODCALLTYPE CShellBrowser::OnFrameWindowActivateBS(BOOL fActive)
2313 {
2314 return E_NOTIMPL;
2315 }
2316
2317 HRESULT STDMETHODCALLTYPE CShellBrowser::ReleaseShellView()
2318 {
2319 return E_NOTIMPL;
2320 }
2321
2322 HRESULT STDMETHODCALLTYPE CShellBrowser::ActivatePendingView()
2323 {
2324 return E_NOTIMPL;
2325 }
2326
2327 HRESULT STDMETHODCALLTYPE CShellBrowser::CreateViewWindow(
2328 IShellView *psvNew, IShellView *psvOld, LPRECT prcView, HWND *phwnd)
2329 {
2330 return E_NOTIMPL;
2331 }
2332
2333 HRESULT STDMETHODCALLTYPE CShellBrowser::CreateBrowserPropSheetExt(REFIID riid, void **ppv)
2334 {
2335 return E_NOTIMPL;
2336 }
2337
2338 HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewWindow(HWND *phwndView)
2339 {
2340 return E_NOTIMPL;
2341 }
2342
2343 HRESULT STDMETHODCALLTYPE CShellBrowser::GetBaseBrowserData(LPCBASEBROWSERDATA *pbbd)
2344 {
2345 return E_NOTIMPL;
2346 }
2347
2348 LPBASEBROWSERDATA STDMETHODCALLTYPE CShellBrowser::PutBaseBrowserData()
2349 {
2350 return NULL;
2351 }
2352
2353 HRESULT STDMETHODCALLTYPE CShellBrowser::InitializeTravelLog(ITravelLog *ptl, DWORD dw)
2354 {
2355 return E_NOTIMPL;
2356 }
2357
2358 HRESULT STDMETHODCALLTYPE CShellBrowser::SetTopBrowser()
2359 {
2360 return E_NOTIMPL;
2361 }
2362
2363 HRESULT STDMETHODCALLTYPE CShellBrowser::Offline(int iCmd)
2364 {
2365 return E_NOTIMPL;
2366 }
2367
2368 HRESULT STDMETHODCALLTYPE CShellBrowser::AllowViewResize(BOOL f)
2369 {
2370 return E_NOTIMPL;
2371 }
2372
2373 HRESULT STDMETHODCALLTYPE CShellBrowser::SetActivateState(UINT u)
2374 {
2375 return E_NOTIMPL;
2376 }
2377
2378 HRESULT STDMETHODCALLTYPE CShellBrowser::UpdateSecureLockIcon(int eSecureLock)
2379 {
2380 return E_NOTIMPL;
2381 }
2382
2383 HRESULT STDMETHODCALLTYPE CShellBrowser::InitializeDownloadManager()
2384 {
2385 return E_NOTIMPL;
2386 }
2387
2388 HRESULT STDMETHODCALLTYPE CShellBrowser::InitializeTransitionSite()
2389 {
2390 return E_NOTIMPL;
2391 }
2392
2393 HRESULT STDMETHODCALLTYPE CShellBrowser::_Initialize(HWND hwnd, IUnknown *pauto)
2394 {
2395 return E_NOTIMPL;
2396 }
2397
2398 HRESULT STDMETHODCALLTYPE CShellBrowser::_CancelPendingNavigationAsync()
2399 {
2400 return E_NOTIMPL;
2401 }
2402
2403 HRESULT STDMETHODCALLTYPE CShellBrowser::_CancelPendingView()
2404 {
2405 return E_NOTIMPL;
2406 }
2407
2408 HRESULT STDMETHODCALLTYPE CShellBrowser::_MaySaveChanges()
2409 {
2410 return E_NOTIMPL;
2411 }
2412
2413 HRESULT STDMETHODCALLTYPE CShellBrowser::_PauseOrResumeView(BOOL fPaused)
2414 {
2415 return E_NOTIMPL;
2416 }
2417
2418 HRESULT STDMETHODCALLTYPE CShellBrowser::_DisableModeless()
2419 {
2420 return E_NOTIMPL;
2421 }
2422
2423 HRESULT STDMETHODCALLTYPE CShellBrowser::_NavigateToPidl(LPCITEMIDLIST pidl, DWORD grfHLNF, DWORD dwFlags)
2424 {
2425 return E_NOTIMPL;
2426 }
2427
2428 HRESULT STDMETHODCALLTYPE CShellBrowser::_TryShell2Rename(IShellView *psv, LPCITEMIDLIST pidlNew)
2429 {
2430 return E_NOTIMPL;
2431 }
2432
2433 HRESULT STDMETHODCALLTYPE CShellBrowser::_SwitchActivationNow()
2434 {
2435 return E_NOTIMPL;
2436 }
2437
2438 HRESULT STDMETHODCALLTYPE CShellBrowser::_ExecChildren(IUnknown *punkBar, BOOL fBroadcast,
2439 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut)
2440 {
2441 return E_NOTIMPL;
2442 }
2443
2444 HRESULT STDMETHODCALLTYPE CShellBrowser::_SendChildren(
2445 HWND hwndBar, BOOL fBroadcast, UINT uMsg, WPARAM wParam, LPARAM lParam)
2446 {
2447 return E_NOTIMPL;
2448 }
2449
2450 HRESULT STDMETHODCALLTYPE CShellBrowser::GetFolderSetData(struct tagFolderSetData *pfsd)
2451 {
2452 return E_NOTIMPL;
2453 }
2454
2455 HRESULT STDMETHODCALLTYPE CShellBrowser::_OnFocusChange(UINT itb)
2456 {
2457 return E_NOTIMPL;
2458 }
2459
2460 HRESULT STDMETHODCALLTYPE CShellBrowser::v_ShowHideChildWindows(BOOL fChildOnly)
2461 {
2462 return E_NOTIMPL;
2463 }
2464
2465 UINT STDMETHODCALLTYPE CShellBrowser::_get_itbLastFocus()
2466 {
2467 return 0;
2468 }
2469
2470 HRESULT STDMETHODCALLTYPE CShellBrowser::_put_itbLastFocus(UINT itbLastFocus)
2471 {
2472 return E_NOTIMPL;
2473 }
2474
2475 HRESULT STDMETHODCALLTYPE CShellBrowser::_UIActivateView(UINT uState)
2476 {
2477 return E_NOTIMPL;
2478 }
2479
2480 HRESULT STDMETHODCALLTYPE CShellBrowser::_GetViewBorderRect(RECT *prc)
2481 {
2482 return E_NOTIMPL;
2483 }
2484
2485 HRESULT STDMETHODCALLTYPE CShellBrowser::_UpdateViewRectSize()
2486 {
2487 return E_NOTIMPL;
2488 }
2489
2490 HRESULT STDMETHODCALLTYPE CShellBrowser::_ResizeNextBorder(UINT itb)
2491 {
2492 return E_NOTIMPL;
2493 }
2494
2495 HRESULT STDMETHODCALLTYPE CShellBrowser::_ResizeView()
2496 {
2497 return E_NOTIMPL;
2498 }
2499
2500 HRESULT STDMETHODCALLTYPE CShellBrowser::_GetEffectiveClientArea(LPRECT lprectBorder, HMONITOR hmon)
2501 {
2502 return E_NOTIMPL;
2503 }
2504
2505 IStream *STDMETHODCALLTYPE CShellBrowser::v_GetViewStream(LPCITEMIDLIST pidl, DWORD grfMode, LPCWSTR pwszName)
2506 {
2507 return NULL;
2508 }
2509
2510 LRESULT STDMETHODCALLTYPE CShellBrowser::ForwardViewMsg(UINT uMsg, WPARAM wParam, LPARAM lParam)
2511 {
2512 return 0;
2513 }
2514
2515 HRESULT STDMETHODCALLTYPE CShellBrowser::SetAcceleratorMenu(HACCEL hacc)
2516 {
2517 return E_NOTIMPL;
2518 }
2519
2520 int STDMETHODCALLTYPE CShellBrowser::_GetToolbarCount()
2521 {
2522 return 0;
2523 }
2524
2525 LPTOOLBARITEM STDMETHODCALLTYPE CShellBrowser::_GetToolbarItem(int itb)
2526 {
2527 return NULL;
2528 }
2529
2530 HRESULT STDMETHODCALLTYPE CShellBrowser::_SaveToolbars(IStream *pstm)
2531 {
2532 return E_NOTIMPL;
2533 }
2534
2535 HRESULT STDMETHODCALLTYPE CShellBrowser::_LoadToolbars(IStream *pstm)
2536 {
2537 return E_NOTIMPL;
2538 }
2539
2540 HRESULT STDMETHODCALLTYPE CShellBrowser::_CloseAndReleaseToolbars(BOOL fClose)
2541 {
2542 return E_NOTIMPL;
2543 }
2544
2545 HRESULT STDMETHODCALLTYPE CShellBrowser::v_MayGetNextToolbarFocus(
2546 LPMSG lpMsg, UINT itbNext, int citb, LPTOOLBARITEM *pptbi, HWND *phwnd)
2547 {
2548 return E_NOTIMPL;
2549 }
2550
2551 HRESULT STDMETHODCALLTYPE CShellBrowser::_ResizeNextBorderHelper(UINT itb, BOOL bUseHmonitor)
2552 {
2553 return E_NOTIMPL;
2554 }
2555
2556 UINT STDMETHODCALLTYPE CShellBrowser::_FindTBar(IUnknown *punkSrc)
2557 {
2558 return 0;
2559 }
2560
2561 HRESULT STDMETHODCALLTYPE CShellBrowser::_SetFocus(LPTOOLBARITEM ptbi, HWND hwnd, LPMSG lpMsg)
2562 {
2563 return E_NOTIMPL;
2564 }
2565
2566 extern HRESULT IUnknown_HasFocusIO(IUnknown * punk);
2567 extern HRESULT IUnknown_TranslateAcceleratorIO(IUnknown * punk, MSG * pmsg);
2568 HRESULT STDMETHODCALLTYPE CShellBrowser::v_MayTranslateAccelerator(MSG *pmsg)
2569 {
2570 for (int i = 0; i < 3; i++)
2571 {
2572 if (IUnknown_TranslateAcceleratorIO(fClientBars[i].clientBar, pmsg) == S_OK)
2573 return S_OK;
2574 }
2575
2576 if (!fCurrentShellView)
2577 return S_FALSE;
2578
2579 return fCurrentShellView->TranslateAcceleratorW(pmsg);
2580 }
2581
2582 HRESULT STDMETHODCALLTYPE CShellBrowser::_GetBorderDWHelper(IUnknown *punkSrc, LPRECT lprectBorder, BOOL bUseHmonitor)
2583 {
2584 return E_NOTIMPL;
2585 }
2586
2587 HRESULT STDMETHODCALLTYPE CShellBrowser::v_CheckZoneCrossing(LPCITEMIDLIST pidl)
2588 {
2589 return E_NOTIMPL;
2590 }
2591
2592 HRESULT STDMETHODCALLTYPE CShellBrowser::GoBack()
2593 {
2594 CComPtr<ITravelLog> travelLog;
2595 HRESULT hResult;
2596
2597 hResult = GetTravelLog(&travelLog);
2598 if (FAILED_UNEXPECTEDLY(hResult))
2599 return hResult;
2600 return travelLog->Travel(static_cast<IDropTarget *>(this), TLOG_BACK);
2601 }
2602
2603 HRESULT STDMETHODCALLTYPE CShellBrowser::GoForward()
2604 {
2605 CComPtr<ITravelLog> travelLog;
2606 HRESULT hResult;
2607
2608 hResult = GetTravelLog(&travelLog);
2609 if (FAILED_UNEXPECTEDLY(hResult))
2610 return hResult;
2611 return travelLog->Travel(static_cast<IDropTarget *>(this), TLOG_FORE);
2612 }
2613
2614 HRESULT STDMETHODCALLTYPE CShellBrowser::GoHome()
2615 {
2616 return E_NOTIMPL;
2617 }
2618
2619 HRESULT STDMETHODCALLTYPE CShellBrowser::GoSearch()
2620 {
2621 return E_NOTIMPL;
2622 }
2623
2624 HRESULT STDMETHODCALLTYPE CShellBrowser::Navigate(BSTR URL, VARIANT *Flags,
2625 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
2626 {
2627 return E_NOTIMPL;
2628 }
2629
2630 HRESULT STDMETHODCALLTYPE CShellBrowser::Refresh()
2631 {
2632 VARIANT level;
2633
2634 V_VT(&level) = VT_I4;
2635 V_I4(&level) = 4;
2636 return Refresh2(&level);
2637 }
2638
2639 HRESULT STDMETHODCALLTYPE CShellBrowser::Refresh2(VARIANT *Level)
2640 {
2641 CComPtr<IOleCommandTarget> oleCommandTarget;
2642 HRESULT hResult;
2643
2644 hResult = fCurrentShellView->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &oleCommandTarget));
2645 if (FAILED_UNEXPECTEDLY(hResult))
2646 return hResult;
2647 return oleCommandTarget->Exec(NULL, 22, 1, Level, NULL);
2648 }
2649
2650 HRESULT STDMETHODCALLTYPE CShellBrowser::Stop()
2651 {
2652 return E_NOTIMPL;
2653 }
2654
2655 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Application(IDispatch **ppDisp)
2656 {
2657 return E_NOTIMPL;
2658 }
2659
2660 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Parent(IDispatch **ppDisp)
2661 {
2662 return E_NOTIMPL;
2663 }
2664
2665 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Container(IDispatch **ppDisp)
2666 {
2667 return E_NOTIMPL;
2668 }
2669
2670 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Document(IDispatch **ppDisp)
2671 {
2672 return E_NOTIMPL;
2673 }
2674
2675 HRESULT STDMETHODCALLTYPE CShellBrowser::get_TopLevelContainer(VARIANT_BOOL *pBool)
2676 {
2677 return E_NOTIMPL;
2678 }
2679
2680 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Type(BSTR *Type)
2681 {
2682 return E_NOTIMPL;
2683 }
2684 #ifdef __exdisp_h__
2685 #define long LONG
2686 #endif
2687 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Left(long *pl)
2688 {
2689 return E_NOTIMPL;
2690 }
2691
2692 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Left(long Left)
2693 {
2694 return E_NOTIMPL;
2695 }
2696
2697 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Top(long *pl)
2698 {
2699 return E_NOTIMPL;
2700 }
2701
2702 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Top(long Top)
2703 {
2704 return E_NOTIMPL;
2705 }
2706
2707 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Width(long *pl)
2708 {
2709 return E_NOTIMPL;
2710 }
2711
2712 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Width(long Width)
2713 {
2714 return E_NOTIMPL;
2715 }
2716
2717 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Height(long *pl)
2718 {
2719 return E_NOTIMPL;
2720 }
2721
2722 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Height(long Height)
2723 {
2724 return E_NOTIMPL;
2725 }
2726 #ifdef __exdisp_h__
2727 #undef long
2728 #endif
2729 HRESULT STDMETHODCALLTYPE CShellBrowser::get_LocationName(BSTR *LocationName)
2730 {
2731 return E_NOTIMPL;
2732 }
2733
2734 HRESULT STDMETHODCALLTYPE CShellBrowser::get_LocationURL(BSTR *LocationURL)
2735 {
2736 return E_NOTIMPL;
2737 }
2738
2739 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Busy(VARIANT_BOOL *pBool)
2740 {
2741 return E_NOTIMPL;
2742 }
2743
2744 HRESULT STDMETHODCALLTYPE CShellBrowser::Quit()
2745 {
2746 return E_NOTIMPL;
2747 }
2748
2749 HRESULT STDMETHODCALLTYPE CShellBrowser::ClientToWindow(int *pcx, int *pcy)
2750 {
2751 return E_NOTIMPL;
2752 }
2753
2754 HRESULT STDMETHODCALLTYPE CShellBrowser::PutProperty(BSTR Property, VARIANT vtValue)
2755 {
2756 return E_NOTIMPL;
2757 }
2758
2759 HRESULT STDMETHODCALLTYPE CShellBrowser::GetProperty(BSTR Property, VARIANT *pvtValue)
2760 {
2761 return E_NOTIMPL;
2762 }
2763
2764 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Name(BSTR *Name)
2765 {
2766 return E_NOTIMPL;
2767 }
2768
2769 HRESULT STDMETHODCALLTYPE CShellBrowser::get_HWND(SHANDLE_PTR *pHWND)
2770 {
2771 return E_NOTIMPL;
2772 }
2773
2774 HRESULT STDMETHODCALLTYPE CShellBrowser::get_FullName(BSTR *FullName)
2775 {
2776 return E_NOTIMPL;
2777 }
2778
2779 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Path(BSTR *Path)
2780 {
2781 return E_NOTIMPL;
2782 }
2783
2784 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Visible(VARIANT_BOOL *pBool)
2785 {
2786 return E_NOTIMPL;
2787 }
2788
2789 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Visible(VARIANT_BOOL Value)
2790 {
2791 return E_NOTIMPL;
2792 }
2793
2794 HRESULT STDMETHODCALLTYPE CShellBrowser::get_StatusBar(VARIANT_BOOL *pBool)
2795 {
2796 return E_NOTIMPL;
2797 }
2798
2799 HRESULT STDMETHODCALLTYPE CShellBrowser::put_StatusBar(VARIANT_BOOL Value)
2800 {
2801 return E_NOTIMPL;
2802 }
2803
2804 HRESULT STDMETHODCALLTYPE CShellBrowser::get_StatusText(BSTR *StatusText)
2805 {
2806 return E_NOTIMPL;
2807 }
2808
2809 HRESULT STDMETHODCALLTYPE CShellBrowser::put_StatusText(BSTR StatusText)
2810 {
2811 return E_NOTIMPL;
2812 }
2813
2814 HRESULT STDMETHODCALLTYPE CShellBrowser::get_ToolBar(int *Value)
2815 {
2816 return E_NOTIMPL;
2817 }
2818
2819 HRESULT STDMETHODCALLTYPE CShellBrowser::put_ToolBar(int Value)
2820 {
2821 return E_NOTIMPL;
2822 }
2823
2824 HRESULT STDMETHODCALLTYPE CShellBrowser::get_MenuBar(VARIANT_BOOL *Value)
2825 {
2826 return E_NOTIMPL;
2827 }
2828
2829 HRESULT STDMETHODCALLTYPE CShellBrowser::put_MenuBar(VARIANT_BOOL Value)
2830 {
2831 return E_NOTIMPL;
2832 }
2833
2834 HRESULT STDMETHODCALLTYPE CShellBrowser::get_FullScreen(VARIANT_BOOL *pbFullScreen)
2835 {
2836 return E_NOTIMPL;
2837 }
2838
2839 HRESULT STDMETHODCALLTYPE CShellBrowser::put_FullScreen(VARIANT_BOOL bFullScreen)
2840 {
2841 return E_NOTIMPL;
2842 }
2843
2844 HRESULT STDMETHODCALLTYPE CShellBrowser::Navigate2(VARIANT *URL, VARIANT *Flags,
2845 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
2846 {
2847 LPITEMIDLIST pidl;
2848 HRESULT hResult;
2849
2850 // called from drive combo box to navigate to a directory
2851 if (V_VT(URL) != (VT_ARRAY | VT_UI1))
2852 return E_INVALIDARG;
2853 if (V_ARRAY(URL)->cDims != 1 || V_ARRAY(URL)->cbElements != 1)
2854 return E_INVALIDARG;
2855 pidl = (LPITEMIDLIST)V_ARRAY(URL)->pvData;
2856 hResult = BrowseToPIDL((LPITEMIDLIST)pidl, BTP_UPDATE_CUR_HISTORY | BTP_UPDATE_NEXT_HISTORY);
2857 if (FAILED_UNEXPECTEDLY(hResult))
2858 return hResult;
2859 return S_OK;
2860 }
2861
2862 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryStatusWB(OLECMDID cmdID, OLECMDF *pcmdf)
2863 {
2864 return E_NOTIMPL;
2865 }
2866
2867 HRESULT STDMETHODCALLTYPE CShellBrowser::ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt,
2868 VARIANT *pvaIn, VARIANT *pvaOut)
2869 {
2870 return E_NOTIMPL;
2871 }
2872
2873 HRESULT STDMETHODCALLTYPE CShellBrowser::ShowBrowserBar(VARIANT *pvaClsid, VARIANT *pvarShow, VARIANT *pvarSize)
2874 {
2875 CLSID classID;
2876 bool vertical;
2877
2878 // called to show search bar
2879 if (V_VT(pvaClsid) != VT_BSTR)
2880 return E_INVALIDARG;
2881 CLSIDFromString(V_BSTR(pvaClsid), &classID);
2882 // TODO: properly compute the value of vertical
2883 vertical = true;
2884 return ShowBand(classID, vertical);
2885 }
2886
2887 HRESULT STDMETHODCALLTYPE CShellBrowser::get_ReadyState(READYSTATE *plReadyState)
2888 {
2889 return E_NOTIMPL;
2890 }
2891
2892 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Offline(VARIANT_BOOL *pbOffline)
2893 {
2894 return E_NOTIMPL;
2895 }
2896
2897 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Offline(VARIANT_BOOL bOffline)
2898 {
2899 return E_NOTIMPL;
2900 }
2901
2902 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Silent(VARIANT_BOOL *pbSilent)
2903 {
2904 return E_NOTIMPL;
2905 }
2906
2907 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Silent(VARIANT_BOOL bSilent)
2908 {
2909 return E_NOTIMPL;
2910 }
2911
2912 HRESULT STDMETHODCALLTYPE CShellBrowser::get_RegisterAsBrowser(VARIANT_BOOL *pbRegister)
2913 {
2914 return E_NOTIMPL;
2915 }
2916
2917 HRESULT STDMETHODCALLTYPE CShellBrowser::put_RegisterAsBrowser(VARIANT_BOOL bRegister)
2918 {
2919 return E_NOTIMPL;
2920 }
2921
2922 HRESULT STDMETHODCALLTYPE CShellBrowser::get_RegisterAsDropTarget(VARIANT_BOOL *pbRegister)
2923 {
2924 return E_NOTIMPL;
2925 }
2926
2927 HRESULT STDMETHODCALLTYPE CShellBrowser::put_RegisterAsDropTarget(VARIANT_BOOL bRegister)
2928 {
2929 return E_NOTIMPL;
2930 }
2931
2932 HRESULT STDMETHODCALLTYPE CShellBrowser::get_TheaterMode(VARIANT_BOOL *pbRegister)
2933 {
2934 return E_NOTIMPL;
2935 }
2936
2937 HRESULT STDMETHODCALLTYPE CShellBrowser::put_TheaterMode(VARIANT_BOOL bRegister)
2938 {
2939 return E_NOTIMPL;
2940 }
2941
2942 HRESULT STDMETHODCALLTYPE CShellBrowser::get_AddressBar(VARIANT_BOOL *Value)
2943 {
2944 return E_NOTIMPL;
2945 }
2946
2947 HRESULT STDMETHODCALLTYPE CShellBrowser::put_AddressBar(VARIANT_BOOL Value)
2948 {
2949 return E_NOTIMPL;
2950 }
2951
2952 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Resizable(VARIANT_BOOL *Value)
2953 {
2954 return E_NOTIMPL;
2955 }
2956
2957 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Resizable(VARIANT_BOOL Value)
2958 {
2959 return E_NOTIMPL;
2960 }
2961
2962 HRESULT STDMETHODCALLTYPE CShellBrowser::FindWindowByIndex(DWORD dwID, IUnknown **ppunk)
2963 {
2964 return E_NOTIMPL;
2965 }
2966
2967 HRESULT STDMETHODCALLTYPE CShellBrowser::GetWindowData(IStream *pStream, LPWINDOWDATA pWinData)
2968 {
2969 if (pWinData == NULL)
2970 return E_POINTER;
2971
2972 pWinData->dwWindowID = -1;
2973 pWinData->uiCP = 0;
2974 pWinData->pidl = ILClone(fCurrentDirectoryPIDL);
2975 pWinData->lpszUrl = NULL;
2976 pWinData->lpszUrlLocation = NULL;
2977 pWinData->lpszTitle = NULL;
2978 return S_OK;
2979 }
2980
2981 HRESULT STDMETHODCALLTYPE CShellBrowser::LoadHistoryPosition(LPWSTR pszUrlLocation, DWORD dwPosition)
2982 {
2983 return E_NOTIMPL;
2984 }
2985
2986 HRESULT STDMETHODCALLTYPE CShellBrowser::GetClassID(CLSID *pClassID)
2987 {
2988 return E_NOTIMPL;
2989 }
2990
2991 HRESULT STDMETHODCALLTYPE CShellBrowser::LoadHistory(IStream *pStream, IBindCtx *pbc)
2992 {
2993 CComPtr<IPersistHistory> viewPersistHistory;
2994 CComPtr<IOleObject> viewHistoryObject;
2995 persistState oldState;
2996 ULONG numRead;
2997 LPITEMIDLIST pidl;
2998 HRESULT hResult;
2999
3000 hResult = pStream->Read(&oldState, sizeof(oldState), &numRead);
3001 if (FAILED_UNEXPECTEDLY(hResult))
3002 return hResult;
3003 if (numRead != sizeof(oldState) || oldState.dwSize != sizeof(oldState))
3004 return E_FAIL;
3005 if (oldState.browseType != 2)
3006 return E_FAIL;
3007 pidl = static_cast<LPITEMIDLIST>(CoTaskMemAlloc(oldState.pidlSize));
3008 if (pidl == NULL)
3009 return E_OUTOFMEMORY;
3010 hResult = pStream->Read(pidl, oldState.pidlSize, &numRead);
3011 if (FAILED_UNEXPECTEDLY(hResult))
3012 {
3013 ILFree(pidl);
3014 return hResult;
3015 }
3016 if (numRead != oldState.pidlSize)
3017 {
3018 ILFree(pidl);
3019 return E_FAIL;
3020 }
3021 hResult = CoCreateInstance(oldState.persistClass, NULL, CLSCTX_LOCAL_SERVER | CLSCTX_INPROC_SERVER,
3022 IID_PPV_ARG(IOleObject, &viewHistoryObject));
3023 fHistoryObject = viewHistoryObject;
3024 fHistoryStream = pStream;
3025 fHistoryBindContext = pbc;
3026 hResult = BrowseToPIDL(pidl, BTP_UPDATE_CUR_HISTORY);
3027 fHistoryObject = NULL;
3028 fHistoryStream = NULL;
3029 fHistoryBindContext = NULL;
3030 ILFree(pidl);
3031 if (FAILED_UNEXPECTEDLY(hResult))
3032 return hResult;
3033 return S_OK;
3034 }
3035
3036 HRESULT STDMETHODCALLTYPE CShellBrowser::SaveHistory(IStream *pStream)
3037 {
3038 CComPtr<IPersistHistory> viewPersistHistory;
3039 persistState newState;
3040 HRESULT hResult;
3041
3042 hResult = fCurrentShellView->GetItemObject(
3043 SVGIO_BACKGROUND, IID_PPV_ARG(IPersistHistory, &viewPersistHistory));
3044 memset(&newState, 0, sizeof(newState));
3045 newState.dwSize = sizeof(newState);
3046 newState.browseType = 2;
3047 newState.browserIndex = GetBrowserIndex();
3048 if (viewPersistHistory.p != NULL)
3049 {
3050 hResult = viewPersistHistory->GetClassID(&newState.persistClass);
3051 if (FAILED_UNEXPECTEDLY(hResult))
3052 return hResult;
3053 }
3054 newState.pidlSize = ILGetSize(fCurrentDirectoryPIDL);
3055 hResult = pStream->Write(&newState, sizeof(newState), NULL);
3056 if (FAILED_UNEXPECTEDLY(hResult))
3057 return hResult;
3058 hResult = pStream->Write(fCurrentDirectoryPIDL, newState.pidlSize, NULL);
3059 if (FAILED_UNEXPECTEDLY(hResult))
3060 return hResult;
3061 if (viewPersistHistory.p != NULL)
3062 {
3063 hResult = viewPersistHistory->SaveHistory(pStream);
3064 if (FAILED_UNEXPECTEDLY(hResult))
3065 return hResult;
3066 }
3067 return S_OK;
3068 }
3069
3070 HRESULT STDMETHODCALLTYPE CShellBrowser::SetPositionCookie(DWORD dwPositioncookie)
3071 {
3072 return E_NOTIMPL;
3073 }
3074
3075 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPositionCookie(DWORD *pdwPositioncookie)
3076 {
3077 return E_NOTIMPL;
3078 }
3079
3080 LRESULT CShellBrowser::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3081 {
3082 OnCreate(reinterpret_cast<LPCREATESTRUCT> (lParam));
3083 return 0;
3084 }
3085
3086 LRESULT CShellBrowser::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3087 {
3088 HRESULT hr;
3089 // TODO: rip down everything
3090 {
3091 fCurrentShellView->DestroyViewWindow();
3092 fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
3093 ReleaseCComPtrExpectZero(fCurrentShellView);
3094
3095 for (int i = 0; i < 3; i++)
3096 {
3097 if (fClientBars[i].clientBar == NULL)
3098 continue;
3099 IDockingWindow * pdw;
3100 hr = fClientBars[i].clientBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &pdw));
3101 if (FAILED_UNEXPECTEDLY(hr))
3102 continue;
3103 pdw->ShowDW(FALSE);
3104 pdw->CloseDW(0);
3105 pdw->Release();
3106 ReleaseCComPtrExpectZero(fClientBars[i].clientBar);
3107