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