Author: dquintana
Date: Mon Feb 17 11:20:35 2014
New Revision: 62226
URL:
http://svn.reactos.org/svn/reactos?rev=62226&view=rev
Log:
[RSHELL]
* CMenuBand: Handle WM_COMMAND and run SMC_EXEC for static menu items (Run, Shutdown).
CORE-7881
Modified:
branches/shell-experiments/base/shell/rshell/CMenuBand.cpp
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] Mon Feb 17
11:20:35 2014
@@ -40,6 +40,7 @@
HRESULT Close();
virtual HRESULT FillToolbar() = 0;
+ virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult) = 0;
protected:
@@ -60,7 +61,7 @@
HRESULT GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
virtual HRESULT FillToolbar();
-
+ virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
private:
HMENU m_hmenu;
};
@@ -75,6 +76,8 @@
HRESULT GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void
**ppv);
virtual HRESULT FillToolbar();
+ virtual HRESULT OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult);
+
private:
@@ -825,7 +828,7 @@
LONG tbStyles = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT | TBSTYLE_REGISTERDROP | TBSTYLE_LIST |
TBSTYLE_FLAT |
CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_TOP;
- LONG tbExStyles = TBSTYLE_EX_DOUBLEBUFFER | TBSTYLE_EX_DRAWDDARROWS;
+ LONG tbExStyles = TBSTYLE_EX_DOUBLEBUFFER;
if (dwFlags & SMINIT_VERTICAL)
{
@@ -960,7 +963,8 @@
{
if (!AllocAndGetMenuString(m_hmenu, i, &MenuString))
return E_OUTOFMEMORY;
- tbb.fsStyle |= BTNS_DROPDOWN;
+ if (::GetSubMenu(m_hmenu, i) != NULL)
+ tbb.fsStyle |= BTNS_DROPDOWN;
tbb.iString = (INT_PTR) MenuString;
tbb.idCommand = info.wID;
@@ -1076,6 +1080,16 @@
return hr;
}
+HRESULT CMenuStaticToolbar::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult)
+{
+ return m_menuBand->CallCBWithId(wParam, SMC_EXEC, 0, 0);
+}
+HRESULT CMenuSFToolbar::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult)
+{
+// return m_menuBand->CallCBWithPidl(GetPidlFromId(wParam), SMC_SFEXEC, 0, 0);
+ return S_OK;
+}
+
CMenuBand::CMenuBand() :
m_site(NULL),
m_psmc(NULL),
@@ -1614,9 +1628,37 @@
HRESULT STDMETHODCALLTYPE CMenuBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, LRESULT *theResult)
{
+ HWND hwndStatic = NULL;
+ HWND hwndShlFld = NULL;
+ HRESULT hr;
+
*theResult = 0;
- if (uMsg == WM_NOTIFY)
- {
+ switch (uMsg)
+ {
+ case WM_COMMAND:
+
+ if (m_staticToolbar != NULL)
+ hr = m_staticToolbar->GetWindow(&hwndStatic);
+ if (FAILED(hr))
+ return hr;
+
+ if (hWnd == hwndStatic)
+ {
+ return m_staticToolbar->OnCommand(wParam, lParam, theResult);
+ }
+
+ if (m_SFToolbar != NULL)
+ hr = m_SFToolbar->GetWindow(&hwndShlFld);
+ if (FAILED(hr))
+ return hr;
+
+ if (hWnd == hwndShlFld)
+ {
+ return m_SFToolbar->OnCommand(wParam, lParam, theResult);
+ }
+
+ return S_OK;
+ case WM_NOTIFY:
NMHDR * hdr = (LPNMHDR) lParam;
NMTBCUSTOMDRAW * cdraw;
switch (hdr->code)
@@ -1661,8 +1703,8 @@
return S_OK;
}
return S_OK;
-
- }
+ }
+
return S_FALSE;
}