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