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