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