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