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