8419af6af2392b552a925bb97a38ab9b2cb02cfb
[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 ShowWindow(SW_SHOWNORMAL);
784
785 return S_OK;
786 }
787
788 HRESULT CShellBrowser::BrowseToPIDL(LPCITEMIDLIST pidl, long flags)
789 {
790 CComPtr<IShellFolder> newFolder;
791 FOLDERSETTINGS newFolderSettings;
792 HRESULT hResult;
793
794 // called by shell view to browse to new folder
795 // also called by explorer band to navigate to new folder
796 hResult = SHBindToFolder(pidl, &newFolder);
797 if (FAILED_UNEXPECTEDLY(hResult))
798 return hResult;
799
800 newFolderSettings.ViewMode = FVM_ICON;
801 newFolderSettings.fFlags = 0;
802 hResult = BrowseToPath(newFolder, pidl, &newFolderSettings, flags);
803 if (FAILED_UNEXPECTEDLY(hResult))
804 return hResult;
805 return S_OK;
806 }
807
808 BOOL WINAPI _ILIsDesktop(LPCITEMIDLIST pidl)
809 {
810 return (pidl == NULL || pidl->mkid.cb == 0);
811 }
812
813 BOOL WINAPI _ILIsPidlSimple(LPCITEMIDLIST pidl)
814 {
815 LPCITEMIDLIST pidlnext;
816 WORD length;
817 BOOL ret;
818
819 ret = TRUE;
820 if (! _ILIsDesktop(pidl))
821 {
822 length = pidl->mkid.cb;
823 pidlnext =
824 reinterpret_cast<LPCITEMIDLIST>(
825 reinterpret_cast<const BYTE *>(pidl) + length);
826 if (pidlnext->mkid.cb != 0)
827 ret = FALSE;
828 }
829 return ret;
830 }
831
832 HRESULT WINAPI SHBindToFolderIDListParent(IShellFolder *unused, LPCITEMIDLIST pidl,
833 const IID *riid, LPVOID *ppv, LPITEMIDLIST *ppidlLast)
834 {
835 CComPtr<IShellFolder> psf;
836 LPITEMIDLIST pidlChild;
837 LPITEMIDLIST pidlParent;
838 HRESULT hResult;
839
840 hResult = E_FAIL;
841 if (ppv == NULL)
842 return E_POINTER;
843 *ppv = NULL;
844 if (ppidlLast != NULL)
845 *ppidlLast = NULL;
846 if (_ILIsPidlSimple(pidl))
847 {
848 if (ppidlLast != NULL)
849 *ppidlLast = ILClone(pidl);
850 hResult = SHGetDesktopFolder((IShellFolder **)ppv);
851 }
852 else
853 {
854 pidlChild = ILClone(ILFindLastID(pidl));
855 pidlParent = ILClone(pidl);
856 ILRemoveLastID(pidlParent);
857 hResult = SHGetDesktopFolder(&psf);
858 if (SUCCEEDED(hResult))
859 hResult = psf->BindToObject(pidlParent, NULL, *riid, ppv);
860 if (SUCCEEDED(hResult) && ppidlLast != NULL)
861 *ppidlLast = pidlChild;
862 else
863 ILFree(pidlChild);
864 ILFree(pidlParent);
865 }
866 return hResult;
867 }
868
869 HRESULT IEGetNameAndFlagsEx(LPITEMIDLIST pidl, SHGDNF uFlags, long param10,
870 LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
871 {
872 CComPtr<IShellFolder> parentFolder;
873 LPITEMIDLIST childPIDL = NULL;
874 STRRET L108;
875 HRESULT hResult;
876
877 hResult = SHBindToFolderIDListParent(NULL, pidl, &IID_PPV_ARG(IShellFolder, &parentFolder), &childPIDL);
878 if (FAILED(hResult))
879 goto cleanup;
880
881 hResult = parentFolder->GetDisplayNameOf(childPIDL, uFlags, &L108);
882 if (FAILED(hResult))
883 goto cleanup;
884
885 StrRetToBufW(&L108, childPIDL, pszBuf, cchBuf);
886 if (rgfInOut)
887 {
888 hResult = parentFolder->GetAttributesOf(1, const_cast<LPCITEMIDLIST *>(&childPIDL), rgfInOut);
889 if (FAILED(hResult))
890 goto cleanup;
891 }
892
893 hResult = S_OK;
894
895 cleanup:
896 if (childPIDL)
897 ILFree(childPIDL);
898 return hResult;
899 }
900
901 long IEGetNameAndFlags(LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
902 {
903 return IEGetNameAndFlagsEx(pidl, uFlags, 0, pszBuf, cchBuf, rgfInOut);
904 }
905
906 HRESULT CShellBrowser::BrowseToPath(IShellFolder *newShellFolder,
907 LPCITEMIDLIST absolutePIDL, FOLDERSETTINGS *folderSettings, long flags)
908 {
909 CComPtr<IObjectWithSite> objectWithSite;
910 CComPtr<IShellFolder> saveCurrentShellFolder;
911 CComPtr<IShellView> saveCurrentShellView;
912 CComPtr<IShellView> newShellView;
913 CComPtr<ITravelLog> travelLog;
914 HWND newShellViewWindow;
915 BOOL windowUpdateIsLocked;
916 RECT shellViewWindowBounds;
917 HWND previousView;
918 HCURSOR saveCursor;
919 wchar_t newTitle[MAX_PATH];
920 SHGDNF nameFlags;
921 HRESULT hResult;
922
923 if (newShellFolder == NULL)
924 return E_INVALIDARG;
925
926 hResult = GetTravelLog(&travelLog);
927 if (FAILED_UNEXPECTEDLY(hResult))
928 return hResult;
929
930 // update history
931 if (flags & BTP_UPDATE_CUR_HISTORY)
932 {
933 if (travelLog->CountEntries(static_cast<IDropTarget *>(this)) > 0)
934 hResult = travelLog->UpdateEntry(static_cast<IDropTarget *>(this), FALSE);
935 // what to do with error? Do we want to halt browse because state save failed?
936 }
937
938 if (fCurrentShellView)
939 {
940 fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
941 }
942
943 // create view object
944 hResult = newShellFolder->CreateViewObject(m_hWnd, IID_PPV_ARG(IShellView, &newShellView));
945 if (FAILED_UNEXPECTEDLY(hResult))
946 return hResult;
947 previousView = fCurrentShellViewWindow;
948
949 // enter updating section
950 saveCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
951 windowUpdateIsLocked = LockWindowUpdate(TRUE);
952 if (fCurrentShellView != NULL)
953 ::SendMessage(fCurrentShellViewWindow, WM_SETREDRAW, 0, 0);
954
955 // set site
956 hResult = IUnknown_SetSite(newShellView, static_cast<IDropTarget *>(this));
957
958 // update folder and view
959 saveCurrentShellFolder = fCurrentShellFolder;
960 saveCurrentShellView = fCurrentShellView;
961 fCurrentShellFolder = newShellFolder;
962 fCurrentShellView = newShellView;
963
964 // get boundary
965 if (previousView != NULL)
966 ::GetWindowRect(previousView, &shellViewWindowBounds);
967 else
968 ZeroMemory(&shellViewWindowBounds, sizeof(shellViewWindowBounds));
969 ::MapWindowPoints(0, m_hWnd, reinterpret_cast<POINT *>(&shellViewWindowBounds), 2);
970
971 // create view window
972 hResult = newShellView->CreateViewWindow(saveCurrentShellView, folderSettings,
973 this, &shellViewWindowBounds, &newShellViewWindow);
974 if (FAILED_UNEXPECTEDLY(hResult) || newShellViewWindow == NULL)
975 {
976 fCurrentShellView = saveCurrentShellView;
977 fCurrentShellFolder = saveCurrentShellFolder;
978 ::SendMessage(fCurrentShellViewWindow, WM_SETREDRAW, 1, 0);
979 if (windowUpdateIsLocked)
980 LockWindowUpdate(FALSE);
981 SetCursor(saveCursor);
982 return hResult;
983 }
984
985 if (objectWithSite.p != NULL)
986 hResult = objectWithSite->SetSite(NULL);
987
988 // update current pidl
989 ILFree(fCurrentDirectoryPIDL);
990 fCurrentDirectoryPIDL = ILClone(absolutePIDL);
991
992 // update view window
993 if (saveCurrentShellView != NULL)
994 saveCurrentShellView->DestroyViewWindow();
995 fCurrentShellViewWindow = newShellViewWindow;
996
997 // no use
998 saveCurrentShellView.Release();
999 saveCurrentShellFolder.Release();
1000
1001 hResult = newShellView->UIActivate(SVUIA_ACTIVATE_FOCUS);
1002
1003 // leave updating section
1004 if (windowUpdateIsLocked)
1005 LockWindowUpdate(FALSE);
1006 SetCursor(saveCursor);
1007
1008 // update history
1009 if (flags & BTP_UPDATE_NEXT_HISTORY)
1010 {
1011 hResult = travelLog->AddEntry(static_cast<IDropTarget *>(this), FALSE);
1012 hResult = travelLog->UpdateEntry(static_cast<IDropTarget *>(this), FALSE);
1013 }
1014
1015 // completed
1016 nameFlags = SHGDN_FORADDRESSBAR | SHGDN_FORPARSING;
1017 hResult = IEGetNameAndFlags(fCurrentDirectoryPIDL, nameFlags, newTitle,
1018 sizeof(newTitle) / sizeof(wchar_t), NULL);
1019 if (SUCCEEDED(hResult))
1020 {
1021 FireNavigateComplete(newTitle);
1022 }
1023 else
1024 {
1025 FireNavigateComplete(L"ERROR");
1026 }
1027
1028 if (fCabinetState.fFullPathTitle)
1029 nameFlags = SHGDN_FORADDRESSBAR | SHGDN_FORPARSING;
1030 else
1031 nameFlags = SHGDN_FORADDRESSBAR;
1032 hResult = IEGetNameAndFlags(fCurrentDirectoryPIDL, nameFlags, newTitle,
1033 sizeof(newTitle) / sizeof(wchar_t), NULL);
1034 if (SUCCEEDED(hResult))
1035 {
1036 SetWindowText(newTitle);
1037
1038 LPCITEMIDLIST pidlChild;
1039 INT index, indexOpen;
1040 HIMAGELIST himlSmall, himlLarge;
1041
1042 CComPtr<IShellFolder> sf;
1043 hResult = SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
1044 if (SUCCEEDED(hResult))
1045 {
1046 index = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
1047
1048 Shell_GetImageLists(&himlLarge, &himlSmall);
1049
1050 HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
1051 HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
1052
1053 /* Hack to make it possible to release the old icons */
1054 /* Something seems to go wrong with WM_SETICON */
1055 HICON oldSmall = (HICON)SendMessage(WM_GETICON, ICON_SMALL, 0);
1056 HICON oldLarge = (HICON)SendMessage(WM_GETICON, ICON_BIG, 0);
1057
1058 SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icSmall));
1059 SendMessage(WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icLarge));
1060
1061 DestroyIcon(oldSmall);
1062 DestroyIcon(oldLarge);
1063 }
1064 }
1065
1066 FireCommandStateChangeAll();
1067 hResult = UpdateForwardBackState();
1068 hResult = UpdateUpState();
1069 return S_OK;
1070 }
1071
1072 HRESULT CShellBrowser::GetMenuBand(REFIID riid, void **shellMenu)
1073 {
1074 CComPtr<IBandSite> bandSite;
1075 CComPtr<IDeskBand> deskBand;
1076 HRESULT hResult;
1077
1078 if (!fClientBars[BIInternetToolbar].clientBar)
1079 return E_FAIL;
1080
1081 hResult = IUnknown_QueryService(fClientBars[BIInternetToolbar].clientBar, SID_IBandSite, IID_PPV_ARG(IBandSite, &bandSite));
1082 if (FAILED_UNEXPECTEDLY(hResult))
1083 return hResult;
1084
1085 hResult = bandSite->QueryBand(1, &deskBand, NULL, NULL, 0);
1086 if (FAILED_UNEXPECTEDLY(hResult))
1087 return hResult;
1088
1089 return deskBand->QueryInterface(riid, shellMenu);
1090 }
1091
1092 HRESULT CShellBrowser::GetBaseBar(bool vertical, REFIID riid, void **theBaseBar)
1093 {
1094 CComPtr<IUnknown> newBaseBar;
1095 CComPtr<IDeskBar> deskBar;
1096 CComPtr<IUnknown> newBaseBarSite;
1097 CComPtr<IDeskBarClient> deskBarClient;
1098 IUnknown **cache;
1099 HRESULT hResult;
1100
1101 if (vertical)
1102 cache = &fClientBars[BIVerticalBaseBar].clientBar.p;
1103 else
1104 cache = &fClientBars[BIHorizontalBaseBar].clientBar.p;
1105 if (*cache == NULL)
1106 {
1107 hResult = CBaseBar_CreateInstance(IID_PPV_ARG(IUnknown, &newBaseBar), vertical);
1108 if (FAILED_UNEXPECTEDLY(hResult))
1109 return hResult;
1110 hResult = CBaseBarSite_CreateInstance(IID_PPV_ARG(IUnknown, &newBaseBarSite), vertical);
1111 if (FAILED_UNEXPECTEDLY(hResult))
1112 return hResult;
1113
1114 // we have to store our basebar into cache now
1115 *cache = newBaseBar;
1116
1117 // tell the new base bar about the shell browser
1118 hResult = IUnknown_SetSite(newBaseBar, static_cast<IDropTarget *>(this));
1119 if (FAILED_UNEXPECTEDLY(hResult))
1120 return hResult;
1121
1122 // tell the new base bar about the new base bar site
1123 hResult = newBaseBar->QueryInterface(IID_PPV_ARG(IDeskBar, &deskBar));
1124 if (FAILED_UNEXPECTEDLY(hResult))
1125 return hResult;
1126 hResult = deskBar->SetClient(newBaseBarSite);
1127 if (FAILED_UNEXPECTEDLY(hResult))
1128 return hResult;
1129
1130 // tell the new base bar site about the new base bar
1131 hResult = newBaseBarSite->QueryInterface(IID_PPV_ARG(IDeskBarClient, &deskBarClient));
1132 if (FAILED_UNEXPECTEDLY(hResult))
1133 return hResult;
1134 hResult = deskBarClient->SetDeskBarSite(newBaseBar);
1135 if (FAILED_UNEXPECTEDLY(hResult))
1136 return hResult;
1137
1138 }
1139 return (*cache)->QueryInterface(riid, theBaseBar);
1140 }
1141
1142 BOOL CShellBrowser::IsBandLoaded(const CLSID clsidBand, bool vertical, DWORD *pdwBandID)
1143 {
1144 HRESULT hResult;
1145 CComPtr<IDeskBar> deskBar;
1146 CComPtr<IUnknown> baseBarSite;
1147 CComPtr<IBandSite> bandSite;
1148 CLSID clsidTmp;
1149 DWORD numBands;
1150 DWORD dwBandID;
1151 DWORD i;
1152
1153 /* Get our basebarsite to be able to enumerate bands */
1154 hResult = GetBaseBar(vertical, IID_PPV_ARG(IDeskBar, &deskBar));
1155 if (FAILED_UNEXPECTEDLY(hResult))
1156 return FALSE;
1157 hResult = deskBar->GetClient(&baseBarSite);
1158 if (FAILED_UNEXPECTEDLY(hResult))
1159 return FALSE;
1160 hResult = baseBarSite->QueryInterface(IID_PPV_ARG(IBandSite, &bandSite));
1161 if (FAILED_UNEXPECTEDLY(hResult))
1162 return FALSE;
1163
1164 hResult = bandSite->EnumBands(-1, &numBands);
1165 if (FAILED_UNEXPECTEDLY(hResult))
1166 return FALSE;
1167
1168 for(i = 0; i < numBands; i++)
1169 {
1170 CComPtr<IPersist> bandPersist;
1171
1172 hResult = bandSite->EnumBands(i, &dwBandID);
1173 if (FAILED_UNEXPECTEDLY(hResult))
1174 return FALSE;
1175
1176 hResult = bandSite->GetBandObject(dwBandID, IID_PPV_ARG(IPersist, &bandPersist));
1177 if (FAILED_UNEXPECTEDLY(hResult))
1178 return FALSE;
1179 hResult = bandPersist->GetClassID(&clsidTmp);
1180 if (FAILED_UNEXPECTEDLY(hResult))
1181 return FALSE;
1182 if (IsEqualGUID(clsidBand, clsidTmp))
1183 {
1184 if (pdwBandID) *pdwBandID = dwBandID;
1185 return TRUE;
1186 }
1187 }
1188 return FALSE;
1189 }
1190
1191 HRESULT CShellBrowser::ShowBand(const CLSID &classID, bool vertical)
1192 {
1193 CComPtr<IDockingWindow> dockingWindow;
1194 CComPtr<IUnknown> baseBarSite;
1195 CComPtr<IUnknown> newBand;
1196 CComPtr<IDeskBar> deskBar;
1197 VARIANT vaIn;
1198 HRESULT hResult;
1199 DWORD dwBandID;
1200
1201 hResult = GetBaseBar(vertical, IID_PPV_ARG(IDeskBar, &deskBar));
1202 if (FAILED_UNEXPECTEDLY(hResult))
1203 return hResult;
1204
1205 hResult = deskBar->GetClient(&baseBarSite);
1206 if (FAILED_UNEXPECTEDLY(hResult))
1207 return hResult;
1208
1209 hResult = deskBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
1210 if (FAILED_UNEXPECTEDLY(hResult))
1211 return hResult;
1212
1213 if (!IsBandLoaded(classID, vertical, &dwBandID))
1214 {
1215 TRACE("ShowBand called for CLSID %s, vertical=%d...\n", wine_dbgstr_guid(&classID), vertical);
1216 if (IsEqualCLSID(CLSID_ExplorerBand, classID))
1217 {
1218 TRACE("CLSID_ExplorerBand requested, building internal band.\n");
1219 hResult = CExplorerBand_CreateInstance(IID_PPV_ARG(IUnknown, &newBand));
1220 if (FAILED_UNEXPECTEDLY(hResult))
1221 return hResult;
1222 }
1223 else
1224 {
1225 TRACE("A different CLSID requested, using CoCreateInstance.\n");
1226 hResult = CoCreateInstance(classID, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IUnknown, &newBand));
1227 if (FAILED_UNEXPECTEDLY(hResult))
1228 return hResult;
1229 }
1230 }
1231 else
1232 {
1233 CComPtr<IBandSite> pBandSite;
1234
1235 hResult = baseBarSite->QueryInterface(IID_PPV_ARG(IBandSite, &pBandSite));
1236 if (!SUCCEEDED(hResult))
1237 {
1238 ERR("Can't get IBandSite interface\n");
1239 return E_FAIL;
1240 }
1241 hResult = pBandSite->GetBandObject(dwBandID, IID_PPV_ARG(IUnknown, &newBand));
1242 if (!SUCCEEDED(hResult))
1243 {
1244 ERR("Can't find band object\n");
1245 return E_FAIL;
1246 }
1247
1248 // It's hackish, but we should be able to show the wanted band until we
1249 // find the proper way to do this (but it seems to work to add a new band)
1250 // Here we'll just re-add the existing band to the site, causing it to display.
1251 }
1252 V_VT(&vaIn) = VT_UNKNOWN;
1253 V_UNKNOWN(&vaIn) = newBand.p;
1254 hResult = IUnknown_Exec(baseBarSite, CGID_IDeskBand, 1, 1, &vaIn, NULL);
1255 if (FAILED_UNEXPECTEDLY(hResult))
1256 {
1257 return hResult;
1258 }
1259
1260 hResult = dockingWindow->ShowDW(TRUE);
1261 if (FAILED_UNEXPECTEDLY(hResult))
1262 return hResult;
1263
1264 return S_OK;
1265 }
1266
1267 HRESULT CShellBrowser::NavigateToParent()
1268 {
1269 LPITEMIDLIST newDirectory = ILClone(fCurrentDirectoryPIDL);
1270 if (newDirectory == NULL)
1271 return E_OUTOFMEMORY;
1272 if (_ILIsDesktop(newDirectory))
1273 {
1274 ILFree(newDirectory);
1275 return E_INVALIDARG;
1276 }
1277 ILRemoveLastID(newDirectory);
1278 HRESULT hResult = BrowseToPIDL(newDirectory, BTP_UPDATE_CUR_HISTORY | BTP_UPDATE_NEXT_HISTORY);
1279 ILFree(newDirectory);
1280 if (FAILED_UNEXPECTEDLY(hResult))
1281 return hResult;
1282 return S_OK;
1283 }
1284
1285 BOOL CALLBACK AddFolderOptionsPage(HPROPSHEETPAGE thePage, LPARAM lParam)
1286 {
1287 PROPSHEETHEADER* sheetInfo = reinterpret_cast<PROPSHEETHEADER*>(lParam);
1288 if (sheetInfo->nPages >= folderOptionsPageCountMax)
1289 return FALSE;
1290 sheetInfo->phpage[sheetInfo->nPages] = thePage;
1291 sheetInfo->nPages++;
1292 return TRUE;
1293 }
1294
1295 HRESULT CShellBrowser::DoFolderOptions()
1296 {
1297 CComPtr<IShellPropSheetExt> folderOptionsSheet;
1298 PROPSHEETHEADER m_PropSheet;
1299 HPROPSHEETPAGE m_psp[folderOptionsPageCountMax];
1300 // CComPtr<IGlobalFolderSettings> globalSettings;
1301 // SHELLSTATE2 shellState;
1302 HRESULT hResult;
1303
1304 memset(m_psp, 0, sizeof(m_psp));
1305 memset(&m_PropSheet, 0, sizeof(m_PropSheet));
1306
1307 // create sheet object
1308 hResult = CoCreateInstance(CLSID_ShellFldSetExt, NULL, CLSCTX_INPROC_SERVER,
1309 IID_PPV_ARG(IShellPropSheetExt, &folderOptionsSheet));
1310 if (FAILED_UNEXPECTEDLY(hResult))
1311 return E_FAIL;
1312
1313 // must set site in order for Apply to all Folders on Advanced page to be enabled
1314 hResult = IUnknown_SetSite(folderOptionsSheet, static_cast<IDispatch *>(this));
1315 m_PropSheet.phpage = m_psp;
1316
1317 #if 0
1318 hResult = CoCreateInstance(CLSID_GlobalFolderSettings, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IGlobalFolderSettings, &globalSettings));
1319 if (FAILED_UNEXPECTEDLY(hResult))
1320 return E_FAIL;
1321 hResult = globalSettings->Get(&shellState, sizeof(shellState));
1322 if (FAILED_UNEXPECTEDLY(hResult))
1323 return E_FAIL;
1324 #endif
1325
1326 // add pages
1327 hResult = folderOptionsSheet->AddPages(AddFolderOptionsPage, reinterpret_cast<LPARAM>(&m_PropSheet));
1328 if (FAILED_UNEXPECTEDLY(hResult))
1329 return E_FAIL;
1330
1331 // CORE-11140 : Disabled this bit, because it prevents the folder options from showing.
1332 // It returns 'E_NOTIMPL'
1333 #if 0
1334 if (fCurrentShellView != NULL)
1335 {
1336 hResult = fCurrentShellView->AddPropertySheetPages(
1337 0, AddFolderOptionsPage, reinterpret_cast<LPARAM>(&m_PropSheet));
1338 if (FAILED_UNEXPECTEDLY(hResult))
1339 return E_FAIL;
1340 }
1341 #endif
1342
1343 // show sheet
1344 m_PropSheet.dwSize = sizeof(PROPSHEETHEADER);
1345 m_PropSheet.dwFlags = 0;
1346 m_PropSheet.hwndParent = m_hWnd;
1347 m_PropSheet.hInstance = _AtlBaseModule.GetResourceInstance();
1348 m_PropSheet.pszCaption = _T("Folder Options");
1349 m_PropSheet.nStartPage = 0;
1350 PropertySheet(&m_PropSheet);
1351 return S_OK;
1352 }
1353
1354 LRESULT CALLBACK CShellBrowser::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1355 {
1356 CShellBrowser *pThis = reinterpret_cast<CShellBrowser *>(hWnd);
1357 _ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
1358 LRESULT lResult;
1359 const _ATL_MSG *previousMessage;
1360 BOOL handled;
1361 WNDPROC saveWindowProc;
1362 HRESULT hResult;
1363
1364 hWnd = pThis->m_hWnd;
1365 previousMessage = pThis->m_pCurrentMsg;
1366 pThis->m_pCurrentMsg = &msg;
1367
1368 CComPtr<IMenuBand> menuBand;
1369 hResult = pThis->GetMenuBand(IID_PPV_ARG(IMenuBand, &menuBand));
1370 if (SUCCEEDED(hResult) && menuBand.p != NULL)
1371 {
1372 hResult = menuBand->TranslateMenuMessage(&msg, &lResult);
1373 if (hResult == S_OK)
1374 return lResult;
1375 uMsg = msg.message;
1376 wParam = msg.wParam;
1377 lParam = msg.lParam;
1378 }
1379 menuBand.Release();
1380
1381 handled = pThis->ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, 0);
1382 ATLASSERT(pThis->m_pCurrentMsg == &msg);
1383 if (handled == FALSE)
1384 {
1385 if (uMsg == WM_NCDESTROY)
1386 {
1387 saveWindowProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hWnd, GWL_WNDPROC));
1388 lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1389 if (saveWindowProc == reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hWnd, GWL_WNDPROC)))
1390 ::SetWindowLongPtr(hWnd, GWL_WNDPROC, (LONG_PTR)pThis->m_pfnSuperWindowProc);
1391 pThis->m_dwState |= WINSTATE_DESTROYED;
1392 }
1393 else
1394 lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
1395 }
1396 pThis->m_pCurrentMsg = previousMessage;
1397 if (previousMessage == NULL && (pThis->m_dwState & WINSTATE_DESTROYED) != 0)
1398 {
1399 pThis->m_dwState &= ~WINSTATE_DESTROYED;
1400 pThis->m_hWnd = NULL;
1401 pThis->OnFinalMessage(hWnd);
1402 }
1403 return lResult;
1404 }
1405
1406 void CShellBrowser::RepositionBars()
1407 {
1408 RECT clientRect;
1409 RECT statusRect;
1410 int x;
1411
1412 GetClientRect(&clientRect);
1413
1414 if (fStatusBarVisible && fStatusBar)
1415 {
1416 ::GetWindowRect(fStatusBar, &statusRect);
1417 ::SetWindowPos(fStatusBar, NULL, clientRect.left, clientRect.bottom - (statusRect.bottom - statusRect.top),
1418 clientRect.right - clientRect.left,
1419 statusRect.bottom - statusRect.top, SWP_NOOWNERZORDER | SWP_NOZORDER);
1420 clientRect.bottom -= statusRect.bottom - statusRect.top;
1421 }
1422
1423 for (x = 0; x < 3; x++)
1424 {
1425 HWND hwnd = fClientBars[x].hwnd;
1426 RECT borderSpace = fClientBars[x].borderSpace;
1427 if (hwnd == NULL && fClientBars[x].clientBar != NULL)
1428 {
1429 IUnknown_GetWindow(fClientBars[x].clientBar, &hwnd);
1430 fClientBars[x].hwnd = hwnd;
1431 }
1432 if (hwnd != NULL)
1433 {
1434 RECT toolbarRect = clientRect;
1435 if (borderSpace.top != 0)
1436 {
1437 toolbarRect.bottom = toolbarRect.top + borderSpace.top;
1438 }
1439 else if (borderSpace.bottom != 0)
1440 {
1441 toolbarRect.top = toolbarRect.bottom - borderSpace.bottom;
1442 }
1443 else if (borderSpace.left != 0)
1444 {
1445 toolbarRect.right = toolbarRect.left + borderSpace.left;
1446 }
1447 else if (borderSpace.right != 0)
1448 {
1449 toolbarRect.left = toolbarRect.right - borderSpace.right;
1450 }
1451
1452 ::SetWindowPos(hwnd, NULL,
1453 toolbarRect.left,
1454 toolbarRect.top,
1455 toolbarRect.right - toolbarRect.left,
1456 toolbarRect.bottom - toolbarRect.top,
1457 SWP_NOOWNERZORDER | SWP_NOZORDER);
1458
1459 if (borderSpace.top != 0)
1460 {
1461 clientRect.top = toolbarRect.bottom;
1462 }
1463 else if (borderSpace.bottom != 0)
1464 {
1465 clientRect.bottom = toolbarRect.top;
1466 }
1467 else if (borderSpace.left != 0)
1468 {
1469 clientRect.left = toolbarRect.right;
1470 }
1471 else if (borderSpace.right != 0)
1472 {
1473 clientRect.right = toolbarRect.left;
1474 }
1475 }
1476 }
1477 ::SetWindowPos(fCurrentShellViewWindow, NULL, clientRect.left, clientRect.top,
1478 clientRect.right - clientRect.left,
1479 clientRect.bottom - clientRect.top, SWP_NOOWNERZORDER | SWP_NOZORDER);
1480 }
1481
1482 HRESULT CShellBrowser::FireEvent(DISPID dispIdMember, int argCount, VARIANT *arguments)
1483 {
1484 DISPPARAMS params;
1485 CComDynamicUnkArray &vec = IConnectionPointImpl<CShellBrowser, &DIID_DWebBrowserEvents2>::m_vec;
1486 CComDynamicUnkArray &vec2 = IConnectionPointImpl<CShellBrowser, &DIID_DWebBrowserEvents>::m_vec;
1487 HRESULT hResult;
1488
1489 params.rgvarg = arguments;
1490 params.rgdispidNamedArgs = NULL;
1491 params.cArgs = argCount;
1492 params.cNamedArgs = 0;
1493 IUnknown** pp = vec.begin();
1494 while (pp < vec.end())
1495 {
1496 if (*pp != NULL)
1497 {
1498 CComPtr<IDispatch> theDispatch;
1499
1500 hResult = (*pp)->QueryInterface(IID_PPV_ARG(IDispatch, &theDispatch));
1501 hResult = theDispatch->Invoke(dispIdMember, GUID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, NULL);
1502 }
1503 pp++;
1504 }
1505 pp = vec2.begin();
1506 while (pp < vec2.end())
1507 {
1508 if (*pp != NULL)
1509 {
1510 CComPtr<IDispatch> theDispatch;
1511
1512 hResult = (*pp)->QueryInterface(IID_PPV_ARG(IDispatch, &theDispatch));
1513 hResult = theDispatch->Invoke(dispIdMember, GUID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, NULL);
1514 }
1515 pp++;
1516 }
1517 return S_OK;
1518 }
1519
1520 HRESULT CShellBrowser::FireNavigateComplete(const wchar_t *newDirectory)
1521 {
1522 // these two variants intentionally to do use CComVariant because it would double free/release
1523 // or does not need to dispose at all
1524 VARIANT varArg[2];
1525 VARIANT varArgs;
1526 CComBSTR tempString(newDirectory);
1527
1528 V_VT(&varArgs) = VT_BSTR;
1529 V_BSTR(&varArgs) = tempString.m_str;
1530
1531 V_VT(&varArg[0]) = VT_VARIANT | VT_BYREF;
1532 V_VARIANTREF(&varArg[0]) = &varArgs;
1533 V_VT(&varArg[1]) = VT_DISPATCH;
1534 V_DISPATCH(&varArg[1]) = (IDispatch *)this;
1535
1536 return FireEvent(DISPID_NAVIGATECOMPLETE2, 2, varArg);
1537 }
1538
1539 HRESULT CShellBrowser::FireCommandStateChange(bool newState, int commandID)
1540 {
1541 VARIANT varArg[2];
1542
1543 V_VT(&varArg[0]) = VT_BOOL;
1544 V_BOOL(&varArg[0]) = newState ? VARIANT_TRUE : VARIANT_FALSE;
1545 V_VT(&varArg[1]) = VT_I4;
1546 V_I4(&varArg[1]) = commandID;
1547
1548 return FireEvent(DISPID_COMMANDSTATECHANGE, 2, varArg);
1549 }
1550
1551 HRESULT CShellBrowser::FireCommandStateChangeAll()
1552 {
1553 return FireCommandStateChange(false, -1);
1554 }
1555
1556 HRESULT CShellBrowser::UpdateForwardBackState()
1557 {
1558 CComPtr<ITravelLog> travelLog;
1559 CComPtr<ITravelEntry> unusedEntry;
1560 bool canGoBack;
1561 bool canGoForward;
1562 HRESULT hResult;
1563
1564 canGoBack = false;
1565 canGoForward = false;
1566 hResult = GetTravelLog(&travelLog);
1567 if (FAILED_UNEXPECTEDLY(hResult))
1568 return hResult;
1569 hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this), TLOG_BACK, &unusedEntry);
1570 if (SUCCEEDED(hResult))
1571 {
1572 canGoBack = true;
1573 unusedEntry.Release();
1574 }
1575 hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this), TLOG_FORE, &unusedEntry);
1576 if (SUCCEEDED(hResult))
1577 {
1578 canGoForward = true;
1579 unusedEntry.Release();
1580 }
1581 hResult = FireCommandStateChange(canGoBack, 2);
1582 hResult = FireCommandStateChange(canGoForward, 1);
1583 return S_OK;
1584 }
1585
1586 HRESULT CShellBrowser::UpdateUpState()
1587 {
1588 bool canGoUp;
1589 HRESULT hResult;
1590
1591 canGoUp = true;
1592 if (_ILIsDesktop(fCurrentDirectoryPIDL))
1593 canGoUp = false;
1594 hResult = FireCommandStateChange(canGoUp, 3);
1595 return S_OK;
1596 }
1597
1598 void CShellBrowser::UpdateGotoMenu(HMENU theMenu)
1599 {
1600 CComPtr<ITravelLog> travelLog;
1601 CComPtr<ITravelEntry> unusedEntry;
1602 int position;
1603 MENUITEMINFO menuItemInfo;
1604 HRESULT hResult;
1605
1606 DeleteMenuItems(theMenu, IDM_GOTO_TRAVEL_FIRST, IDM_GOTO_TRAVEL_LAST);
1607
1608 position = GetMenuItemCount(theMenu);
1609 hResult = GetTravelLog(&travelLog);
1610 if (FAILED_UNEXPECTEDLY(hResult))
1611 return;
1612
1613 hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this),
1614 TLOG_BACK,
1615 &unusedEntry);
1616
1617 if (SUCCEEDED(hResult))
1618 {
1619 SHEnableMenuItem(theMenu, IDM_GOTO_BACK, TRUE);
1620 unusedEntry.Release();
1621 }
1622 else
1623 SHEnableMenuItem(theMenu, IDM_GOTO_BACK, FALSE);
1624
1625 hResult = travelLog->GetTravelEntry(static_cast<IDropTarget *>(this),
1626 TLOG_FORE,
1627 &unusedEntry);
1628
1629 if (SUCCEEDED(hResult))
1630 {
1631 SHEnableMenuItem(theMenu, IDM_GOTO_FORWARD, TRUE);
1632 unusedEntry.Release();
1633 }
1634 else
1635 SHEnableMenuItem(theMenu, IDM_GOTO_FORWARD, FALSE);
1636
1637 SHEnableMenuItem(theMenu,
1638 IDM_GOTO_UPONELEVEL,
1639 !_ILIsDesktop(fCurrentDirectoryPIDL));
1640
1641 hResult = travelLog->InsertMenuEntries(static_cast<IDropTarget *>(this), theMenu, position,
1642 IDM_GOTO_TRAVEL_FIRSTTARGET, IDM_GOTO_TRAVEL_LASTTARGET, TLMENUF_BACKANDFORTH | TLMENUF_CHECKCURRENT);
1643 if (SUCCEEDED(hResult))
1644 {
1645 menuItemInfo.cbSize = sizeof(menuItemInfo);
1646 menuItemInfo.fMask = MIIM_TYPE | MIIM_ID;
1647 menuItemInfo.fType = MF_SEPARATOR;
1648 menuItemInfo.wID = IDM_GOTO_TRAVEL_SEP;
1649 InsertMenuItem(theMenu, position, TRUE, &menuItemInfo);
1650 }
1651 }
1652
1653 void CShellBrowser::UpdateViewMenu(HMENU theMenu)
1654 {
1655 CComPtr<ITravelLog> travelLog;
1656 HMENU gotoMenu;
1657 OLECMD commandList[5];
1658 HMENU toolbarMenuBar;
1659 HMENU toolbarMenu;
1660 MENUITEMINFO menuItemInfo;
1661 HRESULT hResult;
1662
1663 gotoMenu = SHGetMenuFromID(theMenu, FCIDM_MENU_EXPLORE);
1664 if (gotoMenu != NULL)
1665 UpdateGotoMenu(gotoMenu);
1666
1667 commandList[0].cmdID = ITID_TOOLBARBANDSHOWN;
1668 commandList[1].cmdID = ITID_ADDRESSBANDSHOWN;
1669 commandList[2].cmdID = ITID_LINKSBANDSHOWN;
1670 commandList[3].cmdID = ITID_TOOLBARLOCKED;
1671 commandList[4].cmdID = ITID_CUSTOMIZEENABLED;
1672
1673 hResult = IUnknown_QueryStatus(fClientBars[BIInternetToolbar].clientBar,
1674 CGID_PrivCITCommands, 5, commandList, NULL);
1675 if (FAILED_UNEXPECTEDLY(hResult))
1676 DeleteMenu(theMenu, IDM_VIEW_TOOLBARS, MF_BYCOMMAND);
1677 else
1678 {
1679 menuItemInfo.cbSize = sizeof(menuItemInfo);
1680 menuItemInfo.fMask = MIIM_SUBMENU;
1681 GetMenuItemInfo(theMenu, IDM_VIEW_TOOLBARS, FALSE, &menuItemInfo);
1682 DestroyMenu(menuItemInfo.hSubMenu);
1683
1684 toolbarMenuBar = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_CONTEXTMENU));
1685 toolbarMenu = GetSubMenu(toolbarMenuBar, 0);
1686 RemoveMenu(toolbarMenuBar, 0, MF_BYPOSITION);
1687 DestroyMenu(toolbarMenuBar);
1688
1689 // TODO: Implement
1690 SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_STANDARDBUTTONS, commandList[0].cmdf & OLECMDF_ENABLED);
1691 SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_ADDRESSBAR, commandList[1].cmdf & OLECMDF_ENABLED);
1692 SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_LINKSBAR, commandList[2].cmdf & OLECMDF_ENABLED);
1693 SHEnableMenuItem(toolbarMenu, IDM_TOOLBARS_CUSTOMIZE, commandList[4].cmdf & OLECMDF_ENABLED);
1694
1695 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_STANDARDBUTTONS, commandList[0].cmdf & OLECMDF_LATCHED);
1696 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_ADDRESSBAR, commandList[1].cmdf & OLECMDF_LATCHED);
1697 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_LINKSBAR, commandList[2].cmdf & OLECMDF_LATCHED);
1698 SHCheckMenuItem(toolbarMenu, IDM_TOOLBARS_LOCKTOOLBARS, commandList[3].cmdf & OLECMDF_LATCHED);
1699 if ((commandList[4].cmdf & OLECMDF_ENABLED) == 0)
1700 DeleteMenu(toolbarMenu, IDM_TOOLBARS_CUSTOMIZE, MF_BYCOMMAND);
1701 DeleteMenu(toolbarMenu, IDM_TOOLBARS_TEXTLABELS, MF_BYCOMMAND);
1702 DeleteMenu(toolbarMenu, IDM_TOOLBARS_GOBUTTON, MF_BYCOMMAND);
1703
1704 menuItemInfo.cbSize = sizeof(menuItemInfo);
1705 menuItemInfo.fMask = MIIM_SUBMENU;
1706 menuItemInfo.hSubMenu = toolbarMenu;
1707 SetMenuItemInfo(theMenu, IDM_VIEW_TOOLBARS, FALSE, &menuItemInfo);
1708 }
1709 SHCheckMenuItem(theMenu, IDM_VIEW_STATUSBAR, fStatusBarVisible ? TRUE : FALSE);
1710 }
1711
1712 HRESULT CShellBrowser::BuildExplorerBandMenu()
1713 {
1714 HMENU hBandsMenu;
1715 UINT nbFound;
1716
1717 hBandsMenu = SHGetMenuFromID(fCurrentMenuBar, IDM_VIEW_EXPLORERBAR);
1718 if (!hBandsMenu)
1719 {
1720 OutputDebugString(L"No menu !\n");
1721 return E_FAIL;
1722 }
1723 DSA_DeleteAllItems(menuDsa);
1724 BuildExplorerBandCategory(hBandsMenu, CATID_InfoBand, 4, NULL);
1725 BuildExplorerBandCategory(hBandsMenu, CATID_CommBand, 20, &nbFound);
1726 if (!nbFound)
1727 {
1728 // Remove separator
1729 DeleteMenu(hBandsMenu, IDM_EXPLORERBAR_SEPARATOR, MF_BYCOMMAND);
1730 }
1731 // Remove media menu since XP does it (according to API Monitor)
1732 DeleteMenu(hBandsMenu, IDM_EXPLORERBAR_MEDIA, MF_BYCOMMAND);
1733 return S_OK;
1734 }
1735
1736 HRESULT CShellBrowser::BuildExplorerBandCategory(HMENU hBandsMenu, CATID category, DWORD dwPos, UINT *nbFound)
1737 {
1738 HRESULT hr;
1739 CComPtr<IEnumGUID> pEnumGUID;
1740 WCHAR wszBandName[MAX_PATH];
1741 WCHAR wszBandGUID[MAX_PATH];
1742 WCHAR wRegKey[MAX_PATH];
1743 UINT cBands;
1744 DWORD dwRead;
1745 DWORD dwDataSize;
1746 GUID iter;
1747 MenuBandInfo mbi;
1748
1749 mbi.fVertical = IsEqualGUID(category, CATID_InfoBand);
1750 cBands = 0;
1751 hr = SHEnumClassesOfCategories(1, &category, 0, NULL, &pEnumGUID);
1752 if (FAILED_UNEXPECTEDLY(hr))
1753 {
1754 return hr;
1755 }
1756 do
1757 {
1758 pEnumGUID->Next(1, &iter, &dwRead);
1759 if (dwRead)
1760 {
1761 // Get the band name
1762 if (IsBuiltinBand(iter))
1763 continue;
1764 if (!StringFromGUID2(iter, wszBandGUID, MAX_PATH))
1765 continue;
1766 StringCchPrintfW(wRegKey, MAX_PATH, L"CLSID\\%s", wszBandGUID);
1767 dwDataSize = MAX_PATH;
1768 SHGetValue(HKEY_CLASSES_ROOT, wRegKey, NULL, NULL, wszBandName, &dwDataSize);
1769
1770 mbi.barGuid = iter;
1771 InsertMenu(hBandsMenu, dwPos + cBands, MF_BYPOSITION, IDM_EXPLORERBAND_BEGINCUSTOM + DSA_GetItemCount(menuDsa), wszBandName);
1772 DSA_AppendItem(menuDsa, &mbi);
1773 cBands++;
1774 }
1775 }
1776 while (dwRead > 0);
1777 if (nbFound)
1778 *nbFound = cBands;
1779 return S_OK;
1780 }
1781
1782 BOOL CShellBrowser::IsBuiltinBand(CLSID &bandID)
1783 {
1784 if (IsEqualCLSID(bandID, CLSID_ExplorerBand))
1785 return TRUE;
1786 if (IsEqualCLSID(bandID, CLSID_SH_SearchBand) || IsEqualCLSID(bandID, CLSID_SearchBand))
1787 return TRUE;
1788 if (IsEqualCLSID(bandID, CLSID_IE_SearchBand) || IsEqualCLSID(bandID, CLSID_FileSearchBand))
1789 return TRUE;
1790 if (IsEqualCLSID(bandID, CLSID_SH_HistBand))
1791 return TRUE;
1792 if (IsEqualCLSID(bandID, CLSID_SH_FavBand))
1793 return TRUE;
1794 if (IsEqualCLSID(bandID, CLSID_ChannelsBand))
1795 return TRUE;
1796 return FALSE;
1797 }
1798
1799 HRESULT CShellBrowser::OnSearch()
1800 {
1801 CComPtr<IObjectWithSite> objectWithSite;
1802 CComPtr<IContextMenu> contextMenu;
1803 CMINVOKECOMMANDINFO commandInfo;
1804 const char *searchGUID = "{169A0691-8DF9-11d1-A1C4-00C04FD75D13}";
1805 HRESULT hResult;
1806
1807 // TODO: Query shell if this command is enabled first
1808
1809 memset(&commandInfo, 0, sizeof(commandInfo));
1810 commandInfo.cbSize = sizeof(commandInfo);
1811 commandInfo.hwnd = m_hWnd;
1812 commandInfo.lpParameters = searchGUID;
1813 commandInfo.nShow = SW_SHOWNORMAL;
1814
1815 hResult = CoCreateInstance(CLSID_ShellSearchExt, NULL, CLSCTX_INPROC_SERVER,
1816 IID_PPV_ARG(IContextMenu, &contextMenu));
1817 if (FAILED_UNEXPECTEDLY(hResult))
1818 return 0;
1819 hResult = contextMenu->QueryInterface(IID_PPV_ARG(IObjectWithSite, &objectWithSite));
1820 if (FAILED_UNEXPECTEDLY(hResult))
1821 return 0;
1822 hResult = objectWithSite->SetSite(dynamic_cast<IShellBrowser*>(this));
1823 if (FAILED_UNEXPECTEDLY(hResult))
1824 return 0;
1825 hResult = contextMenu->InvokeCommand(&commandInfo);
1826 hResult = objectWithSite->SetSite(NULL);
1827 return hResult;
1828 }
1829
1830 bool IUnknownIsEqual(IUnknown *int1, IUnknown *int2)
1831 {
1832 CComPtr<IUnknown> int1Retry;
1833 CComPtr<IUnknown> int2Retry;
1834 HRESULT hResult;
1835
1836 if (int1 == int2)
1837 return true;
1838 if (int1 == NULL || int2 == NULL)
1839 return false;
1840 hResult = int1->QueryInterface(IID_PPV_ARG(IUnknown, &int1Retry));
1841 if (FAILED_UNEXPECTEDLY(hResult))
1842 return false;
1843 hResult = int2->QueryInterface(IID_PPV_ARG(IUnknown, &int2Retry));
1844 if (FAILED_UNEXPECTEDLY(hResult))
1845 return false;
1846 if (int1Retry == int2Retry)
1847 return true;
1848 return false;
1849 }
1850
1851 HRESULT STDMETHODCALLTYPE CShellBrowser::GetBorderDW(IUnknown *punkObj, LPRECT prcBorder)
1852 {
1853 static const INT excludeItems[] = { 1, 1, 1, 0xa001, 0, 0 };
1854
1855 RECT availableBounds;
1856
1857 GetEffectiveClientRect(m_hWnd, &availableBounds, excludeItems);
1858 for (INT x = 0; x < 3; x++)
1859 {
1860 if (fClientBars[x].clientBar.p != NULL && !IUnknownIsEqual(fClientBars[x].clientBar, punkObj))
1861 {
1862 availableBounds.top += fClientBars[x].borderSpace.top;
1863 availableBounds.left += fClientBars[x].borderSpace.left;
1864 availableBounds.bottom -= fClientBars[x].borderSpace.bottom;
1865 availableBounds.right -= fClientBars[x].borderSpace.right;
1866 }
1867 }
1868 *prcBorder = availableBounds;
1869 return S_OK;
1870 }
1871
1872 HRESULT STDMETHODCALLTYPE CShellBrowser::RequestBorderSpaceDW(IUnknown* punkObj, LPCBORDERWIDTHS pbw)
1873 {
1874 return S_OK;
1875 }
1876
1877 HRESULT STDMETHODCALLTYPE CShellBrowser::SetBorderSpaceDW(IUnknown* punkObj, LPCBORDERWIDTHS pbw)
1878 {
1879 for (INT x = 0; x < 3; x++)
1880 {
1881 if (IUnknownIsEqual(fClientBars[x].clientBar, punkObj))
1882 {
1883 fClientBars[x].borderSpace = *pbw;
1884 // if this bar changed size, it cascades and forces all subsequent bars to resize
1885 RepositionBars();
1886 return S_OK;
1887 }
1888 }
1889 return E_INVALIDARG;
1890 }
1891
1892 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryStatus(const GUID *pguidCmdGroup,
1893 ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT *pCmdText)
1894 {
1895 CComPtr<IOleCommandTarget> commandTarget;
1896 HRESULT hResult;
1897
1898 if (prgCmds == NULL)
1899 return E_INVALIDARG;
1900 if (pguidCmdGroup == NULL)
1901 {
1902 if (fCurrentShellView.p != NULL)
1903 {
1904 hResult = fCurrentShellView->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &commandTarget));
1905 if (SUCCEEDED(hResult) && commandTarget.p != NULL)
1906 return commandTarget->QueryStatus(NULL, 1, prgCmds, pCmdText);
1907 }
1908 while (cCmds != 0)
1909 {
1910 prgCmds->cmdf = 0;
1911 prgCmds++;
1912 cCmds--;
1913 }
1914 }
1915 else if (IsEqualIID(*pguidCmdGroup, CGID_Explorer))
1916 {
1917 while (cCmds != 0)
1918 {
1919 switch (prgCmds->cmdID)
1920 {
1921 case 0x1c: // search
1922 prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
1923 break;
1924 case 0x1d: // history
1925 prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
1926 break;
1927 case 0x1e: // favorites
1928 prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
1929 break;
1930 case 0x23: // folders
1931 prgCmds->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED | OLECMDF_LATCHED;
1932 break;
1933 default:
1934 prgCmds->cmdf = 0;
1935 break;
1936 }
1937 prgCmds++;
1938 cCmds--;
1939 }
1940 }
1941 else if (IsEqualIID(*pguidCmdGroup, CGID_ShellBrowser))
1942 {
1943 while (cCmds != 0)
1944 {
1945 switch (prgCmds->cmdID)
1946 {
1947 case 0xa022: // up level
1948 prgCmds->cmdf = OLECMDF_SUPPORTED;
1949 if (fCurrentDirectoryPIDL->mkid.cb != 0)
1950 prgCmds->cmdf |= OLECMDF_ENABLED;
1951 break;
1952 }
1953 prgCmds++;
1954 cCmds--;
1955 }
1956 }
1957 return S_OK;
1958 }
1959
1960 HRESULT STDMETHODCALLTYPE CShellBrowser::Exec(const GUID *pguidCmdGroup, DWORD nCmdID,
1961 DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
1962 {
1963 HRESULT hResult;
1964
1965 if (!pguidCmdGroup)
1966 {
1967 TRACE("Unhandled null CGID %d %d %p %p\n", nCmdID, nCmdexecopt, pvaIn, pvaOut);
1968 return E_NOTIMPL;
1969 }
1970 if (IsEqualIID(*pguidCmdGroup, CGID_Explorer))
1971 {
1972 switch (nCmdID)
1973 {
1974 case 0x23:
1975 hResult = ShowBand(CLSID_ExplorerBand, true);
1976 return S_OK;
1977 case 0x27:
1978 if (nCmdexecopt == 1)
1979 {
1980 // pvaIn is a VT_UNKNOWN with a band that is being hidden
1981 }
1982 else
1983 {
1984 // update zones part of the status bar
1985 }
1986 return S_OK;
1987 case 0x35: // don't do this, and the internet toolbar doesn't create a menu band
1988 V_VT(pvaOut) = VT_INT_PTR;
1989 V_INTREF(pvaOut) = reinterpret_cast<INT *>(
1990 LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU)));
1991 return S_OK;
1992 case 0x38:
1993 // indicate if this cabinet was opened as a browser
1994 return S_FALSE;
1995 default:
1996 return E_NOTIMPL;
1997 }
1998 }
1999 else if (IsEqualIID(*pguidCmdGroup, CGID_InternetButtons))
2000 {
2001 switch (nCmdID)
2002 {
2003 case 0x23:
2004 // placeholder
2005 return S_OK;
2006 }
2007 }
2008 else if (IsEqualIID(*pguidCmdGroup, CGID_Theater))
2009 {
2010 switch (nCmdID)
2011 {
2012 case 6:
2013 // what is theater mode and why do we receive this?
2014 return E_NOTIMPL;
2015 }
2016 }
2017 else if (IsEqualIID(*pguidCmdGroup, CGID_MenuBand))
2018 {
2019 switch (nCmdID)
2020 {
2021 case 14:
2022 // initialize favorites menu
2023 return S_OK;
2024 }
2025 }
2026 else if (IsEqualIID(*pguidCmdGroup, CGID_ShellDocView))
2027 {
2028 switch (nCmdID)
2029 {
2030 case 0x12:
2031 // refresh on toolbar clicked
2032 return S_OK;
2033 case 0x26:
2034 // called for unknown bands ?
2035 return S_OK;
2036 case 0x4d:
2037 // tell the view if it should hide the task pane or not
2038 return (fClientBars[BIVerticalBaseBar].clientBar.p == NULL) ? S_FALSE : S_OK;
2039 }
2040 }
2041 else if (IsEqualIID(*pguidCmdGroup, CGID_ShellBrowser))
2042 {
2043 switch (nCmdID)
2044 {
2045 case 40994:
2046 return NavigateToParent();
2047 }
2048 }
2049 else if (IsEqualIID(*pguidCmdGroup, CGID_IExplorerToolbar))
2050 {
2051 switch (nCmdID)
2052 {
2053 case 0x7063:
2054 return DoFolderOptions();
2055 }
2056 }
2057 else if (IsEqualIID(*pguidCmdGroup, CGID_DefView))
2058 {
2059 switch (nCmdID)
2060 {
2061 case 1:
2062 // Reset All Folders option in Folder Options
2063 break;
2064 }
2065 }
2066 else if (IsEqualIID(*pguidCmdGroup, CLSID_CommonButtons))
2067 {
2068 // Windows seems to use this as proxy for toolbar buttons.
2069 // We use it for search band for now to remove code duplication,
2070 // let's see if it could be useful in the future.
2071 switch (nCmdID)
2072 {
2073 case 0x123:
2074 // Show search band from toolbar
2075 OnSearch();
2076 return S_OK;
2077 }
2078 return E_NOTIMPL;
2079 }
2080 else
2081 {
2082 return E_NOTIMPL;
2083 }
2084 return E_NOTIMPL;
2085 }
2086
2087 HRESULT STDMETHODCALLTYPE CShellBrowser::GetWindow(HWND *lphwnd)
2088 {
2089 if (lphwnd == NULL)
2090 return E_POINTER;
2091 *lphwnd = m_hWnd;
2092 return S_OK;
2093 }
2094
2095 HRESULT STDMETHODCALLTYPE CShellBrowser::ContextSensitiveHelp(BOOL fEnterMode)
2096 {
2097 return E_NOTIMPL;
2098 }
2099
2100 HRESULT STDMETHODCALLTYPE CShellBrowser::InsertMenusSB(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
2101 {
2102 HMENU mainMenu = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU));
2103
2104 Shell_MergeMenus(hmenuShared, mainMenu, 0, 0, FCIDM_BROWSERLAST, MM_SUBMENUSHAVEIDS);
2105
2106 int GCCU(itemCount3) = GetMenuItemCount(hmenuShared);
2107 Unused(itemCount3);
2108
2109 DestroyMenu(mainMenu);
2110
2111 lpMenuWidths->width[0] = 2;
2112 lpMenuWidths->width[2] = 3;
2113 lpMenuWidths->width[4] = 1;
2114 return S_OK;
2115 }
2116
2117 HRESULT STDMETHODCALLTYPE CShellBrowser::SetMenuSB(HMENU hmenuShared, HOLEMENU holemenuRes, HWND hwndActiveObject)
2118 {
2119 CComPtr<IShellMenu> shellMenu;
2120 HRESULT hResult;
2121
2122 if (hmenuShared && IsMenu(hmenuShared) == FALSE)
2123 return E_FAIL;
2124 hResult = GetMenuBand(IID_PPV_ARG(IShellMenu, &shellMenu));
2125 if (FAILED_UNEXPECTEDLY(hResult))
2126 return hResult;
2127
2128 if (!hmenuShared)
2129 {
2130 hmenuShared = LoadMenu(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDM_CABINET_MAINMENU));
2131 }
2132 // FIXME: Figure out the proper way to do this.
2133 HMENU hMenuFavs = GetSubMenu(hmenuShared, 3);
2134 if (hMenuFavs)
2135 {
2136 DeleteMenu(hMenuFavs, IDM_FAVORITES_EMPTY, MF_BYCOMMAND);
2137 }
2138
2139 hResult = shellMenu->SetMenu(hmenuShared, m_hWnd, SMSET_DONTOWN);
2140 if (FAILED_UNEXPECTEDLY(hResult))
2141 return hResult;
2142 fCurrentMenuBar = hmenuShared;
2143 BuildExplorerBandMenu();
2144 return S_OK;
2145 }
2146
2147 HRESULT STDMETHODCALLTYPE CShellBrowser::RemoveMenusSB(HMENU hmenuShared)
2148 {
2149 if (hmenuShared == fCurrentMenuBar)
2150 {
2151 //DestroyMenu(fCurrentMenuBar);
2152 SetMenuSB(NULL, NULL, NULL);
2153 }
2154 return S_OK;
2155 }
2156
2157 HRESULT STDMETHODCALLTYPE CShellBrowser::SetStatusTextSB(LPCOLESTR pszStatusText)
2158 {
2159 //
2160 if (pszStatusText)
2161 {
2162 ::SetWindowText(fStatusBar, pszStatusText);
2163 }
2164 else
2165 {
2166
2167 }
2168 return S_OK;
2169 }
2170
2171 HRESULT STDMETHODCALLTYPE CShellBrowser::EnableModelessSB(BOOL fEnable)
2172 {
2173 return E_NOTIMPL;
2174 }
2175
2176 HRESULT STDMETHODCALLTYPE CShellBrowser::TranslateAcceleratorSB(MSG *pmsg, WORD wID)
2177 {
2178 if (!::TranslateAcceleratorW(m_hWnd, m_hAccel, pmsg))
2179 return S_FALSE;
2180 return S_OK;
2181 }
2182
2183 HRESULT STDMETHODCALLTYPE CShellBrowser::BrowseObject(LPCITEMIDLIST pidl, UINT wFlags)
2184 {
2185 return BrowseToPIDL(pidl, BTP_UPDATE_CUR_HISTORY | BTP_UPDATE_NEXT_HISTORY);
2186 }
2187
2188 HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewStateStream(DWORD grfMode, IStream **ppStrm)
2189 {
2190 return E_NOTIMPL;
2191 }
2192
2193 HRESULT STDMETHODCALLTYPE CShellBrowser::GetControlWindow(UINT id, HWND *lphwnd)
2194 {
2195 if (lphwnd == NULL)
2196 return E_POINTER;
2197 *lphwnd = NULL;
2198 switch (id)
2199 {
2200 case FCW_TOOLBAR:
2201 *lphwnd = fToolbarProxy.m_hWnd;
2202 return S_OK;
2203 case FCW_STATUS:
2204 *lphwnd = fStatusBar;
2205 return S_OK;
2206 case FCW_TREE:
2207 // find the directory browser and return it
2208 // this should be used only to determine if a tree is present
2209 return S_OK;
2210 case FCW_PROGRESS:
2211 // is this a progress dialog?
2212 return S_OK;
2213 }
2214 return S_OK;
2215 }
2216
2217 HRESULT STDMETHODCALLTYPE CShellBrowser::SendControlMsg(
2218 UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pret)
2219 {
2220 LPARAM result;
2221
2222 if (pret != NULL)
2223 *pret = 0;
2224 switch (id)
2225 {
2226 case FCW_TOOLBAR:
2227 result = fToolbarProxy.SendMessage(uMsg, wParam, lParam);
2228 if (pret != NULL)
2229 *pret = result;
2230 break;
2231 case FCW_STATUS:
2232 result = SendMessage(fStatusBar, uMsg, wParam, lParam);
2233 if (pret != NULL)
2234 *pret = result;
2235 break;
2236 }
2237 return S_OK;
2238 }
2239
2240 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryActiveShellView(IShellView **ppshv)
2241 {
2242 if (ppshv == NULL)
2243 return E_POINTER;
2244 *ppshv = fCurrentShellView;
2245 if (fCurrentShellView.p != NULL)
2246 fCurrentShellView.p->AddRef();
2247 return S_OK;
2248 }
2249
2250 HRESULT STDMETHODCALLTYPE CShellBrowser::OnViewWindowActive(IShellView *ppshv)
2251 {
2252 return E_NOTIMPL;
2253 }
2254
2255 HRESULT STDMETHODCALLTYPE CShellBrowser::SetToolbarItems(LPTBBUTTON lpButtons, UINT nButtons, UINT uFlags)
2256 {
2257 return E_NOTIMPL;
2258 }
2259
2260 HRESULT STDMETHODCALLTYPE CShellBrowser::DragEnter(
2261 IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2262 {
2263 return E_NOTIMPL;
2264 }
2265
2266 HRESULT STDMETHODCALLTYPE CShellBrowser::DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2267 {
2268 return E_NOTIMPL;
2269 }
2270
2271 HRESULT STDMETHODCALLTYPE CShellBrowser::DragLeave()
2272 {
2273 return E_NOTIMPL;
2274 }
2275
2276 HRESULT STDMETHODCALLTYPE CShellBrowser::Drop(
2277 IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2278 {
2279 return E_NOTIMPL;
2280 }
2281
2282 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
2283 {
2284 // view does a query for SID_STopLevelBrowser, IID_IShellBrowserService
2285 // the returned interface has a method GetPropertyBag on it
2286 if (IsEqualIID(guidService, SID_STopLevelBrowser))
2287 return this->QueryInterface(riid, ppvObject);
2288 if (IsEqualIID(guidService, SID_SShellBrowser))
2289 return this->QueryInterface(riid, ppvObject);
2290 if (IsEqualIID(guidService, SID_ITargetFrame2))
2291 return this->QueryInterface(riid, ppvObject);
2292 if (IsEqualIID(guidService, SID_IWebBrowserApp)) // without this, the internet toolbar won't reflect notifications
2293 return this->QueryInterface(riid, ppvObject);
2294 if (IsEqualIID(guidService, SID_SProxyBrowser))
2295 return this->QueryInterface(riid, ppvObject);
2296 if (IsEqualIID(guidService, SID_IExplorerToolbar))
2297 return fClientBars[BIInternetToolbar].clientBar->QueryInterface(riid, ppvObject);
2298 if (IsEqualIID(riid, IID_IShellBrowser))
2299 return this->QueryInterface(riid, ppvObject);
2300 return E_NOINTERFACE;
2301 }
2302
2303 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPropertyBag(long flags, REFIID riid, void **ppvObject)
2304 {
2305 if (ppvObject == NULL)
2306 return E_POINTER;
2307 *ppvObject = NULL;
2308 return E_NOTIMPL;
2309 }
2310
2311 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTypeInfoCount(UINT *pctinfo)
2312 {
2313 return E_NOTIMPL;
2314 }
2315
2316 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
2317 {
2318 return E_NOTIMPL;
2319 }
2320
2321 HRESULT STDMETHODCALLTYPE CShellBrowser::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames,
2322 UINT cNames, LCID lcid, DISPID *rgDispId)
2323 {
2324 return E_NOTIMPL;
2325 }
2326
2327 HRESULT STDMETHODCALLTYPE CShellBrowser::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
2328 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2329 {
2330 return E_NOTIMPL;
2331 }
2332
2333 HRESULT STDMETHODCALLTYPE CShellBrowser::GetParentSite(IOleInPlaceSite **ppipsite)
2334 {
2335 return E_NOTIMPL;
2336 }
2337
2338 HRESULT STDMETHODCALLTYPE CShellBrowser::SetTitle(IShellView *psv, LPCWSTR pszName)
2339 {
2340 return E_NOTIMPL;
2341 }
2342
2343 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTitle(IShellView *psv, LPWSTR pszName, DWORD cchName)
2344 {
2345 return E_NOTIMPL;
2346 }
2347
2348 HRESULT STDMETHODCALLTYPE CShellBrowser::GetOleObject(IOleObject **ppobjv)
2349 {
2350 return E_NOTIMPL;
2351 }
2352
2353 HRESULT STDMETHODCALLTYPE CShellBrowser::GetTravelLog(ITravelLog **pptl)
2354 {
2355 HRESULT hResult;
2356
2357 // called by toolbar when displaying tooltips
2358 if (pptl == NULL)
2359 return E_FAIL;
2360
2361 *pptl = NULL;
2362 if (fTravelLog.p == NULL)
2363 {
2364 hResult = CTravelLog_CreateInstance(IID_PPV_ARG(ITravelLog, &fTravelLog));
2365 if (FAILED_UNEXPECTEDLY(hResult))
2366 return hResult;
2367 }
2368 *pptl = fTravelLog.p;
2369 fTravelLog.p->AddRef();
2370 return S_OK;
2371 }
2372
2373 HRESULT STDMETHODCALLTYPE CShellBrowser::ShowControlWindow(UINT id, BOOL fShow)
2374 {
2375 return E_NOTIMPL;
2376 }
2377
2378 HRESULT STDMETHODCALLTYPE CShellBrowser::IsControlWindowShown(UINT id, BOOL *pfShown)
2379 {
2380 return E_NOTIMPL;
2381 }
2382
2383 HRESULT STDMETHODCALLTYPE CShellBrowser::IEGetDisplayName(LPCITEMIDLIST pidl, LPWSTR pwszName, UINT uFlags)
2384 {
2385 return E_NOTIMPL;
2386 }
2387
2388 HRESULT STDMETHODCALLTYPE CShellBrowser::IEParseDisplayName(UINT uiCP, LPCWSTR pwszPath, LPITEMIDLIST *ppidlOut)
2389 {
2390 return E_NOTIMPL;
2391 }
2392
2393 HRESULT STDMETHODCALLTYPE CShellBrowser::DisplayParseError(HRESULT hres, LPCWSTR pwszPath)
2394 {
2395 return E_NOTIMPL;
2396 }
2397
2398 HRESULT STDMETHODCALLTYPE CShellBrowser::NavigateToPidl(LPCITEMIDLIST pidl, DWORD grfHLNF)
2399 {
2400 return E_NOTIMPL;
2401 }
2402
2403 HRESULT STDMETHODCALLTYPE CShellBrowser::SetNavigateState(BNSTATE bnstate)
2404 {
2405 return E_NOTIMPL;
2406 }
2407
2408 HRESULT STDMETHODCALLTYPE CShellBrowser::GetNavigateState(BNSTATE *pbnstate)
2409 {
2410 return E_NOTIMPL;
2411 }
2412
2413 HRESULT STDMETHODCALLTYPE CShellBrowser::NotifyRedirect(IShellView *psv, LPCITEMIDLIST pidl, BOOL *pfDidBrowse)
2414 {
2415 return E_NOTIMPL;
2416 }
2417
2418 HRESULT STDMETHODCALLTYPE CShellBrowser::UpdateWindowList()
2419 {
2420 return E_NOTIMPL;
2421 }
2422
2423 HRESULT STDMETHODCALLTYPE CShellBrowser::UpdateBackForwardState()
2424 {
2425 return E_NOTIMPL;
2426 }
2427
2428 HRESULT STDMETHODCALLTYPE CShellBrowser::SetFlags(DWORD dwFlags, DWORD dwFlagMask)
2429 {
2430 return E_NOTIMPL;
2431 }
2432
2433 HRESULT STDMETHODCALLTYPE CShellBrowser::GetFlags(DWORD *pdwFlags)
2434 {
2435 return E_NOTIMPL;
2436 }
2437
2438 HRESULT STDMETHODCALLTYPE CShellBrowser::CanNavigateNow()
2439 {
2440 return E_NOTIMPL;
2441 }
2442
2443 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPidl(LPITEMIDLIST *ppidl)
2444 {
2445 // called by explorer bar to get current pidl
2446 if (ppidl == NULL)
2447 return E_POINTER;
2448 *ppidl = ILClone(fCurrentDirectoryPIDL);
2449 return S_OK;
2450 }
2451
2452 HRESULT STDMETHODCALLTYPE CShellBrowser::SetReferrer(LPCITEMIDLIST pidl)
2453 {
2454 return E_NOTIMPL;
2455 }
2456
2457 DWORD STDMETHODCALLTYPE CShellBrowser::GetBrowserIndex()
2458 {
2459 return -1;
2460 }
2461
2462 HRESULT STDMETHODCALLTYPE CShellBrowser::GetBrowserByIndex(DWORD dwID, IUnknown **ppunk)
2463 {
2464 return E_NOTIMPL;
2465 }
2466
2467 HRESULT STDMETHODCALLTYPE CShellBrowser::GetHistoryObject(IOleObject **ppole, IStream **pstm, IBindCtx **ppbc)
2468 {
2469 if (ppole == NULL || pstm == NULL || ppbc == NULL)
2470 return E_INVALIDARG;
2471 *ppole = fHistoryObject;
2472 if (fHistoryObject != NULL)
2473 fHistoryObject->AddRef();
2474 *pstm = fHistoryStream;
2475 if (fHistoryStream != NULL)
2476 fHistoryStream->AddRef();
2477 *ppbc = fHistoryBindContext;
2478 if (fHistoryBindContext != NULL)
2479 fHistoryBindContext->AddRef();
2480 fHistoryObject = NULL;
2481 fHistoryStream = NULL;
2482 fHistoryBindContext = NULL;
2483 if (*ppole == NULL)
2484 return E_FAIL;
2485 return S_OK;
2486 }
2487
2488 HRESULT STDMETHODCALLTYPE CShellBrowser::SetHistoryObject(IOleObject *pole, BOOL fIsLocalAnchor)
2489 {
2490 return E_NOTIMPL;
2491 }
2492
2493 HRESULT STDMETHODCALLTYPE CShellBrowser::CacheOLEServer(IOleObject *pole)
2494 {
2495 return E_NOTIMPL;
2496 }
2497
2498 HRESULT STDMETHODCALLTYPE CShellBrowser::GetSetCodePage(VARIANT *pvarIn, VARIANT *pvarOut)
2499 {
2500 return E_NOTIMPL;
2501 }
2502
2503 HRESULT STDMETHODCALLTYPE CShellBrowser::OnHttpEquiv(
2504 IShellView *psv, BOOL fDone, VARIANT *pvarargIn, VARIANT *pvarargOut)
2505 {
2506 return E_NOTIMPL;
2507 }
2508
2509 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPalette(HPALETTE *hpal)
2510 {
2511 return E_NOTIMPL;
2512 }
2513
2514 HRESULT STDMETHODCALLTYPE CShellBrowser::RegisterWindow(BOOL fForceRegister, int swc)
2515 {
2516 return E_NOTIMPL;
2517 }
2518
2519 LRESULT STDMETHODCALLTYPE CShellBrowser::WndProcBS(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2520 {
2521 return E_NOTIMPL;
2522 }
2523
2524 HRESULT STDMETHODCALLTYPE CShellBrowser::SetAsDefFolderSettings()
2525 {
2526 return E_NOTIMPL;
2527 }
2528
2529 HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewRect(RECT *prc)
2530 {
2531 return E_NOTIMPL;
2532 }
2533
2534 HRESULT STDMETHODCALLTYPE CShellBrowser::OnSize(WPARAM wParam)
2535 {
2536 return E_NOTIMPL;
2537 }
2538
2539 HRESULT STDMETHODCALLTYPE CShellBrowser::OnCreate(struct tagCREATESTRUCTW *pcs)
2540 {
2541 m_hAccel = LoadAcceleratorsW(GetModuleHandle(L"browseui.dll"), MAKEINTRESOURCEW(256));
2542 return S_OK;
2543 }
2544
2545 LRESULT STDMETHODCALLTYPE CShellBrowser::OnCommand(WPARAM wParam, LPARAM lParam)
2546 {
2547 return 0;
2548 }
2549
2550 HRESULT STDMETHODCALLTYPE CShellBrowser::OnDestroy()
2551 {
2552 return E_NOTIMPL;
2553 }
2554
2555 LRESULT STDMETHODCALLTYPE CShellBrowser::OnNotify(struct tagNMHDR *pnm)
2556 {
2557 return 0;
2558 }
2559
2560 HRESULT STDMETHODCALLTYPE CShellBrowser::OnSetFocus()
2561 {
2562 return E_NOTIMPL;
2563 }
2564
2565 HRESULT STDMETHODCALLTYPE CShellBrowser::OnFrameWindowActivateBS(BOOL fActive)
2566 {
2567 return E_NOTIMPL;
2568 }
2569
2570 HRESULT STDMETHODCALLTYPE CShellBrowser::ReleaseShellView()
2571 {
2572 return E_NOTIMPL;
2573 }
2574
2575 HRESULT STDMETHODCALLTYPE CShellBrowser::ActivatePendingView()
2576 {
2577 return E_NOTIMPL;
2578 }
2579
2580 HRESULT STDMETHODCALLTYPE CShellBrowser::CreateViewWindow(
2581 IShellView *psvNew, IShellView *psvOld, LPRECT prcView, HWND *phwnd)
2582 {
2583 return E_NOTIMPL;
2584 }
2585
2586 HRESULT STDMETHODCALLTYPE CShellBrowser::CreateBrowserPropSheetExt(REFIID riid, void **ppv)
2587 {
2588 return E_NOTIMPL;
2589 }
2590
2591 HRESULT STDMETHODCALLTYPE CShellBrowser::GetViewWindow(HWND *phwndView)
2592 {
2593 return E_NOTIMPL;
2594 }
2595
2596 HRESULT STDMETHODCALLTYPE CShellBrowser::GetBaseBrowserData(LPCBASEBROWSERDATA *pbbd)
2597 {
2598 return E_NOTIMPL;
2599 }
2600
2601 LPBASEBROWSERDATA STDMETHODCALLTYPE CShellBrowser::PutBaseBrowserData()
2602 {
2603 return NULL;
2604 }
2605
2606 HRESULT STDMETHODCALLTYPE CShellBrowser::InitializeTravelLog(ITravelLog *ptl, DWORD dw)
2607 {
2608 return E_NOTIMPL;
2609 }
2610
2611 HRESULT STDMETHODCALLTYPE CShellBrowser::SetTopBrowser()
2612 {
2613 return E_NOTIMPL;
2614 }
2615
2616 HRESULT STDMETHODCALLTYPE CShellBrowser::Offline(int iCmd)
2617 {
2618 return E_NOTIMPL;
2619 }
2620
2621 HRESULT STDMETHODCALLTYPE CShellBrowser::AllowViewResize(BOOL f)
2622 {
2623 return E_NOTIMPL;
2624 }
2625
2626 HRESULT STDMETHODCALLTYPE CShellBrowser::SetActivateState(UINT u)
2627 {
2628 return E_NOTIMPL;
2629 }
2630
2631 HRESULT STDMETHODCALLTYPE CShellBrowser::UpdateSecureLockIcon(int eSecureLock)
2632 {
2633 return E_NOTIMPL;
2634 }
2635
2636 HRESULT STDMETHODCALLTYPE CShellBrowser::InitializeDownloadManager()
2637 {
2638 return E_NOTIMPL;
2639 }
2640
2641 HRESULT STDMETHODCALLTYPE CShellBrowser::InitializeTransitionSite()
2642 {
2643 return E_NOTIMPL;
2644 }
2645
2646 HRESULT STDMETHODCALLTYPE CShellBrowser::_Initialize(HWND hwnd, IUnknown *pauto)
2647 {
2648 return E_NOTIMPL;
2649 }
2650
2651 HRESULT STDMETHODCALLTYPE CShellBrowser::_CancelPendingNavigationAsync()
2652 {
2653 return E_NOTIMPL;
2654 }
2655
2656 HRESULT STDMETHODCALLTYPE CShellBrowser::_CancelPendingView()
2657 {
2658 return E_NOTIMPL;
2659 }
2660
2661 HRESULT STDMETHODCALLTYPE CShellBrowser::_MaySaveChanges()
2662 {
2663 return E_NOTIMPL;
2664 }
2665
2666 HRESULT STDMETHODCALLTYPE CShellBrowser::_PauseOrResumeView(BOOL fPaused)
2667 {
2668 return E_NOTIMPL;
2669 }
2670
2671 HRESULT STDMETHODCALLTYPE CShellBrowser::_DisableModeless()
2672 {
2673 return E_NOTIMPL;
2674 }
2675
2676 HRESULT STDMETHODCALLTYPE CShellBrowser::_NavigateToPidl(LPCITEMIDLIST pidl, DWORD grfHLNF, DWORD dwFlags)
2677 {
2678 return E_NOTIMPL;
2679 }
2680
2681 HRESULT STDMETHODCALLTYPE CShellBrowser::_TryShell2Rename(IShellView *psv, LPCITEMIDLIST pidlNew)
2682 {
2683 return E_NOTIMPL;
2684 }
2685
2686 HRESULT STDMETHODCALLTYPE CShellBrowser::_SwitchActivationNow()
2687 {
2688 return E_NOTIMPL;
2689 }
2690
2691 HRESULT STDMETHODCALLTYPE CShellBrowser::_ExecChildren(IUnknown *punkBar, BOOL fBroadcast,
2692 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut)
2693 {
2694 return E_NOTIMPL;
2695 }
2696
2697 HRESULT STDMETHODCALLTYPE CShellBrowser::_SendChildren(
2698 HWND hwndBar, BOOL fBroadcast, UINT uMsg, WPARAM wParam, LPARAM lParam)
2699 {
2700 return E_NOTIMPL;
2701 }
2702
2703 HRESULT STDMETHODCALLTYPE CShellBrowser::GetFolderSetData(struct tagFolderSetData *pfsd)
2704 {
2705 return E_NOTIMPL;
2706 }
2707
2708 HRESULT STDMETHODCALLTYPE CShellBrowser::_OnFocusChange(UINT itb)
2709 {
2710 return E_NOTIMPL;
2711 }
2712
2713 HRESULT STDMETHODCALLTYPE CShellBrowser::v_ShowHideChildWindows(BOOL fChildOnly)
2714 {
2715 return E_NOTIMPL;
2716 }
2717
2718 UINT STDMETHODCALLTYPE CShellBrowser::_get_itbLastFocus()
2719 {
2720 return 0;
2721 }
2722
2723 HRESULT STDMETHODCALLTYPE CShellBrowser::_put_itbLastFocus(UINT itbLastFocus)
2724 {
2725 return E_NOTIMPL;
2726 }
2727
2728 HRESULT STDMETHODCALLTYPE CShellBrowser::_UIActivateView(UINT uState)
2729 {
2730 return E_NOTIMPL;
2731 }
2732
2733 HRESULT STDMETHODCALLTYPE CShellBrowser::_GetViewBorderRect(RECT *prc)
2734 {
2735 return E_NOTIMPL;
2736 }
2737
2738 HRESULT STDMETHODCALLTYPE CShellBrowser::_UpdateViewRectSize()
2739 {
2740 return E_NOTIMPL;
2741 }
2742
2743 HRESULT STDMETHODCALLTYPE CShellBrowser::_ResizeNextBorder(UINT itb)
2744 {
2745 return E_NOTIMPL;
2746 }
2747
2748 HRESULT STDMETHODCALLTYPE CShellBrowser::_ResizeView()
2749 {
2750 return E_NOTIMPL;
2751 }
2752
2753 HRESULT STDMETHODCALLTYPE CShellBrowser::_GetEffectiveClientArea(LPRECT lprectBorder, HMONITOR hmon)
2754 {
2755 return E_NOTIMPL;
2756 }
2757
2758 IStream *STDMETHODCALLTYPE CShellBrowser::v_GetViewStream(LPCITEMIDLIST pidl, DWORD grfMode, LPCWSTR pwszName)
2759 {
2760 return NULL;
2761 }
2762
2763 LRESULT STDMETHODCALLTYPE CShellBrowser::ForwardViewMsg(UINT uMsg, WPARAM wParam, LPARAM lParam)
2764 {
2765 return 0;
2766 }
2767
2768 HRESULT STDMETHODCALLTYPE CShellBrowser::SetAcceleratorMenu(HACCEL hacc)
2769 {
2770 return E_NOTIMPL;
2771 }
2772
2773 int STDMETHODCALLTYPE CShellBrowser::_GetToolbarCount()
2774 {
2775 return 0;
2776 }
2777
2778 LPTOOLBARITEM STDMETHODCALLTYPE CShellBrowser::_GetToolbarItem(int itb)
2779 {
2780 return NULL;
2781 }
2782
2783 HRESULT STDMETHODCALLTYPE CShellBrowser::_SaveToolbars(IStream *pstm)
2784 {
2785 return E_NOTIMPL;
2786 }
2787
2788 HRESULT STDMETHODCALLTYPE CShellBrowser::_LoadToolbars(IStream *pstm)
2789 {
2790 return E_NOTIMPL;
2791 }
2792
2793 HRESULT STDMETHODCALLTYPE CShellBrowser::_CloseAndReleaseToolbars(BOOL fClose)
2794 {
2795 return E_NOTIMPL;
2796 }
2797
2798 HRESULT STDMETHODCALLTYPE CShellBrowser::v_MayGetNextToolbarFocus(
2799 LPMSG lpMsg, UINT itbNext, int citb, LPTOOLBARITEM *pptbi, HWND *phwnd)
2800 {
2801 return E_NOTIMPL;
2802 }
2803
2804 HRESULT STDMETHODCALLTYPE CShellBrowser::_ResizeNextBorderHelper(UINT itb, BOOL bUseHmonitor)
2805 {
2806 return E_NOTIMPL;
2807 }
2808
2809 UINT STDMETHODCALLTYPE CShellBrowser::_FindTBar(IUnknown *punkSrc)
2810 {
2811 return 0;
2812 }
2813
2814 HRESULT STDMETHODCALLTYPE CShellBrowser::_SetFocus(LPTOOLBARITEM ptbi, HWND hwnd, LPMSG lpMsg)
2815 {
2816 return E_NOTIMPL;
2817 }
2818
2819 HRESULT STDMETHODCALLTYPE CShellBrowser::v_MayTranslateAccelerator(MSG *pmsg)
2820 {
2821 for (int i = 0; i < 3; i++)
2822 {
2823 if (IUnknown_TranslateAcceleratorIO(fClientBars[i].clientBar, pmsg) == S_OK)
2824 return S_OK;
2825 }
2826
2827 if (!fCurrentShellView)
2828 return S_FALSE;
2829
2830 return fCurrentShellView->TranslateAcceleratorW(pmsg);
2831 }
2832
2833 HRESULT STDMETHODCALLTYPE CShellBrowser::_GetBorderDWHelper(IUnknown *punkSrc, LPRECT lprectBorder, BOOL bUseHmonitor)
2834 {
2835 return E_NOTIMPL;
2836 }
2837
2838 HRESULT STDMETHODCALLTYPE CShellBrowser::v_CheckZoneCrossing(LPCITEMIDLIST pidl)
2839 {
2840 return E_NOTIMPL;
2841 }
2842
2843 HRESULT STDMETHODCALLTYPE CShellBrowser::GoBack()
2844 {
2845 CComPtr<ITravelLog> travelLog;
2846 HRESULT hResult = GetTravelLog(&travelLog);
2847 if (FAILED_UNEXPECTEDLY(hResult))
2848 return hResult;
2849 return travelLog->Travel(static_cast<IDropTarget *>(this), TLOG_BACK);
2850 }
2851
2852 HRESULT STDMETHODCALLTYPE CShellBrowser::GoForward()
2853 {
2854 CComPtr<ITravelLog> travelLog;
2855 HRESULT hResult = GetTravelLog(&travelLog);
2856 if (FAILED_UNEXPECTEDLY(hResult))
2857 return hResult;
2858 return travelLog->Travel(static_cast<IDropTarget *>(this), TLOG_FORE);
2859 }
2860
2861 HRESULT STDMETHODCALLTYPE CShellBrowser::GoHome()
2862 {
2863 return E_NOTIMPL;
2864 }
2865
2866 HRESULT STDMETHODCALLTYPE CShellBrowser::GoSearch()
2867 {
2868 return E_NOTIMPL;
2869 }
2870
2871 HRESULT STDMETHODCALLTYPE CShellBrowser::Navigate(BSTR URL, VARIANT *Flags,
2872 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
2873 {
2874 CComHeapPtr<ITEMIDLIST> pidl;
2875 HRESULT hResult;
2876 CComPtr<IShellFolder> pDesktop;
2877
2878 hResult = SHGetDesktopFolder(&pDesktop);
2879 if (FAILED_UNEXPECTEDLY(hResult))
2880 return hResult;
2881 hResult = pDesktop->ParseDisplayName(NULL, NULL, URL, NULL, &pidl, NULL);
2882 if (FAILED_UNEXPECTEDLY(hResult))
2883 return hResult;
2884 return BrowseObject(pidl, 1);
2885 }
2886
2887 HRESULT STDMETHODCALLTYPE CShellBrowser::Refresh()
2888 {
2889 VARIANT level;
2890
2891 V_VT(&level) = VT_I4;
2892 V_I4(&level) = 4;
2893 return Refresh2(&level);
2894 }
2895
2896 HRESULT STDMETHODCALLTYPE CShellBrowser::Refresh2(VARIANT *Level)
2897 {
2898 CComPtr<IOleCommandTarget> oleCommandTarget;
2899 HRESULT hResult;
2900
2901 hResult = fCurrentShellView->QueryInterface(IID_PPV_ARG(IOleCommandTarget, &oleCommandTarget));
2902 if (FAILED_UNEXPECTEDLY(hResult))
2903 return hResult;
2904 return oleCommandTarget->Exec(NULL, 22, 1, Level, NULL);
2905 }
2906
2907 HRESULT STDMETHODCALLTYPE CShellBrowser::Stop()
2908 {
2909 return E_NOTIMPL;
2910 }
2911
2912 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Application(IDispatch **ppDisp)
2913 {
2914 return E_NOTIMPL;
2915 }
2916
2917 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Parent(IDispatch **ppDisp)
2918 {
2919 return E_NOTIMPL;
2920 }
2921
2922 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Container(IDispatch **ppDisp)
2923 {
2924 return E_NOTIMPL;
2925 }
2926
2927 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Document(IDispatch **ppDisp)
2928 {
2929 return E_NOTIMPL;
2930 }
2931
2932 HRESULT STDMETHODCALLTYPE CShellBrowser::get_TopLevelContainer(VARIANT_BOOL *pBool)
2933 {
2934 return E_NOTIMPL;
2935 }
2936
2937 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Type(BSTR *Type)
2938 {
2939 return E_NOTIMPL;
2940 }
2941 #ifdef __exdisp_h__
2942 #define long LONG
2943 #endif
2944 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Left(long *pl)
2945 {
2946 return E_NOTIMPL;
2947 }
2948
2949 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Left(long Left)
2950 {
2951 return E_NOTIMPL;
2952 }
2953
2954 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Top(long *pl)
2955 {
2956 return E_NOTIMPL;
2957 }
2958
2959 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Top(long Top)
2960 {
2961 return E_NOTIMPL;
2962 }
2963
2964 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Width(long *pl)
2965 {
2966 return E_NOTIMPL;
2967 }
2968
2969 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Width(long Width)
2970 {
2971 return E_NOTIMPL;
2972 }
2973
2974 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Height(long *pl)
2975 {
2976 return E_NOTIMPL;
2977 }
2978
2979 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Height(long Height)
2980 {
2981 return E_NOTIMPL;
2982 }
2983 #ifdef __exdisp_h__
2984 #undef long
2985 #endif
2986 HRESULT STDMETHODCALLTYPE CShellBrowser::get_LocationName(BSTR *LocationName)
2987 {
2988 return E_NOTIMPL;
2989 }
2990
2991 HRESULT STDMETHODCALLTYPE CShellBrowser::get_LocationURL(BSTR *LocationURL)
2992 {
2993 return E_NOTIMPL;
2994 }
2995
2996 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Busy(VARIANT_BOOL *pBool)
2997 {
2998 return E_NOTIMPL;
2999 }
3000
3001 HRESULT STDMETHODCALLTYPE CShellBrowser::Quit()
3002 {
3003 return E_NOTIMPL;
3004 }
3005
3006 HRESULT STDMETHODCALLTYPE CShellBrowser::ClientToWindow(int *pcx, int *pcy)
3007 {
3008 return E_NOTIMPL;
3009 }
3010
3011 HRESULT STDMETHODCALLTYPE CShellBrowser::PutProperty(BSTR Property, VARIANT vtValue)
3012 {
3013 return E_NOTIMPL;
3014 }
3015
3016 HRESULT STDMETHODCALLTYPE CShellBrowser::GetProperty(BSTR Property, VARIANT *pvtValue)
3017 {
3018 return E_NOTIMPL;
3019 }
3020
3021 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Name(BSTR *Name)
3022 {
3023 return E_NOTIMPL;
3024 }
3025
3026 HRESULT STDMETHODCALLTYPE CShellBrowser::get_HWND(SHANDLE_PTR *pHWND)
3027 {
3028 return E_NOTIMPL;
3029 }
3030
3031 HRESULT STDMETHODCALLTYPE CShellBrowser::get_FullName(BSTR *FullName)
3032 {
3033 return E_NOTIMPL;
3034 }
3035
3036 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Path(BSTR *Path)
3037 {
3038 return E_NOTIMPL;
3039 }
3040
3041 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Visible(VARIANT_BOOL *pBool)
3042 {
3043 return E_NOTIMPL;
3044 }
3045
3046 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Visible(VARIANT_BOOL Value)
3047 {
3048 return E_NOTIMPL;
3049 }
3050
3051 HRESULT STDMETHODCALLTYPE CShellBrowser::get_StatusBar(VARIANT_BOOL *pBool)
3052 {
3053 return E_NOTIMPL;
3054 }
3055
3056 HRESULT STDMETHODCALLTYPE CShellBrowser::put_StatusBar(VARIANT_BOOL Value)
3057 {
3058 return E_NOTIMPL;
3059 }
3060
3061 HRESULT STDMETHODCALLTYPE CShellBrowser::get_StatusText(BSTR *StatusText)
3062 {
3063 return E_NOTIMPL;
3064 }
3065
3066 HRESULT STDMETHODCALLTYPE CShellBrowser::put_StatusText(BSTR StatusText)
3067 {
3068 return E_NOTIMPL;
3069 }
3070
3071 HRESULT STDMETHODCALLTYPE CShellBrowser::get_ToolBar(int *Value)
3072 {
3073 return E_NOTIMPL;
3074 }
3075
3076 HRESULT STDMETHODCALLTYPE CShellBrowser::put_ToolBar(int Value)
3077 {
3078 return E_NOTIMPL;
3079 }
3080
3081 HRESULT STDMETHODCALLTYPE CShellBrowser::get_MenuBar(VARIANT_BOOL *Value)
3082 {
3083 return E_NOTIMPL;
3084 }
3085
3086 HRESULT STDMETHODCALLTYPE CShellBrowser::put_MenuBar(VARIANT_BOOL Value)
3087 {
3088 return E_NOTIMPL;
3089 }
3090
3091 HRESULT STDMETHODCALLTYPE CShellBrowser::get_FullScreen(VARIANT_BOOL *pbFullScreen)
3092 {
3093 return E_NOTIMPL;
3094 }
3095
3096 HRESULT STDMETHODCALLTYPE CShellBrowser::put_FullScreen(VARIANT_BOOL bFullScreen)
3097 {
3098 return E_NOTIMPL;
3099 }
3100
3101 HRESULT STDMETHODCALLTYPE CShellBrowser::Navigate2(VARIANT *URL, VARIANT *Flags,
3102 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
3103 {
3104 LPITEMIDLIST pidl = NULL;
3105 HRESULT hResult;
3106 // called from drive combo box to navigate to a directory
3107 // Also called by search band to display shell results folder view
3108
3109 if (V_VT(URL) == VT_BSTR)
3110 {
3111 return this->Navigate(V_BSTR(URL), Flags, TargetFrameName, PostData, Headers);
3112 }
3113 if (V_VT(URL) == (VT_ARRAY | VT_UI1))
3114 {
3115 if (V_ARRAY(URL)->cDims != 1 || V_ARRAY(URL)->cbElements != 1)
3116 return E_INVALIDARG;
3117
3118 pidl = static_cast<LPITEMIDLIST>(V_ARRAY(URL)->pvData);
3119 }
3120 hResult = BrowseToPIDL(pidl, BTP_UPDATE_CUR_HISTORY | BTP_UPDATE_NEXT_HISTORY);
3121 if (FAILED_UNEXPECTEDLY(hResult))
3122 return hResult;
3123 return S_OK;
3124 }
3125
3126 HRESULT STDMETHODCALLTYPE CShellBrowser::QueryStatusWB(OLECMDID cmdID, OLECMDF *pcmdf)
3127 {
3128 return E_NOTIMPL;
3129 }
3130
3131 HRESULT STDMETHODCALLTYPE CShellBrowser::ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt,
3132 VARIANT *pvaIn, VARIANT *pvaOut)
3133 {
3134 return E_NOTIMPL;
3135 }
3136
3137 HRESULT STDMETHODCALLTYPE CShellBrowser::ShowBrowserBar(VARIANT *pvaClsid, VARIANT *pvarShow, VARIANT *pvarSize)
3138 {
3139 CLSID classID;
3140 bool vertical;
3141
3142 // called to show search bar
3143 if (V_VT(pvaClsid) != VT_BSTR)
3144 return E_INVALIDARG;
3145 CLSIDFromString(V_BSTR(pvaClsid), &classID);
3146 // TODO: properly compute the value of vertical
3147 vertical = true;
3148 return ShowBand(classID, vertical);
3149 }
3150
3151 HRESULT STDMETHODCALLTYPE CShellBrowser::get_ReadyState(READYSTATE *plReadyState)
3152 {
3153 return E_NOTIMPL;
3154 }
3155
3156 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Offline(VARIANT_BOOL *pbOffline)
3157 {
3158 return E_NOTIMPL;
3159 }
3160
3161 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Offline(VARIANT_BOOL bOffline)
3162 {
3163 return E_NOTIMPL;
3164 }
3165
3166 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Silent(VARIANT_BOOL *pbSilent)
3167 {
3168 return E_NOTIMPL;
3169 }
3170
3171 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Silent(VARIANT_BOOL bSilent)
3172 {
3173 return E_NOTIMPL;
3174 }
3175
3176 HRESULT STDMETHODCALLTYPE CShellBrowser::get_RegisterAsBrowser(VARIANT_BOOL *pbRegister)
3177 {
3178 return E_NOTIMPL;
3179 }
3180
3181 HRESULT STDMETHODCALLTYPE CShellBrowser::put_RegisterAsBrowser(VARIANT_BOOL bRegister)
3182 {
3183 return E_NOTIMPL;
3184 }
3185
3186 HRESULT STDMETHODCALLTYPE CShellBrowser::get_RegisterAsDropTarget(VARIANT_BOOL *pbRegister)
3187 {
3188 return E_NOTIMPL;
3189 }
3190
3191 HRESULT STDMETHODCALLTYPE CShellBrowser::put_RegisterAsDropTarget(VARIANT_BOOL bRegister)
3192 {
3193 return E_NOTIMPL;
3194 }
3195
3196 HRESULT STDMETHODCALLTYPE CShellBrowser::get_TheaterMode(VARIANT_BOOL *pbRegister)
3197 {
3198 return E_NOTIMPL;
3199 }
3200
3201 HRESULT STDMETHODCALLTYPE CShellBrowser::put_TheaterMode(VARIANT_BOOL bRegister)
3202 {
3203 return E_NOTIMPL;
3204 }
3205
3206 HRESULT STDMETHODCALLTYPE CShellBrowser::get_AddressBar(VARIANT_BOOL *Value)
3207 {
3208 return E_NOTIMPL;
3209 }
3210
3211 HRESULT STDMETHODCALLTYPE CShellBrowser::put_AddressBar(VARIANT_BOOL Value)
3212 {
3213 return E_NOTIMPL;
3214 }
3215
3216 HRESULT STDMETHODCALLTYPE CShellBrowser::get_Resizable(VARIANT_BOOL *Value)
3217 {
3218 return E_NOTIMPL;
3219 }
3220
3221 HRESULT STDMETHODCALLTYPE CShellBrowser::put_Resizable(VARIANT_BOOL Value)
3222 {
3223 return E_NOTIMPL;
3224 }
3225
3226 HRESULT STDMETHODCALLTYPE CShellBrowser::FindWindowByIndex(DWORD dwID, IUnknown **ppunk)
3227 {
3228 return E_NOTIMPL;
3229 }
3230
3231 HRESULT STDMETHODCALLTYPE CShellBrowser::GetWindowData(IStream *pStream, LPWINDOWDATA pWinData)
3232 {
3233 if (pWinData == NULL)
3234 return E_POINTER;
3235
3236 pWinData->dwWindowID = -1;
3237 pWinData->uiCP = 0;
3238 pWinData->pidl = ILClone(fCurrentDirectoryPIDL);
3239 pWinData->lpszUrl = NULL;
3240 pWinData->lpszUrlLocation = NULL;
3241 pWinData->lpszTitle = NULL;
3242 return S_OK;
3243 }
3244
3245 HRESULT STDMETHODCALLTYPE CShellBrowser::LoadHistoryPosition(LPWSTR pszUrlLocation, DWORD dwPosition)
3246 {
3247 return E_NOTIMPL;
3248 }
3249
3250 HRESULT STDMETHODCALLTYPE CShellBrowser::GetClassID(CLSID *pClassID)
3251 {
3252 return E_NOTIMPL;
3253 }
3254
3255 HRESULT STDMETHODCALLTYPE CShellBrowser::LoadHistory(IStream *pStream, IBindCtx *pbc)
3256 {
3257 CComPtr<IPersistHistory> viewPersistHistory;
3258 CComPtr<IOleObject> viewHistoryObject;
3259 persistState oldState;
3260 ULONG numRead;
3261 LPITEMIDLIST pidl;
3262 HRESULT hResult;
3263
3264 hResult = pStream->Read(&oldState, sizeof(oldState), &numRead);
3265 if (FAILED_UNEXPECTEDLY(hResult))
3266 return hResult;
3267 if (numRead != sizeof(oldState) || oldState.dwSize != sizeof(oldState))
3268 return E_FAIL;
3269 if (oldState.browseType != 2)
3270 return E_FAIL;
3271 pidl = static_cast<LPITEMIDLIST>(CoTaskMemAlloc(oldState.pidlSize));
3272 if (pidl == NULL)
3273 return E_OUTOFMEMORY;
3274 hResult = pStream->Read(pidl, oldState.pidlSize, &numRead);
3275 if (FAILED_UNEXPECTEDLY(hResult))
3276 {
3277 ILFree(pidl);
3278 return hResult;
3279 }
3280 if (numRead != oldState.pidlSize)
3281 {
3282 ILFree(pidl);
3283 return E_FAIL;
3284 }
3285 hResult = CoCreateInstance(oldState.persistClass, NULL, CLSCTX_LOCAL_SERVER | CLSCTX_INPROC_SERVER,
3286 IID_PPV_ARG(IOleObject, &viewHistoryObject));
3287 fHistoryObject = viewHistoryObject;
3288 fHistoryStream = pStream;
3289 fHistoryBindContext = pbc;
3290 hResult = BrowseToPIDL(pidl, BTP_DONT_UPDATE_HISTORY);
3291 fHistoryObject = NULL;
3292 fHistoryStream = NULL;
3293 fHistoryBindContext = NULL;
3294 ILFree(pidl);
3295 if (FAILED_UNEXPECTEDLY(hResult))
3296 return hResult;
3297 return S_OK;
3298 }
3299
3300 HRESULT STDMETHODCALLTYPE CShellBrowser::SaveHistory(IStream *pStream)
3301 {
3302 CComPtr<IPersistHistory> viewPersistHistory;
3303 persistState newState;
3304 HRESULT hResult;
3305
3306 hResult = fCurrentShellView->GetItemObject(
3307 SVGIO_BACKGROUND, IID_PPV_ARG(IPersistHistory, &viewPersistHistory));
3308 memset(&newState, 0, sizeof(newState));
3309 newState.dwSize = sizeof(newState);
3310 newState.browseType = 2;
3311 newState.browserIndex = GetBrowserIndex();
3312 if (viewPersistHistory.p != NULL)
3313 {
3314 hResult = viewPersistHistory->GetClassID(&newState.persistClass);
3315 if (FAILED_UNEXPECTEDLY(hResult))
3316 return hResult;
3317 }
3318 newState.pidlSize = ILGetSize(fCurrentDirectoryPIDL);
3319 hResult = pStream->Write(&newState, sizeof(newState), NULL);
3320 if (FAILED_UNEXPECTEDLY(hResult))
3321 return hResult;
3322 hResult = pStream->Write(fCurrentDirectoryPIDL, newState.pidlSize, NULL);
3323 if (FAILED_UNEXPECTEDLY(hResult))
3324 return hResult;
3325 if (viewPersistHistory.p != NULL)
3326 {
3327 hResult = viewPersistHistory->SaveHistory(pStream);
3328 if (FAILED_UNEXPECTEDLY(hResult))
3329 return hResult;
3330 }
3331 return S_OK;
3332 }
3333
3334 HRESULT STDMETHODCALLTYPE CShellBrowser::SetPositionCookie(DWORD dwPositioncookie)
3335 {
3336 return E_NOTIMPL;
3337 }
3338
3339 HRESULT STDMETHODCALLTYPE CShellBrowser::GetPositionCookie(DWORD *pdwPositioncookie)
3340 {
3341 return E_NOTIMPL;
3342 }
3343
3344 LRESULT CShellBrowser::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3345 {
3346 OnCreate(reinterpret_cast<LPCREATESTRUCT> (lParam));
3347 return 0;
3348 }
3349
3350 LRESULT CShellBrowser::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3351 {
3352 HRESULT hr;
3353
3354 /* The current thread is about to go down so render any IDataObject that may be left in the clipboard */
3355 OleFlushClipboard();
3356
3357 // TODO: rip down everything
3358 {
3359 fCurrentShellView->DestroyViewWindow();
3360 fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
3361 ReleaseCComPtrExpectZero(fCurrentShellView);
3362
3363 for (int i = 0; i < 3; i++)
3364 {
3365 CComPtr<IDockingWindow> pdw;
3366 CComPtr<IDeskBar> bar;
3367 CComPtr<IUnknown> pBarSite;
3368 CComPtr<IDeskBarClient> pClient;
3369
3370 if (fClientBars[i].clientBar == NULL)
3371 continue;
3372
3373 hr = fClientBars[i].clientBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &pdw));
3374 if (FAILED_UNEXPECTEDLY(hr))
3375 continue;
3376
3377 /* We should destroy our basebarsite too */
3378 hr = pdw->QueryInterface(IID_PPV_ARG(IDeskBar, &bar));
3379 if (SUCCEEDED(hr))
3380 {
3381 hr = bar->GetClient(&pBarSite);
3382 if (SUCCEEDED(hr) && pBarSite)
3383 {
3384 hr = pBarSite->QueryInterface(IID_PPV_ARG(IDeskBarClient, &pClient));
3385 if (SUCCEEDED(hr))
3386 pClient->SetDeskBarSite(NULL);
3387 }
3388 }
3389 pdw->CloseDW(0);
3390 pdw = NULL;
3391 /* For some reasons, it's like we miss some AddRef in ATL when QueryInterface on
3392 * same interface or inherited one, so we are removing already removed (!) object.
3393 * TODO: check with MSVC's ATL to see if this behaviour happens too
3394 */
3395 bar.Detach();
3396 pClient.Detach();
3397 pBarSite.Detach();
3398 ReleaseCComPtrExpectZero(fClientBars[i].clientBar);
3399 }
3400 ReleaseCComPtrExpectZero(fTravelLog);
3401
3402 fCurrentShellFolder.Release();
3403 ILFree(fCurrentDirectoryPIDL);
3404 ::DestroyWindow(fStatusBar);
3405 DestroyMenu(fCurrentMenuBar);
3406 }
3407 PostQuitMessage(0);
3408 return 0;
3409 }
3410
3411 LRESULT CShellBrowser::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3412 {
3413 CComPtr<IDockingWindow> dockingWindow;
3414 RECT availableBounds;
3415 static const INT excludeItems[] = {1, 1, 1, 0xa001, 0, 0};
3416 HRESULT hResult;
3417
3418 if (wParam != SIZE_MINIMIZED)
3419 {
3420 GetEffectiveClientRect(m_hWnd, &availableBounds, excludeItems);
3421 for (INT x = 0; x < 3; x++)
3422 {
3423 if (fClientBars[x].clientBar != NULL)
3424 {
3425 hResult = fClientBars[x].clientBar->QueryInterface(
3426 IID_PPV_ARG(IDockingWindow, &dockingWindow));
3427 if (SUCCEEDED(hResult) && dockingWindow != NULL)
3428 {
3429 hResult = dockingWindow->ResizeBorderDW(
3430 &availableBounds, static_cast<IDropTarget *>(this), TRUE);
3431 break;
3432 }
3433 }
3434 }
3435 RepositionBars();
3436 }
3437 return 1;
3438 }
3439
3440 LRESULT CShellBrowser::OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
3441 {
3442 HMENU theMenu;
3443 LPARAM menuIndex = lParam;
3444
3445 theMenu = reinterpret_cast<HMENU>(wParam);
3446
3447 if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_FILE))
3448 {
3449 menuIndex = 0;
3450 }
3451 else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_EDIT))
3452 {
3453 menuIndex = 1;
3454 }
3455 else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_VIEW))
3456 {
3457 UpdateViewMenu(theMenu);
3458 menuIndex = 2;
3459 }
3460 else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_FAVORITES))
3461 {
3462 menuIndex = 3;
3463 }
3464 else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_TOOLS))
3465 {
3466 // FIXME: Remove once implemented
3467 SHEnableMenuItem(theMenu, IDM_TOOLS_MAPNETWORKDRIVE, FALSE);
3468 SHEnableMenuItem(theMenu, IDM_TOOLS_DISCONNECTNETWORKDRIVE, FALSE);
3469 SHEnableMenuItem(theMenu, IDM_TOOLS_SYNCHRONIZE, FALSE);
3470 FIXME("Folder options dialog is stubbed: CORE-11141\n");
3471 SHEnableMenuItem(theMenu, IDM_TOOLS_FOLDEROPTIONS, FALSE); // Remove when CORE-11141 is fixed.
3472 menuIndex = 4;
3473 }
3474 else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_HELP))
3475 {
3476 menuIndex = 5;
3477 }
3478
3479 LRESULT ret =