mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 20:50:29 +00:00
[RSHELL]
* Improve mouse navigation of the menubar. * Fix the menus. * Fix the case for system includes (hopefully fixes). CORE-7586 svn path=/branches/shell-experiments/; revision=62537
This commit is contained in:
parent
ad40525f61
commit
0216102e0c
6 changed files with 192 additions and 139 deletions
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
#include "precomp.h"
|
||||
#include <windowsx.h>
|
||||
#include <CommonControls.h>
|
||||
#include <commoncontrols.h>
|
||||
#include <shlwapi_undoc.h>
|
||||
|
||||
#include "CMenuBand.h"
|
||||
|
@ -333,13 +333,18 @@ HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
|
|||
HRESULT hr = S_OK;
|
||||
|
||||
if (m_staticToolbar != NULL)
|
||||
{
|
||||
hr = m_staticToolbar->ShowWindow(fShow);
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (m_SFToolbar != NULL)
|
||||
{
|
||||
hr = m_SFToolbar->ShowWindow(fShow);
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (fShow)
|
||||
{
|
||||
|
@ -348,12 +353,10 @@ HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
|
|||
return hr;
|
||||
}
|
||||
|
||||
{
|
||||
if (fShow)
|
||||
hr = m_focusManager->PushMenu(this);
|
||||
else
|
||||
hr = m_focusManager->PopMenu(this);
|
||||
}
|
||||
if (fShow)
|
||||
hr = m_focusManager->PushMenu(this);
|
||||
else
|
||||
hr = m_focusManager->PopMenu(this);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -370,17 +373,6 @@ HRESULT STDMETHODCALLTYPE CMenuBand::CloseDW(DWORD dwReserved)
|
|||
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::ContextSensitiveHelp(BOOL fEnterMode)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
|
||||
{
|
||||
|
@ -492,6 +484,12 @@ HRESULT STDMETHODCALLTYPE CMenuBand::SetSubMenu(IMenuPopup *pmp, BOOL fSet)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMenuBand::_SetChildBand(CMenuBand * child)
|
||||
{
|
||||
m_childBand = child;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::SetClient(IUnknown *punkClient)
|
||||
{
|
||||
if (m_subMenuChild)
|
||||
|
@ -504,13 +502,13 @@ HRESULT STDMETHODCALLTYPE CMenuBand::SetClient(IUnknown *punkClient)
|
|||
}
|
||||
HRESULT hr = punkClient->QueryInterface(IID_PPV_ARG(IMenuPopup, &m_subMenuChild));
|
||||
m_trackingPopup = m_subMenuChild != NULL;
|
||||
DbgPrint("Tracking: %d\n", m_trackingPopup);
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetClient(IUnknown **ppunkClient)
|
||||
{
|
||||
// HACK, so I can test for a submenu in the DeskBar
|
||||
//UNIMPLEMENTED;
|
||||
if (ppunkClient)
|
||||
{
|
||||
if (m_subMenuChild)
|
||||
|
@ -523,15 +521,11 @@ HRESULT STDMETHODCALLTYPE CMenuBand::GetClient(IUnknown **ppunkClient)
|
|||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::IsMenuMessage(MSG *pmsg)
|
||||
{
|
||||
//UNIMPLEMENTED;
|
||||
//return S_OK;
|
||||
return S_FALSE;
|
||||
//return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::TranslateMenuMessage(MSG *pmsg, LRESULT *plRet)
|
||||
{
|
||||
//UNIMPLEMENTED;
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
|
@ -571,24 +565,6 @@ HRESULT STDMETHODCALLTYPE CMenuBand::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIS
|
|||
return E_FAIL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetState(LPSMDATA psmd)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::SetMenuToolbar(IUnknown *punk, DWORD dwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
|
||||
{
|
||||
*theResult = 0;
|
||||
|
@ -663,6 +639,8 @@ HRESULT CMenuBand::_TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y, R
|
|||
UINT flags = TPM_VERPOSANIMATION | TPM_VERTICAL | TPM_LEFTALIGN;
|
||||
|
||||
m_trackingPopup = TRUE;
|
||||
DbgPrint("Tracking: %d\n", m_trackingPopup);
|
||||
|
||||
m_focusManager->PushTrackedPopup(this, popup);
|
||||
if (m_menuOwner)
|
||||
{
|
||||
|
@ -672,9 +650,11 @@ HRESULT CMenuBand::_TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y, R
|
|||
{
|
||||
::TrackPopupMenuEx(popup, flags, x, y, m_topLevelWindow, ¶ms);
|
||||
}
|
||||
m_trackingPopup = FALSE;
|
||||
m_focusManager->PopTrackedPopup(this, popup);
|
||||
|
||||
m_trackingPopup = FALSE;
|
||||
DbgPrint("Tracking: %d\n", m_trackingPopup);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -812,11 +792,8 @@ HRESULT CMenuBand::_MenuItemHotTrack(DWORD changeType)
|
|||
{
|
||||
if (m_hotBar && m_hotItem >= 0)
|
||||
{
|
||||
if (m_hotBar->HasSubMenu(m_hotItem)==S_OK)
|
||||
{
|
||||
m_hotBar->PopupItem(m_hotItem);
|
||||
if (m_hotBar->PopupItem(m_hotItem) == S_OK)
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
if (!m_subMenuParent)
|
||||
return S_OK;
|
||||
|
@ -839,9 +816,14 @@ HRESULT CMenuBand::_OnPopupSubMenu(IMenuPopup * popup, POINTL * pAt, RECTL * pEx
|
|||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (m_staticToolbar) m_staticToolbar->OnPopupItemChanged(toolbar, item);
|
||||
if (m_SFToolbar) m_SFToolbar->OnPopupItemChanged(toolbar, item);
|
||||
|
||||
m_subMenuChild = popup;
|
||||
m_trackingPopup = popup != NULL;
|
||||
DbgPrint("Tracking: %d\n", m_trackingPopup);
|
||||
|
||||
if (popup)
|
||||
{
|
||||
if (m_subMenuParent)
|
||||
|
@ -851,6 +833,7 @@ HRESULT CMenuBand::_OnPopupSubMenu(IMenuPopup * popup, POINTL * pAt, RECTL * pEx
|
|||
|
||||
popup->Popup(pAt, pExclude, MPPF_RIGHT);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -863,6 +846,36 @@ HRESULT CMenuBand::_DisableMouseTrack(BOOL bDisable)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetState(LPSMDATA psmd)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::SetMenuToolbar(IUnknown *punk, DWORD dwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::ContextSensitiveHelp(BOOL fEnterMode)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetSubMenu(THIS)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
|
|
|
@ -47,6 +47,7 @@ private:
|
|||
CComPtr<IShellMenuCallback> m_psmc;
|
||||
CComPtr<IMenuPopup> m_subMenuChild;
|
||||
CComPtr<IMenuPopup> m_subMenuParent;
|
||||
CComPtr<CMenuBand> m_childBand;
|
||||
|
||||
UINT m_uId;
|
||||
UINT m_uIdAncestor;
|
||||
|
@ -178,6 +179,7 @@ public:
|
|||
HRESULT _MenuItemHotTrack(DWORD changeType);
|
||||
HRESULT _OnPopupSubMenu(IMenuPopup * popup, POINTL * pAt, RECTL * pExclude, CMenuToolbarBase * toolbar, INT item);
|
||||
HRESULT _DisableMouseTrack(BOOL bDisable);
|
||||
HRESULT _SetChildBand(CMenuBand * child);
|
||||
|
||||
BOOL UseBigIcons()
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
#include "precomp.h"
|
||||
#include <windowsx.h>
|
||||
#include <CommonControls.h>
|
||||
#include <commoncontrols.h>
|
||||
#include <shlwapi_undoc.h>
|
||||
|
||||
#include "CMenuFocusManager.h"
|
||||
|
@ -194,13 +194,56 @@ HRESULT CMenuFocusManager::IsTrackedWindow(HWND hWnd)
|
|||
return S_FALSE;
|
||||
}
|
||||
|
||||
LRESULT CMenuFocusManager::MsgFilterHook(INT nCode, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CMenuFocusManager::ProcessMouseMove(MSG* msg)
|
||||
{
|
||||
HWND parent;
|
||||
HWND child;
|
||||
POINT pt;
|
||||
int iHitTestResult;
|
||||
|
||||
pt = msg->pt;
|
||||
|
||||
parent = WindowFromPoint(pt);
|
||||
|
||||
ScreenToClient(parent, &pt);
|
||||
|
||||
child = ChildWindowFromPoint(parent, pt);
|
||||
|
||||
if (child != m_parentToolbar)
|
||||
return TRUE;
|
||||
|
||||
ScreenToClient(m_parentToolbar, &msg->pt);
|
||||
|
||||
/* Don't do anything if the mouse has not been moved */
|
||||
if (msg->pt.x == m_ptPrev.x && msg->pt.y == m_ptPrev.y)
|
||||
return TRUE;
|
||||
|
||||
m_ptPrev = msg->pt;
|
||||
|
||||
iHitTestResult = SendMessageW(m_parentToolbar, TB_HITTEST, 0, (LPARAM) &msg->pt);
|
||||
|
||||
/* Make sure that iHitTestResult is one of the menu items and that it is not the current menu item */
|
||||
if (iHitTestResult >= 0)
|
||||
{
|
||||
HWND hwndToolbar = m_parentToolbar;
|
||||
if (SendMessage(hwndToolbar, WM_USER_ISTRACKEDITEM, iHitTestResult, 0))
|
||||
{
|
||||
DbgPrint("Hot item tracking detected a change...\n");
|
||||
if (m_currentMenu)
|
||||
SendMessage(m_currentFocus, WM_CANCELMODE, 0, 0);
|
||||
else
|
||||
m_currentBand->_MenuItemHotTrack(MPOS_SELECTLEFT);
|
||||
DbgPrint("Active popup cancelled, notifying of change...\n");
|
||||
PostMessage(hwndToolbar, WM_USER_CHANGETRACKEDITEM, iHitTestResult, iHitTestResult);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LRESULT CMenuFocusManager::MsgFilterHook(INT nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (nCode < 0)
|
||||
return CallNextHookEx(m_hMsgFilterHook, nCode, wParam, lParam);
|
||||
|
||||
|
@ -214,38 +257,7 @@ LRESULT CMenuFocusManager::MsgFilterHook(INT nCode, WPARAM wParam, LPARAM lParam
|
|||
switch (msg->message)
|
||||
{
|
||||
case WM_MOUSEMOVE:
|
||||
|
||||
pt = msg->pt;
|
||||
|
||||
parent = WindowFromPoint(pt);
|
||||
|
||||
ScreenToClient(parent, &pt);
|
||||
|
||||
child = ChildWindowFromPoint(parent, pt);
|
||||
|
||||
if (child != m_parentToolbar)
|
||||
break;
|
||||
|
||||
ScreenToClient(m_parentToolbar, &msg->pt);
|
||||
|
||||
/* Don't do anything if the mouse has not been moved */
|
||||
if (msg->pt.x == m_ptPrev.x && msg->pt.y == m_ptPrev.y)
|
||||
return TRUE;
|
||||
|
||||
m_ptPrev = msg->pt;
|
||||
|
||||
iHitTestResult = SendMessageW(m_parentToolbar, TB_HITTEST, 0, (LPARAM) &msg->pt);
|
||||
|
||||
/* Make sure that iHitTestResult is one of the menu items and that it is not the current menu item */
|
||||
if (iHitTestResult >= 0)
|
||||
{
|
||||
if (SendMessage(m_parentToolbar, WM_USER_ISTRACKEDITEM, iHitTestResult, 0))
|
||||
{
|
||||
SendMessage(m_currentFocus, WM_CANCELMODE, 0, 0);
|
||||
PostMessage(m_parentToolbar, WM_USER_CHANGETRACKEDITEM, iHitTestResult, iHitTestResult);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
callNext = ProcessMouseMove(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -309,6 +321,7 @@ LRESULT CMenuFocusManager::GetMsgHook(INT nCode, WPARAM wParam, LPARAM lParam)
|
|||
DisableMouseTrack(NULL, FALSE);
|
||||
}
|
||||
}
|
||||
callNext = ProcessMouseMove(msg);
|
||||
break;
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYDOWN:
|
||||
|
@ -351,10 +364,12 @@ HRESULT CMenuFocusManager::PlaceHooks()
|
|||
//SetCapture(window);
|
||||
if (m_currentMenu)
|
||||
{
|
||||
DbgPrint("Entering MSGFILTER hook...\n");
|
||||
m_hMsgFilterHook = SetWindowsHookEx(WH_MSGFILTER, s_MsgFilterHook, NULL, m_threadId);
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrint("Entering GETMESSAGE hook...\n");
|
||||
m_hGetMsgHook = SetWindowsHookEx(WH_GETMESSAGE, s_GetMsgHook, NULL, m_threadId);
|
||||
}
|
||||
return S_OK;
|
||||
|
@ -362,6 +377,7 @@ HRESULT CMenuFocusManager::PlaceHooks()
|
|||
|
||||
HRESULT CMenuFocusManager::RemoveHooks()
|
||||
{
|
||||
DbgPrint("Removing all hooks...\n");
|
||||
if (m_hMsgFilterHook)
|
||||
UnhookWindowsHookEx(m_hMsgFilterHook);
|
||||
if (m_hGetMsgHook)
|
||||
|
@ -388,10 +404,15 @@ HRESULT CMenuFocusManager::UpdateFocus(CMenuBand * newBand, HMENU popupToTrack)
|
|||
m_currentBand = newBand;
|
||||
m_currentMenu = popupToTrack;
|
||||
m_currentFocus = newFocus;
|
||||
if (m_currentMenu)
|
||||
m_parentToolbar = NULL;
|
||||
if (popupToTrack)
|
||||
{
|
||||
m_currentBand->GetWindow(&m_parentToolbar);
|
||||
}
|
||||
else if (m_bandCount >= 2)
|
||||
{
|
||||
m_bandStack[m_bandCount - 2]->GetWindow(&m_parentToolbar);
|
||||
}
|
||||
|
||||
if (oldFocus && (!newFocus || (oldMenu != popupToTrack)))
|
||||
{
|
||||
|
@ -425,7 +446,7 @@ HRESULT CMenuFocusManager::PushMenu(CMenuBand * mb)
|
|||
|
||||
if (mbParent)
|
||||
{
|
||||
mbParent->SetClient(static_cast<IMenuPopup*>(mb));
|
||||
mbParent->_SetChildBand(mb);
|
||||
}
|
||||
|
||||
return UpdateFocus(mb);
|
||||
|
@ -466,7 +487,7 @@ HRESULT CMenuFocusManager::PopMenu(CMenuBand * mb)
|
|||
|
||||
if (mb)
|
||||
{
|
||||
mb->SetClient(NULL);
|
||||
mb->_SetChildBand(NULL);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
@ -515,10 +536,5 @@ HRESULT CMenuFocusManager::PopTrackedPopup(CMenuBand * mb, HMENU popup)
|
|||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
|
||||
if (mb)
|
||||
{
|
||||
mb->SetClient(NULL);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
|
@ -44,8 +44,8 @@ private:
|
|||
HWND m_currentFocus;
|
||||
HMENU m_currentMenu;
|
||||
HWND m_parentToolbar;
|
||||
HHOOK m_hGetMsgHook;
|
||||
HHOOK m_hMsgFilterHook;
|
||||
HHOOK m_hGetMsgHook;
|
||||
DWORD m_threadId;
|
||||
BOOL m_mouseTrackDisabled;
|
||||
WPARAM m_lastMoveFlags;
|
||||
|
@ -82,6 +82,7 @@ private:
|
|||
|
||||
void DisableMouseTrack(HWND enableTo, BOOL disableThis);
|
||||
|
||||
LRESULT ProcessMouseMove(MSG* msg);
|
||||
public:
|
||||
HRESULT PushMenu(CMenuBand * mb);
|
||||
HRESULT PopMenu(CMenuBand * mb);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
#include "precomp.h"
|
||||
#include <windowsx.h>
|
||||
#include <CommonControls.h>
|
||||
#include <commoncontrols.h>
|
||||
#include <shlwapi_undoc.h>
|
||||
|
||||
#include "CMenuBand.h"
|
||||
|
@ -84,8 +84,7 @@ HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||
return S_OK;
|
||||
|
||||
case TBN_DROPDOWN:
|
||||
wParam = reinterpret_cast<LPNMTOOLBAR>(hdr)->iItem;
|
||||
return OnCommand(wParam, 0, theResult);
|
||||
return OnCommand(reinterpret_cast<LPNMTOOLBAR>(hdr)->iItem, 0, theResult);
|
||||
|
||||
case TBN_HOTITEMCHANGE:
|
||||
return OnHotItemChange(reinterpret_cast<LPNMTBHOTITEM>(hdr), theResult);
|
||||
|
@ -99,8 +98,30 @@ HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||
case RBN_CHILDSIZE:
|
||||
return S_OK;
|
||||
|
||||
case NM_RELEASEDCAPTURE:
|
||||
break;
|
||||
|
||||
case NM_RDOWN:
|
||||
case NM_LDOWN:
|
||||
break;
|
||||
|
||||
case TBN_GETDISPINFO:
|
||||
break;
|
||||
|
||||
case TBN_BEGINDRAG:
|
||||
case TBN_ENDDRAG:
|
||||
break;
|
||||
|
||||
case NM_TOOLTIPSCREATED:
|
||||
break;
|
||||
|
||||
case TBN_GETINFOTIP:
|
||||
// TODO: Get tooltip for item
|
||||
break;
|
||||
|
||||
default:
|
||||
DbgPrint("WM_NOTIFY unknown code %d, %d\n", hdr->code, hdr->idFrom);
|
||||
break;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -406,7 +427,6 @@ LRESULT CMenuToolbarBase::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
|||
m_SubclassOld(hWnd, uMsg, wParam, lParam);
|
||||
return IsTrackedItem(wParam);
|
||||
case WM_USER_CHANGETRACKEDITEM:
|
||||
m_isTracking = TRUE;
|
||||
m_SubclassOld(hWnd, uMsg, wParam, lParam);
|
||||
return ChangeTrackedItem(wParam);
|
||||
|
||||
|
@ -423,10 +443,7 @@ LRESULT CMenuToolbarBase::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
|||
|
||||
m_menuBand->_OnPopupSubMenu(NULL, NULL, NULL, NULL, -1);
|
||||
|
||||
if (HasSubMenu(m_hotItem) == S_OK)
|
||||
{
|
||||
PopupItem(m_hotItem);
|
||||
}
|
||||
PopupItem(m_hotItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,17 +465,20 @@ HRESULT CMenuToolbarBase::OnHotItemChange(const NMTBHOTITEM * hot, LRESULT * the
|
|||
if (m_menuBand->_OnHotItemChanged(NULL, -1) == S_FALSE)
|
||||
{
|
||||
*theResult = 1;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hotItem = -1;
|
||||
m_menuBand->_OnHotItemChanged(NULL, -1);
|
||||
m_menuBand->_MenuItemHotTrack(MPOS_CHILDTRACKING);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
else if (m_hotItem != hot->idNew)
|
||||
|
||||
if (m_hotItem != hot->idNew)
|
||||
{
|
||||
DbgPrint("Hot item is now %d\n", hot->idNew);
|
||||
|
||||
if (hot->dwFlags & HICF_MOUSE &&
|
||||
m_toolbarFlags & SMINIT_VERTICAL)
|
||||
{
|
||||
|
@ -467,8 +487,7 @@ HRESULT CMenuToolbarBase::OnHotItemChange(const NMTBHOTITEM * hot, LRESULT * the
|
|||
SetTimer(m_hwndToolbar, TIMERID_HOTTRACK, elapsed, NULL);
|
||||
}
|
||||
|
||||
m_hotItem = hot->idNew;
|
||||
m_menuBand->_OnHotItemChanged(this, m_hotItem);
|
||||
m_menuBand->_OnHotItemChanged(this, hot->idNew);
|
||||
m_menuBand->_MenuItemHotTrack(MPOS_CHILDTRACKING);
|
||||
|
||||
if (m_isTracking && !(m_toolbarFlags & SMINIT_VERTICAL))
|
||||
|
@ -477,13 +496,11 @@ HRESULT CMenuToolbarBase::OnHotItemChange(const NMTBHOTITEM * hot, LRESULT * the
|
|||
|
||||
m_menuBand->_OnPopupSubMenu(NULL, NULL, NULL, NULL, -1);
|
||||
|
||||
if (HasSubMenu(m_hotItem) == S_OK)
|
||||
{
|
||||
PopupItem(m_hotItem);
|
||||
}
|
||||
PopupItem(m_hotItem);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -514,6 +531,7 @@ HRESULT CMenuToolbarBase::OnPopupItemChanged(CMenuToolbarBase * toolbar, INT ite
|
|||
{
|
||||
SendMessage(m_hwndToolbar, TB_CHECKBUTTON, m_popupItem, FALSE);
|
||||
m_isTracking = FALSE;
|
||||
DbgPrint("Is Tracking: %d\n", m_isTracking);
|
||||
}
|
||||
m_popupBar = toolbar;
|
||||
m_popupItem = item;
|
||||
|
@ -542,6 +560,9 @@ HRESULT CMenuToolbarBase::ChangeTrackedItem(INT index)
|
|||
|
||||
if (m_hotItem != btn.idCommand)
|
||||
{
|
||||
m_isTracking = TRUE;
|
||||
DbgPrint("Is Tracking: %d\n", m_isTracking);
|
||||
|
||||
SendMessage(m_hwndToolbar, TB_SETHOTITEM, index, 0);
|
||||
}
|
||||
return S_OK;
|
||||
|
@ -626,6 +647,8 @@ HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, IShellMenu* child
|
|||
return hr;
|
||||
|
||||
m_isTracking = TRUE;
|
||||
DbgPrint("Is Tracking: %d\n", m_isTracking);
|
||||
|
||||
m_menuBand->_OnPopupSubMenu(popup, &pt, &rcl, this, uItem);
|
||||
|
||||
return S_OK;
|
||||
|
@ -663,10 +686,14 @@ HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, HMENU menu)
|
|||
HMENU popup = GetSubMenu(menu, index);
|
||||
|
||||
m_isTracking = TRUE;
|
||||
DbgPrint("Is Tracking: %d\n", m_isTracking);
|
||||
|
||||
m_menuBand->_TrackSubMenuUsingTrackPopupMenu(popup, pt.x, pt.y, rcl);
|
||||
|
||||
SendMessage(m_hwndToolbar, TB_CHECKBUTTON, uItem, FALSE);
|
||||
|
||||
m_isTracking = FALSE;
|
||||
DbgPrint("Is Tracking: %d\n", m_isTracking);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -704,15 +731,17 @@ HRESULT CMenuToolbarBase::DoContextMenu(IContextMenu* contextMenu)
|
|||
HRESULT CMenuToolbarBase::OnCommand(WPARAM wParam, LPARAM lParam, LRESULT *theResult)
|
||||
{
|
||||
theResult = 0;
|
||||
if (HasSubMenu(wParam) == S_OK)
|
||||
{
|
||||
KillTimer(m_hwndToolbar, TIMERID_HOTTRACK);
|
||||
PopupItem(wParam);
|
||||
|
||||
KillTimer(m_hwndToolbar, TIMERID_HOTTRACK);
|
||||
|
||||
if (PopupItem(wParam) == S_OK)
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT hr = m_menuBand->_MenuItemHotTrack(MPOS_EXECUTE);
|
||||
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
|
||||
return S_OK; // filter out a possible S_FALSE from here.
|
||||
}
|
||||
|
||||
|
@ -866,8 +895,11 @@ HRESULT CMenuToolbarBase::AddPlaceholder()
|
|||
HRESULT CMenuToolbarBase::GetDataFromId(INT uItem, INT* pIndex, DWORD_PTR* pData)
|
||||
{
|
||||
TBBUTTONINFO info = { 0 };
|
||||
DbgPrint("GetDataFromId %d\n", uItem);
|
||||
|
||||
info.cbSize = sizeof(TBBUTTONINFO);
|
||||
info.dwMask = 0;
|
||||
info.dwMask = TBIF_COMMAND | TBIF_LPARAM;
|
||||
|
||||
int index = SendMessage(m_hwndToolbar, TB_GETBUTTONINFO, uItem, reinterpret_cast<LPARAM>(&info));
|
||||
if (index < 0)
|
||||
return E_FAIL;
|
||||
|
@ -876,43 +908,33 @@ HRESULT CMenuToolbarBase::GetDataFromId(INT uItem, INT* pIndex, DWORD_PTR* pData
|
|||
*pIndex = index;
|
||||
|
||||
if (pData)
|
||||
{
|
||||
TBBUTTON btn = { 0 };
|
||||
if (!SendMessage(m_hwndToolbar, TB_GETBUTTON, index, reinterpret_cast<LPARAM>(&btn)))
|
||||
return E_FAIL;
|
||||
*pData = btn.dwData;
|
||||
}
|
||||
*pData = info.lParam;
|
||||
|
||||
DbgPrint("GetDataFromId ret: %d, %d, %x, %x\n", info.idCommand, index, info.lParam);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CMenuToolbarBase::PopupItem(INT uItem)
|
||||
{
|
||||
INT index;
|
||||
DWORD_PTR dwData;
|
||||
|
||||
GetDataFromId(uItem, &index, &dwData);
|
||||
|
||||
if (!(m_toolbarFlags & SMINIT_VERTICAL))
|
||||
{
|
||||
SendMessage(m_hwndToolbar, TB_SETHOTITEM, uItem, 0);
|
||||
SendMessage(m_hwndToolbar, TB_SETHOTITEM, index, 0);
|
||||
SendMessage(m_hwndToolbar, TB_CHECKBUTTON, uItem, TRUE);
|
||||
}
|
||||
|
||||
GetDataFromId(uItem, &index, &dwData);
|
||||
HRESULT hr = InternalHasSubMenu(uItem, index, dwData);
|
||||
if (hr != S_OK)
|
||||
return hr;
|
||||
|
||||
return InternalPopupItem(uItem, index, dwData);
|
||||
}
|
||||
|
||||
HRESULT CMenuToolbarBase::HasSubMenu(INT uItem)
|
||||
{
|
||||
INT index;
|
||||
DWORD_PTR dwData;
|
||||
|
||||
GetDataFromId(uItem, &index, &dwData);
|
||||
|
||||
return InternalHasSubMenu(uItem, index, dwData);
|
||||
}
|
||||
|
||||
CMenuStaticToolbar::CMenuStaticToolbar(CMenuBand *menuBand) :
|
||||
CMenuToolbarBase(menuBand, FALSE),
|
||||
m_hmenu(NULL)
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
class CMenuBand;
|
||||
class CMenuFocusManager;
|
||||
|
||||
#define WM_USER_ISTRACKEDITEM (WM_USER+41)
|
||||
#define WM_USER_CHANGETRACKEDITEM (WM_USER+42)
|
||||
#define WM_USER_ISTRACKEDITEM (WM_APP+41)
|
||||
#define WM_USER_CHANGETRACKEDITEM (WM_APP+42)
|
||||
|
||||
|
||||
class CMenuToolbarBase
|
||||
|
@ -89,7 +89,6 @@ public:
|
|||
virtual HRESULT OnContextMenu(NMMOUSE * rclick) = 0;
|
||||
|
||||
HRESULT PopupItem(INT uItem);
|
||||
HRESULT HasSubMenu(INT uItem);
|
||||
HRESULT GetDataFromId(INT uItem, INT* pIndex, DWORD_PTR* pData);
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in a new issue