Author: dquintana
Date: Thu Feb 20 16:18:49 2014
New Revision: 62263
URL:
http://svn.reactos.org/svn/reactos?rev=62263&view=rev
Log:
[RSHELL]
* Improve the layout of the class definitions to make the important details easier to
find.
* Rename private (non-COM) class methods to more appropriate names, including a prefix.
* CMenuBand: Make one submenu close before showing another one. This may not be happening
in the same exact way windows does it.
CORE-7881
Modified:
branches/shell-experiments/base/shell/rshell/CMenuBand.cpp
branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp
branches/shell-experiments/base/shell/rshell/CMenuSite.cpp
branches/shell-experiments/base/shell/rshell/precomp.h
Modified: branches/shell-experiments/base/shell/rshell/CMenuBand.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuBand.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuBand.cpp [iso-8859-1] Thu Feb 20
16:18:49 2014
@@ -21,9 +21,9 @@
#include <windowsx.h>
#include <shlwapi_undoc.h>
+#define TBSTYLE_EX_VERTICAL 4
+
WINE_DEFAULT_DEBUG_CHANNEL(CMenuBand);
-
-#define TBSTYLE_EX_VERTICAL 4
#define TIMERID_HOTTRACK 1
#define SUBCLASS_ID_MENUBAND 1
@@ -35,47 +35,49 @@
class CMenuToolbarBase
{
+protected:
+ CMenuBand * m_menuBand;
+ HWND m_hwnd;
+ DWORD m_dwMenuFlags;
+ INT m_hotItem;
+ WNDPROC m_SubclassOld;
+
+private:
+ static LRESULT CALLBACK s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam);
+
public:
CMenuToolbarBase(CMenuBand *menuBand);
virtual ~CMenuToolbarBase() {}
+ HRESULT IsWindowOwner(HWND hwnd);
HRESULT CreateToolbar(HWND hwndParent, DWORD dwFlags);
HRESULT GetWindow(HWND *phwnd);
HRESULT ShowWindow(BOOL fShow);
HRESULT Close();
- BOOL IsWindowOwner(HWND hwnd) { return m_hwnd && m_hwnd == hwnd; }
-
virtual HRESULT FillToolbar() = 0;
virtual HRESULT PopupItem(UINT uItem) = 0;
virtual HRESULT HasSubMenu(UINT uItem) = 0;
+ virtual HRESULT OnContextMenu(NMMOUSE * rclick) = 0;
virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
- virtual HRESULT OnContextMenu(NMMOUSE * rclick) = 0;
-
- HRESULT OnHotItemChange(const NMTBHOTITEM * hot);
HRESULT PopupSubMenu(UINT index, IShellMenu* childShellMenu);
HRESULT PopupSubMenu(UINT index, HMENU menu);
HRESULT DoContextMenu(IContextMenu* contextMenu);
- HRESULT ChildTrack(DWORD dwSelectType);
-
- static LRESULT CALLBACK s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam);
+ HRESULT ChangeHotItem(DWORD changeType);
+ HRESULT OnHotItemChange(const NMTBHOTITEM * hot);
+
protected:
-
- static const UINT WM_USER_SHOWPOPUPMENU = WM_USER + 1;
-
LRESULT CALLBACK SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
- CMenuBand *m_menuBand;
- HWND m_hwnd;
- DWORD m_dwMenuFlags;
- INT m_hotItem;
- WNDPROC m_SubclassOld;
};
-class CMenuStaticToolbar : public CMenuToolbarBase
-{
+class CMenuStaticToolbar :
+ public CMenuToolbarBase
+{
+private:
+ HMENU m_hmenu;
+
public:
CMenuStaticToolbar(CMenuBand *menuBand);
virtual ~CMenuStaticToolbar() {}
@@ -89,12 +91,16 @@
virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
virtual HRESULT OnContextMenu(NMMOUSE * rclick);
+};
+
+class CMenuSFToolbar :
+ public CMenuToolbarBase
+{
private:
- HMENU m_hmenu;
-};
-
-class CMenuSFToolbar : public CMenuToolbarBase
-{
+ IShellFolder * m_shellFolder;
+ LPCITEMIDLIST m_idList;
+ HKEY m_hKey;
+
public:
CMenuSFToolbar(CMenuBand *menuBand);
virtual ~CMenuSFToolbar();
@@ -109,11 +115,7 @@
virtual HRESULT OnContextMenu(NMMOUSE * rclick);
private:
- LPITEMIDLIST GetPidlFromId(UINT uItem, INT* pIndex);
-
- IShellFolder * m_shellFolder;
- LPCITEMIDLIST m_idList;
- HKEY m_hKey;
+ LPITEMIDLIST GetPidlFromId(UINT uItem, INT* pIndex = NULL);
};
class CMenuBand :
@@ -131,127 +133,31 @@
public IWinEventHandler,
public IShellMenuAcc
{
+private:
+ CMenuFocusManager * m_focusManager;
+ CMenuStaticToolbar * m_staticToolbar;
+ CMenuSFToolbar * m_SFToolbar;
+
+ CComPtr<IOleWindow> m_site;
+ CComPtr<IShellMenuCallback> m_psmc;
+ CComPtr<IMenuPopup> m_childMenu;
+
+ UINT m_uId;
+ UINT m_uIdAncestor;
+ DWORD m_dwFlags;
+ PVOID m_UserData;
+ HMENU m_hmenu;
+ HWND m_menuOwner;
+
+ BOOL m_useBigIcons;
+ HWND m_topLevelWindow;
+
+ CMenuToolbarBase * m_hotBar;
+ INT m_hotItem;
+
public:
CMenuBand();
~CMenuBand();
-
-private:
- IOleWindow *m_site;
- IShellMenuCallback *m_psmc;
-
- CMenuStaticToolbar *m_staticToolbar;
- CMenuSFToolbar *m_SFToolbar;
-
- UINT m_uId;
- UINT m_uIdAncestor;
- DWORD m_dwFlags;
- PVOID m_UserData;
- HMENU m_hmenu;
- HWND m_menuOwner;
-
- BOOL m_useBigIcons;
-
- HWND m_topLevelWindow;
-
- CMenuFocusManager * m_focusManager;
-
- CMenuToolbarBase * m_hotBar;
- INT m_hotItem;
-
-public:
-
- // *** IDeskBand methods ***
- virtual HRESULT STDMETHODCALLTYPE GetBandInfo(DWORD dwBandID, DWORD dwViewMode,
DESKBANDINFO *pdbi);
-
- // *** IDockingWindow methods ***
- virtual HRESULT STDMETHODCALLTYPE ShowDW(BOOL fShow);
- virtual HRESULT STDMETHODCALLTYPE CloseDW(DWORD dwReserved);
- virtual HRESULT STDMETHODCALLTYPE ResizeBorderDW(LPCRECT prcBorder, IUnknown
*punkToolbarSite, BOOL fReserved);
-
- // *** IOleWindow methods ***
- virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *phwnd);
- virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
-
- // *** IObjectWithSite methods ***
- virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
- virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, PVOID *ppvSite);
-
- // *** IInputObject methods ***
- virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg);
- virtual HRESULT STDMETHODCALLTYPE HasFocusIO();
- virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg);
-
- // *** IPersistStream methods ***
- virtual HRESULT STDMETHODCALLTYPE IsDirty();
- virtual HRESULT STDMETHODCALLTYPE Load(IStream *pStm);
- virtual HRESULT STDMETHODCALLTYPE Save(IStream *pStm, BOOL fClearDirty);
- virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize);
-
- // *** IPersist methods ***
- virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
-
- // *** IOleCommandTarget methods ***
- virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds,
OLECMD prgCmds [], OLECMDTEXT *pCmdText);
- virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
-
- // *** IServiceProvider methods ***
- virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void
**ppvObject);
-
- // *** IMenuPopup methods ***
- virtual HRESULT STDMETHODCALLTYPE Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS
dwFlags);
- virtual HRESULT STDMETHODCALLTYPE OnSelect(DWORD dwSelectType);
- virtual HRESULT STDMETHODCALLTYPE SetSubMenu(IMenuPopup *pmp, BOOL fSet);
-
- // *** IDeskBar methods ***
- virtual HRESULT STDMETHODCALLTYPE SetClient(IUnknown *punkClient);
- virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown **ppunkClient);
- virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(RECT *prc);
-
- // *** IMenuBand methods ***
- virtual HRESULT STDMETHODCALLTYPE IsMenuMessage(MSG *pmsg);
- virtual HRESULT STDMETHODCALLTYPE TranslateMenuMessage(MSG *pmsg, LRESULT *plRet);
-
- // *** IShellMenu methods ***
- virtual HRESULT STDMETHODCALLTYPE Initialize(IShellMenuCallback *psmc, UINT uId, UINT
uIdAncestor, DWORD dwFlags);
- virtual HRESULT STDMETHODCALLTYPE GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId,
UINT *puIdAncestor, DWORD *pdwFlags);
- virtual HRESULT STDMETHODCALLTYPE SetShellFolder(IShellFolder *psf, LPCITEMIDLIST
pidlFolder, HKEY hKey, DWORD dwFlags);
- virtual HRESULT STDMETHODCALLTYPE GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST
*ppidl, REFIID riid, void **ppv);
- virtual HRESULT STDMETHODCALLTYPE SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
- virtual HRESULT STDMETHODCALLTYPE GetMenu(HMENU *phmenu, HWND *phwnd, DWORD
*pdwFlags);
- virtual HRESULT STDMETHODCALLTYPE InvalidateItem(LPSMDATA psmd, DWORD dwFlags);
- virtual HRESULT STDMETHODCALLTYPE GetState(LPSMDATA psmd);
- virtual HRESULT STDMETHODCALLTYPE SetMenuToolbar(IUnknown *punk, DWORD dwFlags);
-
- // *** IWinEventHandler methods ***
- virtual HRESULT STDMETHODCALLTYPE OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, LRESULT *theResult);
- virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd);
-
- // *** IShellMenu2 methods ***
- virtual HRESULT STDMETHODCALLTYPE GetSubMenu(THIS);
- virtual HRESULT STDMETHODCALLTYPE SetToolbar(THIS);
- virtual HRESULT STDMETHODCALLTYPE SetMinWidth(THIS);
- virtual HRESULT STDMETHODCALLTYPE SetNoBorder(THIS);
- virtual HRESULT STDMETHODCALLTYPE SetTheme(THIS);
-
- // *** IShellMenuAcc methods ***
- virtual HRESULT STDMETHODCALLTYPE GetTop(THIS);
- virtual HRESULT STDMETHODCALLTYPE GetBottom(THIS);
- virtual HRESULT STDMETHODCALLTYPE GetTracked(THIS);
- virtual HRESULT STDMETHODCALLTYPE GetParentSite(THIS);
- virtual HRESULT STDMETHODCALLTYPE GetState(THIS);
- virtual HRESULT STDMETHODCALLTYPE DoDefaultAction(THIS);
- virtual HRESULT STDMETHODCALLTYPE IsEmpty(THIS);
-
- HRESULT CallCBWithId(UINT Id, UINT uMsg, WPARAM wParam, LPARAM lParam);
- HRESULT CallCBWithPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam, LPARAM lParam);
- HRESULT TrackPopup(HMENU popup, INT x, INT y);
- HRESULT GetTopLevelWindow(HWND*topLevel);
- HRESULT OnHotItemChanged(CMenuToolbarBase * tb, INT id);
- HRESULT ChildTrack(DWORD reason);
-
- BOOL UseBigIcons() {
- return m_useBigIcons;
- }
DECLARE_NOT_AGGREGATABLE(CMenuBand)
DECLARE_PROTECT_FINAL_CONSTRUCT()
@@ -275,6 +181,101 @@
COM_INTERFACE_ENTRY_IID(IID_IShellMenuAcc, IShellMenuAcc)
END_COM_MAP()
+ // *** IDeskBand methods ***
+ virtual HRESULT STDMETHODCALLTYPE GetBandInfo(DWORD dwBandID, DWORD dwViewMode,
DESKBANDINFO *pdbi);
+
+ // *** IDockingWindow methods ***
+ virtual HRESULT STDMETHODCALLTYPE ShowDW(BOOL fShow);
+ virtual HRESULT STDMETHODCALLTYPE CloseDW(DWORD dwReserved);
+ virtual HRESULT STDMETHODCALLTYPE ResizeBorderDW(LPCRECT prcBorder, IUnknown
*punkToolbarSite, BOOL fReserved);
+
+ // *** IOleWindow methods ***
+ virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *phwnd);
+ virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
+
+ // *** IObjectWithSite methods ***
+ virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
+ virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, PVOID *ppvSite);
+
+ // *** IInputObject methods ***
+ virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg);
+ virtual HRESULT STDMETHODCALLTYPE HasFocusIO();
+ virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg);
+
+ // *** IPersistStream methods ***
+ virtual HRESULT STDMETHODCALLTYPE IsDirty();
+ virtual HRESULT STDMETHODCALLTYPE Load(IStream *pStm);
+ virtual HRESULT STDMETHODCALLTYPE Save(IStream *pStm, BOOL fClearDirty);
+ virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize);
+
+ // *** IPersist methods ***
+ virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
+
+ // *** IOleCommandTarget methods ***
+ virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds,
OLECMD prgCmds [], OLECMDTEXT *pCmdText);
+ virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
+
+ // *** IServiceProvider methods ***
+ virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void
**ppvObject);
+
+ // *** IMenuPopup methods ***
+ virtual HRESULT STDMETHODCALLTYPE Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS
dwFlags);
+ virtual HRESULT STDMETHODCALLTYPE OnSelect(DWORD dwSelectType);
+ virtual HRESULT STDMETHODCALLTYPE SetSubMenu(IMenuPopup *pmp, BOOL fSet);
+
+ // *** IDeskBar methods ***
+ virtual HRESULT STDMETHODCALLTYPE SetClient(IUnknown *punkClient);
+ virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown **ppunkClient);
+ virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(RECT *prc);
+
+ // *** IMenuBand methods ***
+ virtual HRESULT STDMETHODCALLTYPE IsMenuMessage(MSG *pmsg);
+ virtual HRESULT STDMETHODCALLTYPE TranslateMenuMessage(MSG *pmsg, LRESULT *plRet);
+
+ // *** IShellMenu methods ***
+ virtual HRESULT STDMETHODCALLTYPE Initialize(IShellMenuCallback *psmc, UINT uId, UINT
uIdAncestor, DWORD dwFlags);
+ virtual HRESULT STDMETHODCALLTYPE GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId,
UINT *puIdAncestor, DWORD *pdwFlags);
+ virtual HRESULT STDMETHODCALLTYPE SetShellFolder(IShellFolder *psf, LPCITEMIDLIST
pidlFolder, HKEY hKey, DWORD dwFlags);
+ virtual HRESULT STDMETHODCALLTYPE GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST
*ppidl, REFIID riid, void **ppv);
+ virtual HRESULT STDMETHODCALLTYPE SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
+ virtual HRESULT STDMETHODCALLTYPE GetMenu(HMENU *phmenu, HWND *phwnd, DWORD
*pdwFlags);
+ virtual HRESULT STDMETHODCALLTYPE InvalidateItem(LPSMDATA psmd, DWORD dwFlags);
+ virtual HRESULT STDMETHODCALLTYPE GetState(LPSMDATA psmd);
+ virtual HRESULT STDMETHODCALLTYPE SetMenuToolbar(IUnknown *punk, DWORD dwFlags);
+
+ // *** IWinEventHandler methods ***
+ virtual HRESULT STDMETHODCALLTYPE OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, LRESULT *theResult);
+ virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd);
+
+ // *** IShellMenu2 methods ***
+ virtual HRESULT STDMETHODCALLTYPE GetSubMenu(THIS);
+ virtual HRESULT STDMETHODCALLTYPE SetToolbar(THIS);
+ virtual HRESULT STDMETHODCALLTYPE SetMinWidth(THIS);
+ virtual HRESULT STDMETHODCALLTYPE SetNoBorder(THIS);
+ virtual HRESULT STDMETHODCALLTYPE SetTheme(THIS);
+
+ // *** IShellMenuAcc methods ***
+ virtual HRESULT STDMETHODCALLTYPE GetTop(THIS);
+ virtual HRESULT STDMETHODCALLTYPE GetBottom(THIS);
+ virtual HRESULT STDMETHODCALLTYPE GetTracked(THIS);
+ virtual HRESULT STDMETHODCALLTYPE GetParentSite(THIS);
+ virtual HRESULT STDMETHODCALLTYPE GetState(THIS);
+ virtual HRESULT STDMETHODCALLTYPE DoDefaultAction(THIS);
+ virtual HRESULT STDMETHODCALLTYPE IsEmpty(THIS);
+
+ HRESULT _CallCBWithItemId(UINT Id, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ HRESULT _CallCBWithItemPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam, LPARAM
lParam);
+ HRESULT _TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y);
+ HRESULT _GetTopLevelWindow(HWND*topLevel);
+ HRESULT _OnHotItemChanged(CMenuToolbarBase * tb, INT id);
+ HRESULT _MenuItemHotTrack(DWORD changeType);
+ HRESULT _OnPopupSubMenu(IMenuPopup * popup);
+
+ BOOL UseBigIcons()
+ {
+ return m_useBigIcons;
+ }
+
private:
HRESULT _CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam, UINT id = 0, LPITEMIDLIST
pidl = NULL);
};
@@ -425,19 +426,19 @@
case VK_MENU:
case VK_LMENU:
case VK_RMENU:
- m_currentBand->ChildTrack(MPOS_FULLCANCEL);
+ m_currentBand->_MenuItemHotTrack(MPOS_FULLCANCEL);
break;
case VK_LEFT:
- m_currentBand->ChildTrack(MPOS_SELECTLEFT);
+ m_currentBand->_MenuItemHotTrack(MPOS_SELECTLEFT);
break;
case VK_RIGHT:
- m_currentBand->ChildTrack(MPOS_SELECTRIGHT);
+ m_currentBand->_MenuItemHotTrack(MPOS_SELECTRIGHT);
break;
case VK_UP:
- m_currentBand->ChildTrack(VK_UP);
+ m_currentBand->_MenuItemHotTrack(VK_UP);
break;
case VK_DOWN:
- m_currentBand->ChildTrack(VK_DOWN);
+ m_currentBand->_MenuItemHotTrack(VK_DOWN);
break;
}
break;
@@ -488,7 +489,7 @@
}
HWND newFocus;
- hr = newBand->GetTopLevelWindow(&newFocus);
+ hr = newBand->_GetTopLevelWindow(&newFocus);
if (FAILED(hr))
return hr;
@@ -557,6 +558,11 @@
m_hwnd(NULL),
m_dwMenuFlags(0)
{
+}
+
+HRESULT CMenuToolbarBase::IsWindowOwner(HWND hwnd)
+{
+ return (m_hwnd && m_hwnd == hwnd) ? S_OK : S_FALSE;
}
HRESULT CMenuToolbarBase::ShowWindow(BOOL fShow)
@@ -670,6 +676,7 @@
case WM_TIMER:
if (wParam == TIMERID_HOTTRACK)
{
+ m_menuBand->_OnPopupSubMenu(NULL);
PopupItem(m_hotItem);
KillTimer(hWnd, TIMERID_HOTTRACK);
}
@@ -684,8 +691,8 @@
{
KillTimer(m_hwnd, TIMERID_HOTTRACK);
m_hotItem = -1;
- m_menuBand->OnHotItemChanged(NULL, -1);
- m_menuBand->ChildTrack(MPOS_CHILDTRACKING);
+ m_menuBand->_OnHotItemChanged(NULL, -1);
+ m_menuBand->_MenuItemHotTrack(MPOS_CHILDTRACKING);
}
else if (m_hotItem != hot->idNew)
{
@@ -693,14 +700,12 @@
{
DWORD elapsed = 0;
SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &elapsed, 0);
-
-
SetTimer(m_hwnd, TIMERID_HOTTRACK, elapsed, NULL);
}
m_hotItem = hot->idNew;
- m_menuBand->OnHotItemChanged(this, m_hotItem);
- m_menuBand->ChildTrack(MPOS_CHILDTRACKING);
+ m_menuBand->_OnHotItemChanged(this, m_hotItem);
+ m_menuBand->_MenuItemHotTrack(MPOS_CHILDTRACKING);
}
return S_OK;
}
@@ -773,6 +778,8 @@
popup->Popup(&pt, &rcl, MPPF_TOP | MPPF_RIGHT);
+ m_menuBand->_OnPopupSubMenu(popup);
+
return S_OK;
}
@@ -789,7 +796,7 @@
HMENU popup = GetSubMenu(menu, index);
- m_menuBand->TrackPopup(popup, b.x, b.y);
+ m_menuBand->_TrackSubMenuUsingTrackPopupMenu(popup, b.x, b.y);
return S_OK;
}
@@ -826,12 +833,12 @@
HRESULT CMenuToolbarBase::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult)
{
- m_menuBand->OnSelect(MPOS_EXECUTE);
- return S_OK;
-}
-
-
-HRESULT CMenuToolbarBase::ChildTrack(DWORD dwSelectType)
+ theResult = 0;
+ return m_menuBand->_MenuItemHotTrack(MPOS_EXECUTE);
+}
+
+
+HRESULT CMenuToolbarBase::ChangeHotItem(DWORD dwSelectType)
{
int prev = SendMessage(m_hwnd, TB_GETHOTITEM, 0, 0);
int index = -1;
@@ -894,7 +901,7 @@
if (prev != index)
{
SendMessage(m_hwnd, TB_SETHOTITEM, index, 0);
- return m_menuBand->OnHotItemChanged(this, m_hotItem);
+ return m_menuBand->_OnHotItemChanged(this, m_hotItem);
}
return S_OK;
}
@@ -914,7 +921,7 @@
if (prev != index)
{
SendMessage(m_hwnd, TB_SETHOTITEM, -1, 0);
- m_menuBand->OnHotItemChanged(NULL, -1);
+ m_menuBand->_OnHotItemChanged(NULL, -1);
}
return S_FALSE;
}
@@ -997,7 +1004,7 @@
SMINFO * sminfo = new SMINFO();
sminfo->dwMask = SMIM_ICON | SMIM_FLAGS;
- if (SUCCEEDED(m_menuBand->CallCBWithId(info.wID, SMC_GETINFO, 0,
reinterpret_cast<LPARAM>(sminfo))))
+ if (SUCCEEDED(m_menuBand->_CallCBWithItemId(info.wID, SMC_GETINFO, 0,
reinterpret_cast<LPARAM>(sminfo))))
{
tbb.iBitmap = sminfo->iIcon;
tbb.dwData = reinterpret_cast<DWORD_PTR>(sminfo);
@@ -1021,7 +1028,7 @@
HRESULT CMenuStaticToolbar::OnContextMenu(NMMOUSE * rclick)
{
CComPtr<IContextMenu> contextMenu;
- HRESULT hr = m_menuBand->CallCBWithId(rclick->dwItemSpec, SMC_GETOBJECT,
reinterpret_cast<WPARAM>(&IID_IContextMenu),
reinterpret_cast<LPARAM>(&contextMenu));
+ HRESULT hr = m_menuBand->_CallCBWithItemId(rclick->dwItemSpec, SMC_GETOBJECT,
reinterpret_cast<WPARAM>(&IID_IContextMenu),
reinterpret_cast<LPARAM>(&contextMenu));
if (hr != S_OK)
return hr;
@@ -1030,7 +1037,7 @@
HRESULT CMenuStaticToolbar::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult)
{
- HRESULT hr = m_menuBand->CallCBWithId(wParam, SMC_EXEC, 0, 0);
+ HRESULT hr = m_menuBand->_CallCBWithItemId(wParam, SMC_EXEC, 0, 0);
if (FAILED(hr))
return hr;
@@ -1045,7 +1052,7 @@
int index = SendMessage(m_hwnd, TB_GETBUTTONINFO, uItem,
reinterpret_cast<LPARAM>(&info));
if (index < 0)
return E_FAIL;
-
+
TBBUTTON btn = { 0 };
SendMessage(m_hwnd, TB_GETBUTTON, index, reinterpret_cast<LPARAM>(&btn));
@@ -1060,7 +1067,7 @@
else
{
CComPtr<IShellMenu> shellMenu;
- HRESULT hr = m_menuBand->CallCBWithId(uItem, SMC_GETOBJECT,
reinterpret_cast<WPARAM>(&IID_IShellMenu),
reinterpret_cast<LPARAM>(&shellMenu));
+ HRESULT hr = m_menuBand->_CallCBWithItemId(uItem, SMC_GETOBJECT,
reinterpret_cast<WPARAM>(&IID_IShellMenu),
reinterpret_cast<LPARAM>(&shellMenu));
if (FAILED(hr))
return hr;
@@ -1215,7 +1222,9 @@
HRESULT CMenuSFToolbar::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult)
{
- return m_menuBand->CallCBWithPidl(GetPidlFromId(wParam, NULL), SMC_SFEXEC, 0, 0);
+ HRESULT hr = m_menuBand->_CallCBWithItemPidl(GetPidlFromId(wParam), SMC_SFEXEC, 0,
0);
+
+ return CMenuToolbarBase::OnCommand(wParam, lParam, theResult);
}
HRESULT CMenuSFToolbar::PopupItem(UINT uItem)
@@ -1227,7 +1236,7 @@
int index;
CComPtr<IShellMenuCallback> psmc;
CComPtr<IShellMenu> shellMenu;
-
+
LPITEMIDLIST pidl = GetPidlFromId(uItem, &index);
if (!pidl)
@@ -1272,7 +1281,7 @@
{
HRESULT hr;
CComPtr<IShellItem> psi;
- SHCreateShellItem(NULL, m_shellFolder, GetPidlFromId(uItem, NULL), &psi);
+ SHCreateShellItem(NULL, m_shellFolder, GetPidlFromId(uItem), &psi);
SFGAOF attrs;
hr = psi->GetAttributes(SFGAO_FOLDER, &attrs);
@@ -1289,7 +1298,8 @@
m_SFToolbar(NULL),
m_useBigIcons(FALSE),
m_hotBar(NULL),
- m_hotItem(-1)
+ m_hotItem(-1),
+ m_childMenu(NULL)
{
m_focusManager = CMenuFocusManager::AcquireManager();
}
@@ -1297,12 +1307,6 @@
CMenuBand::~CMenuBand()
{
CMenuFocusManager::ReleaseManager(m_focusManager);
-
- if (m_site)
- m_site->Release();
-
- if (m_psmc)
- m_psmc->Release();
if (m_staticToolbar)
delete m_staticToolbar;
@@ -1317,9 +1321,6 @@
UINT uIdAncestor,
DWORD dwFlags)
{
- if (m_psmc)
- m_psmc->Release();
-
m_psmc = psmc;
m_uId = uId;
m_uIdAncestor = uIdAncestor;
@@ -1327,8 +1328,6 @@
if (m_psmc)
{
- m_psmc->AddRef();
-
_CallCB(SMC_CREATE, 0, reinterpret_cast<LPARAM>(&m_UserData));
}
@@ -1408,22 +1407,19 @@
HWND hwndParent;
HRESULT hr;
- if (m_site != NULL)
- m_site->Release();
+ m_site = NULL;
if (pUnkSite == NULL)
return S_OK;
hwndParent = NULL;
hr = pUnkSite->QueryInterface(IID_PPV_ARG(IOleWindow, &m_site));
- if (SUCCEEDED(hr))
- {
- m_site->Release();
-
- hr = m_site->GetWindow(&hwndParent);
- if (FAILED(hr))
- return hr;
- }
+ if (FAILED(hr))
+ return hr;
+
+ hr = m_site->GetWindow(&hwndParent);
+ if (FAILED(hr))
+ return hr;
if (!::IsWindow(hwndParent))
return E_FAIL;
@@ -1765,7 +1761,7 @@
HRESULT STDMETHODCALLTYPE CMenuBand::QueryService(REFGUID guidService, REFIID riid, void
**ppvObject)
{
if (IsEqualIID(guidService, SID_SMenuBandChild) ||
- IsEqualIID(guidService, SID_SMenuBandBottom) ||
+ IsEqualIID(guidService, SID_SMenuBandBottom) ||
IsEqualIID(guidService, SID_SMenuBandBottomSelected))
return this->QueryInterface(riid, ppvObject);
WARN("Unknown service requested %s\n",
wine_dbgstr_guid(&guidService));
@@ -1780,7 +1776,19 @@
HRESULT STDMETHODCALLTYPE CMenuBand::OnSelect(DWORD dwSelectType)
{
- return S_OK;
+ if (dwSelectType != MPOS_CANCELLEVEL)
+ {
+ if (dwSelectType == MPOS_SELECTLEFT)
+ {
+ dwSelectType = MPOS_CANCELLEVEL;
+ }
+ CComPtr<IMenuPopup> pmp;
+ HRESULT hr = IUnknown_QueryService(m_site, SID_SMenuPopup,
IID_PPV_ARG(IMenuPopup, &pmp));
+ if (FAILED(hr))
+ return hr;
+ return pmp->OnSelect(dwSelectType);
+ }
+ return S_FALSE;
}
HRESULT STDMETHODCALLTYPE CMenuBand::SetSubMenu(IMenuPopup *pmp, BOOL fSet)
@@ -1876,12 +1884,12 @@
{
case WM_COMMAND:
- if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd))
+ if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd) == S_OK)
{
return m_staticToolbar->OnCommand(wParam, lParam, theResult);
}
- if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd))
+ if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd) == S_OK)
{
return m_SFToolbar->OnCommand(wParam, lParam, theResult);
}
@@ -1898,12 +1906,12 @@
case TBN_HOTITEMCHANGE:
hot = reinterpret_cast<LPNMTBHOTITEM>(hdr);
- if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd))
+ if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd) ==
S_OK)
{
return m_staticToolbar->OnHotItemChange(hot);
}
- if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd))
+ if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd) == S_OK)
{
return m_SFToolbar->OnHotItemChange(hot);
}
@@ -1913,12 +1921,12 @@
case NM_RCLICK:
rclick = reinterpret_cast<LPNMMOUSE>(hdr);
- if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd))
+ if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd) ==
S_OK)
{
return m_staticToolbar->OnContextMenu(rclick);
}
- if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd))
+ if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd) == S_OK)
{
return m_SFToolbar->OnContextMenu(rclick);
}
@@ -1971,10 +1979,10 @@
HRESULT STDMETHODCALLTYPE CMenuBand::IsWindowOwner(HWND hWnd)
{
- if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd))
+ if (m_staticToolbar && m_staticToolbar->IsWindowOwner(hWnd) == S_OK)
return S_OK;
- if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd))
+ if (m_SFToolbar && m_SFToolbar->IsWindowOwner(hWnd) == S_OK)
return S_OK;
return S_FALSE;
@@ -2052,12 +2060,12 @@
return S_OK;
}
-HRESULT CMenuBand::CallCBWithId(UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam)
+HRESULT CMenuBand::_CallCBWithItemId(UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return _CallCB(uMsg, wParam, lParam, id);
}
-HRESULT CMenuBand::CallCBWithPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam, LPARAM
lParam)
+HRESULT CMenuBand::_CallCBWithItemPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
return _CallCB(uMsg, wParam, lParam, 0, pidl);
}
@@ -2091,80 +2099,81 @@
return hr;
}
-HRESULT CMenuBand::TrackPopup(HMENU popup, INT x, INT y)
+HRESULT CMenuBand::_TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y)
{
::TrackPopupMenu(popup, 0, x, y, 0, m_menuOwner, NULL);
return S_OK;
}
-HRESULT CMenuBand::GetTopLevelWindow(HWND*topLevel)
+HRESULT CMenuBand::_GetTopLevelWindow(HWND*topLevel)
{
*topLevel = m_topLevelWindow;
return S_OK;
}
-HRESULT CMenuBand::OnHotItemChanged(CMenuToolbarBase * tb, INT id)
+HRESULT CMenuBand::_OnHotItemChanged(CMenuToolbarBase * tb, INT id)
{
if (m_hotBar && m_hotBar != tb)
- m_hotBar->ChildTrack(-1);
+ m_hotBar->ChangeHotItem(-1);
m_hotBar = tb;
m_hotItem = id;
return S_OK;
}
-HRESULT CMenuBand::ChildTrack(DWORD dwSelectType)
+HRESULT CMenuBand::_MenuItemHotTrack(DWORD changeType)
{
HRESULT hr;
- if (dwSelectType == VK_DOWN)
+
+ if (changeType == VK_DOWN)
{
if (m_SFToolbar && (m_hotBar == m_SFToolbar || m_hotBar == NULL))
{
- hr = m_SFToolbar->ChildTrack(dwSelectType);
+ hr = m_SFToolbar->ChangeHotItem(VK_DOWN);
if (hr == S_FALSE)
{
if (m_staticToolbar)
- return m_staticToolbar->ChildTrack(VK_HOME);
+ return m_staticToolbar->ChangeHotItem(VK_HOME);
else
- return m_SFToolbar->ChildTrack(VK_HOME);
+ return m_SFToolbar->ChangeHotItem(VK_HOME);
}
return hr;
}
else if (m_staticToolbar && m_hotBar == m_staticToolbar)
{
- hr = m_staticToolbar->ChildTrack(dwSelectType);
+ hr = m_staticToolbar->ChangeHotItem(VK_DOWN);
if (hr == S_FALSE)
{
if (m_SFToolbar)
- return m_SFToolbar->ChildTrack(VK_HOME);
+ return m_SFToolbar->ChangeHotItem(VK_HOME);
else
- return m_staticToolbar->ChildTrack(VK_HOME);
+ return m_staticToolbar->ChangeHotItem(VK_HOME);
}
return hr;
}
}
- else if (dwSelectType == VK_UP)
+ else if (changeType == VK_UP)
{
if (m_staticToolbar && (m_hotBar == m_staticToolbar || m_hotBar ==
NULL))
{
- hr = m_staticToolbar->ChildTrack(dwSelectType);
+ hr = m_staticToolbar->ChangeHotItem(VK_DOWN);
if (hr == S_FALSE)
{
if (m_SFToolbar)
- return m_SFToolbar->ChildTrack(VK_END);
+ return m_SFToolbar->ChangeHotItem(VK_END);
else
- return m_staticToolbar->ChildTrack(VK_END);
+ return m_staticToolbar->ChangeHotItem(VK_END);
}
return hr;
}
else if (m_SFToolbar && m_hotBar == m_SFToolbar)
{
- hr = m_SFToolbar->ChildTrack(dwSelectType);
+ hr = m_SFToolbar->ChangeHotItem(VK_UP);
if (hr == S_FALSE)
{
if (m_staticToolbar)
- return m_staticToolbar->ChildTrack(VK_END);
+ return m_staticToolbar->ChangeHotItem(VK_END);
else
- return m_SFToolbar->ChildTrack(VK_END);
+ return m_SFToolbar->ChangeHotItem(VK_END);
}
return hr;
}
@@ -2175,7 +2184,24 @@
hr = IUnknown_QueryService(m_site, SID_SMenuPopup, IID_PPV_ARG(IMenuPopup,
&pmp));
if (FAILED(hr))
return hr;
- pmp->OnSelect(dwSelectType);
- }
- return S_OK;
-}
+ pmp->OnSelect(changeType);
+ }
+ return S_OK;
+}
+
+
+HRESULT CMenuBand::_OnPopupSubMenu(IMenuPopup * popup)
+{
+ if (m_childMenu)
+ {
+ HRESULT hr = m_childMenu->OnSelect(MPOS_CANCELLEVEL);
+ if (FAILED(hr))
+ return hr;
+ }
+ m_childMenu = popup;
+ if (m_childMenu)
+ {
+ return m_childMenu->SetSubMenu(this, TRUE);
+ }
+ return S_OK;
+}
Modified: branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp [iso-8859-1] Thu Feb 20
16:18:49 2014
@@ -43,10 +43,6 @@
public IBanneredBar,
public IInitializeObject
{
-public:
- CMenuDeskBar();
- ~CMenuDeskBar();
-
private:
CComPtr<IUnknown> m_Site;
CComPtr<IUnknown> m_Client;
@@ -58,47 +54,8 @@
HBITMAP m_Banner;
public:
- // *** IMenuPopup methods ***
- virtual HRESULT STDMETHODCALLTYPE Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS
dwFlags);
- virtual HRESULT STDMETHODCALLTYPE OnSelect(DWORD dwSelectType);
- virtual HRESULT STDMETHODCALLTYPE SetSubMenu(IMenuPopup *pmp, BOOL fSet);
-
- // *** IOleWindow methods ***
- virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *phwnd);
- virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
-
- // *** IObjectWithSite methods ***
- virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
- virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, PVOID *ppvSite);
-
- // *** IBanneredBar methods ***
- virtual HRESULT STDMETHODCALLTYPE SetIconSize(DWORD iIcon);
- virtual HRESULT STDMETHODCALLTYPE GetIconSize(DWORD* piIcon);
- virtual HRESULT STDMETHODCALLTYPE SetBitmap(HBITMAP hBitmap);
- virtual HRESULT STDMETHODCALLTYPE GetBitmap(HBITMAP* phBitmap);
-
- // *** IInitializeObject methods ***
- virtual HRESULT STDMETHODCALLTYPE Initialize(THIS);
-
- // *** IOleCommandTarget methods ***
- virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds,
OLECMD prgCmds [], OLECMDTEXT *pCmdText);
- virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
-
- // *** IServiceProvider methods ***
- virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void
**ppvObject);
-
- // *** IInputObjectSite methods ***
- virtual HRESULT STDMETHODCALLTYPE OnFocusChangeIS(LPUNKNOWN lpUnknown, BOOL bFocus);
-
- // *** IInputObject methods ***
- virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL bActivating, LPMSG lpMsg);
- virtual HRESULT STDMETHODCALLTYPE HasFocusIO(THIS);
- virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg);
-
- // *** IDeskBar methods ***
- virtual HRESULT STDMETHODCALLTYPE SetClient(IUnknown *punkClient);
- virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown **ppunkClient);
- virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(LPRECT prc);
+ CMenuDeskBar();
+ ~CMenuDeskBar();
DECLARE_NOT_AGGREGATABLE(CMenuDeskBar)
DECLARE_PROTECT_FINAL_CONSTRUCT()
@@ -106,10 +63,10 @@
DECLARE_WND_CLASS_EX(_T("BaseBar"), CS_SAVEBITS | CS_DROPSHADOW,
COLOR_3DFACE)
BEGIN_MSG_MAP(CMenuDeskBar)
- MESSAGE_HANDLER(WM_SIZE, OnSize)
- MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
- MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, OnWindowPosChanged)
- MESSAGE_HANDLER(WM_PAINT, OnPaint)
+ MESSAGE_HANDLER(WM_SIZE, _OnSize)
+ MESSAGE_HANDLER(WM_NOTIFY, _OnNotify)
+ MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, _OnWindowPosChanged)
+ MESSAGE_HANDLER(WM_PAINT, _OnPaint)
END_MSG_MAP()
BEGIN_COM_MAP(CMenuDeskBar)
@@ -125,13 +82,54 @@
COM_INTERFACE_ENTRY_IID(IID_IInitializeObject, IInitializeObject)
END_COM_MAP()
+ // *** IMenuPopup methods ***
+ virtual HRESULT STDMETHODCALLTYPE Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS
dwFlags);
+ virtual HRESULT STDMETHODCALLTYPE OnSelect(DWORD dwSelectType);
+ virtual HRESULT STDMETHODCALLTYPE SetSubMenu(IMenuPopup *pmp, BOOL fSet);
+
+ // *** IOleWindow methods ***
+ virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *phwnd);
+ virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode);
+
+ // *** IObjectWithSite methods ***
+ virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
+ virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, PVOID *ppvSite);
+
+ // *** IBanneredBar methods ***
+ virtual HRESULT STDMETHODCALLTYPE SetIconSize(DWORD iIcon);
+ virtual HRESULT STDMETHODCALLTYPE GetIconSize(DWORD* piIcon);
+ virtual HRESULT STDMETHODCALLTYPE SetBitmap(HBITMAP hBitmap);
+ virtual HRESULT STDMETHODCALLTYPE GetBitmap(HBITMAP* phBitmap);
+
+ // *** IInitializeObject methods ***
+ virtual HRESULT STDMETHODCALLTYPE Initialize(THIS);
+
+ // *** IOleCommandTarget methods ***
+ virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds,
OLECMD prgCmds [], OLECMDTEXT *pCmdText);
+ virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD
nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
+
+ // *** IServiceProvider methods ***
+ virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void
**ppvObject);
+
+ // *** IInputObjectSite methods ***
+ virtual HRESULT STDMETHODCALLTYPE OnFocusChangeIS(LPUNKNOWN lpUnknown, BOOL bFocus);
+
+ // *** IInputObject methods ***
+ virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL bActivating, LPMSG lpMsg);
+ virtual HRESULT STDMETHODCALLTYPE HasFocusIO(THIS);
+ virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg);
+
+ // *** IDeskBar methods ***
+ virtual HRESULT STDMETHODCALLTYPE SetClient(IUnknown *punkClient);
+ virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown **ppunkClient);
+ virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(LPRECT prc);
+
private:
-
// message handlers
- LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
- LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
- LRESULT OnWindowPosChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled);
- LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
+ LRESULT _OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
+ LRESULT _OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
+ LRESULT _OnWindowPosChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled);
+ LRESULT _OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
};
extern "C"
@@ -331,7 +329,7 @@
return m_Site->QueryInterface(riid, ppvSite);
}
-LRESULT CMenuDeskBar::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
+LRESULT CMenuDeskBar::_OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
{
if (m_Client)
{
@@ -352,7 +350,7 @@
return 0;
}
-LRESULT CMenuDeskBar::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
+LRESULT CMenuDeskBar::_OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
{
CComPtr<IWinEventHandler> winEventHandler;
LRESULT result;
@@ -368,12 +366,12 @@
return result;
}
-LRESULT CMenuDeskBar::OnWindowPosChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
+LRESULT CMenuDeskBar::_OnWindowPosChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
{
return 0;
}
-LRESULT CMenuDeskBar::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
+LRESULT CMenuDeskBar::_OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
{
bHandled = FALSE;
@@ -432,6 +430,7 @@
if (FAILED(hr))
return hr;
+ // Windows calls this, but it appears to be unimplemented?
hr = dbc->SetModeDBC(1);
// Allow it to fail with E_NOTIMPL.
@@ -481,7 +480,7 @@
// HACK: The bar needs to be notified of the size AFTER it is shown.
// Quick & dirty way of getting it done.
BOOL bHandled;
- OnSize(WM_SIZE, 0, 0, bHandled);
+ _OnSize(WM_SIZE, 0, 0, bHandled);
UIActivateIO(TRUE, NULL);
@@ -502,7 +501,7 @@
return hr;
BOOL bHandled;
- OnSize(WM_SIZE, 0, 0, bHandled);
+ _OnSize(WM_SIZE, 0, 0, bHandled);
return hr;
}
@@ -519,7 +518,7 @@
m_Banner = hBitmap;
BOOL bHandled;
- OnSize(WM_SIZE, 0, 0, bHandled);
+ _OnSize(WM_SIZE, 0, 0, bHandled);
return S_OK;
}
@@ -534,6 +533,7 @@
HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnSelect(
DWORD dwSelectType)
{
+ CComPtr<IMenuPopup> pmp;
CComPtr<IDeskBarClient> dbc;
HRESULT hr;
@@ -542,6 +542,13 @@
case MPOS_EXECUTE:
case MPOS_FULLCANCEL:
case MPOS_CANCELLEVEL:
+ hr = IUnknown_QueryService(m_Client, SID_SMenuBandChild, IID_PPV_ARG(IMenuPopup,
&pmp));
+ if (FAILED(hr))
+ return hr;
+
+ hr = pmp->OnSelect(MPOS_CANCELLEVEL);
+ if (FAILED(hr))
+ return hr;
hr = m_Client->QueryInterface(IID_PPV_ARG(IDeskBarClient, &dbc));
if (FAILED(hr))
@@ -558,7 +565,6 @@
if (dwSelectType == MPOS_CANCELLEVEL)
break;
- dwSelectType = MPOS_CANCELLEVEL;
case MPOS_SELECTLEFT:
case MPOS_SELECTRIGHT:
/*CComPtr<IMenuPopup> pmp;
Modified: branches/shell-experiments/base/shell/rshell/CMenuSite.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuSite.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuSite.cpp [iso-8859-1] Thu Feb 20
16:18:49 2014
@@ -24,23 +24,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(menusite);
-#if 0
-bool _assert(bool cond, LPCSTR expr, LPCSTR file, DWORD line, LPCSTR func)
-{
-#if DBG
- if (!cond)
- {
- wine_dbg_printf("%s(%d): Assertion failed '%s', at %s", file,
line, expr, func);
- DebugBreak();
- }
-#endif
- return cond;
-}
-#define DBGASSERT(x) _assert(!!(x), #x, __FILE__, __LINE__, __FUNCSIG__)
-#else
-#define DBGASSERT(x) (!!(x))
-#endif
-
class CMenuSite :
public CComObjectRootEx<CComMultiThreadModelNoCS>,
public CWindowImpl<CMenuSite, CWindow, CControlWinTraits>,
@@ -52,6 +35,7 @@
public IWinEventHandler,
public IServiceProvider
{
+private:
CComPtr<IUnknown> m_DeskBarSite;
CComPtr<IUnknown> m_BandObject;
CComPtr<IDeskBand> m_DeskBand;
@@ -200,12 +184,19 @@
HRESULT STDMETHODCALLTYPE CMenuSite::AddBand(IUnknown * punk)
{
+ HRESULT hr;
+
+#define TO_HRESULT(x) ((HRESULT)(S_OK+(x)))
+
if (SHIsSameObject(punk, m_BandObject))
- return S_OK + 0;
-
- IUnknown_SetSite(m_BandObject, NULL);
-
- BOOL result = m_hWndBand != NULL;
+ return TO_HRESULT(0);
+
+ if (m_BandObject)
+ {
+ hr = IUnknown_SetSite(m_BandObject, NULL);
+ if (FAILED(hr))
+ return hr;
+ }
m_BandObject = NULL;
m_DeskBand = NULL;
@@ -213,19 +204,29 @@
m_hWndBand = NULL;
if (!punk)
- return result ? S_OK + 0 : E_FAIL;
-
- DBGASSERT(SUCCEEDED(punk->QueryInterface(IID_PPV_ARG(IDeskBand,
&m_DeskBand))));
- DBGASSERT(SUCCEEDED(punk->QueryInterface(IID_PPV_ARG(IWinEventHandler,
&m_WinEventHandler))));
-
- IUnknown_SetSite(punk, this->ToIUnknown());
- IUnknown_GetWindow(punk, &m_hWndBand);
+ return TO_HRESULT(0);
+
+ hr = punk->QueryInterface(IID_PPV_ARG(IDeskBand, &m_DeskBand));
+ if (FAILED(hr))
+ return hr;
+
+ hr = punk->QueryInterface(IID_PPV_ARG(IWinEventHandler, &m_WinEventHandler));
+ if (FAILED(hr))
+ return hr;
+
+ hr = IUnknown_SetSite(punk, this->ToIUnknown());
+ if (FAILED(hr))
+ return hr;
+
+ hr = IUnknown_GetWindow(punk, &m_hWndBand);
+ if (FAILED(hr))
+ return hr;
m_BandObject = punk;
punk->AddRef();
- return S_OK + 0;
+ return TO_HRESULT(0);
}
HRESULT STDMETHODCALLTYPE CMenuSite::EnumBands(UINT uBand, DWORD* pdwBandID)
@@ -245,7 +246,7 @@
HRESULT STDMETHODCALLTYPE CMenuSite::GetBandObject(DWORD dwBandID, REFIID riid, VOID
**ppv)
{
- if (!DBGASSERT(dwBandID == 0) || m_BandObject == NULL)
+ if (dwBandID != 0 || m_BandObject == NULL)
{
*ppv = NULL;
return E_NOINTERFACE;
@@ -277,7 +278,8 @@
HRESULT STDMETHODCALLTYPE CMenuSite::GetWindow(HWND *phwnd)
{
- DBGASSERT(IsWindow());
+ if (!IsWindow())
+ return E_FAIL;
*phwnd = m_hWnd;
@@ -305,8 +307,8 @@
HRESULT STDMETHODCALLTYPE CMenuSite::QueryBand(DWORD dwBandID, IDeskBand **ppstb, DWORD
*pdwState, LPWSTR pszName, int cchName)
{
- DBGASSERT(dwBandID == 0);
- DBGASSERT(!IsBadWritePtr(ppstb, sizeof(*ppstb)));
+ if (dwBandID != 0)
+ return E_FAIL;
if (!m_BandObject)
{
@@ -338,15 +340,17 @@
return IUnknown_QueryService(m_BandObject, guidService, riid, ppvObject);
}
- DBGASSERT(m_DeskBarSite);
+ if (!m_DeskBarSite)
+ return E_FAIL;
return IUnknown_QueryService(m_DeskBarSite, guidService, riid, ppvObject);
}
HRESULT STDMETHODCALLTYPE CMenuSite::QueryStatus(const GUID * pguidCmdGroup, ULONG cCmds,
OLECMD prgCmds [], OLECMDTEXT *pCmdText)
{
- if (!DBGASSERT(m_DeskBarSite))
- return E_FAIL;
+ if (!m_DeskBarSite)
+ return E_FAIL;
+
return IUnknown_QueryStatus(m_DeskBarSite, *pguidCmdGroup, cCmds, prgCmds,
pCmdText);
}
@@ -382,7 +386,7 @@
m_DeskBand->CloseDW(0);
}
- IUnknown_SetSite(m_BandObject, NULL);
+ hr = IUnknown_SetSite(m_BandObject, NULL);
m_BandObject = NULL;
m_DeskBand = NULL;
Modified: branches/shell-experiments/base/shell/rshell/precomp.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/precomp.h [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/precomp.h [iso-8859-1] Thu Feb 20
16:18:49 2014
@@ -3,9 +3,9 @@
#define USE_SYSTEM_MENUSITE 0
#define USE_SYSTEM_MENUBAND 0
-#define WRAP_MENUDESKBAR 0
-#define WRAP_MENUSITE 0
-#define WRAP_MENUBAND 0
+#define WRAP_MENUDESKBAR 1
+#define WRAP_MENUSITE 1
+#define WRAP_MENUBAND 1
#include <stdio.h>
#include <tchar.h>