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