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