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