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