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