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