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