ReactOS  0.4.14-dev-552-g2fad488
CMenuFocusManager Class Reference

#include <CMenuFocusManager.h>

Inheritance diagram for CMenuFocusManager:
Collaboration diagram for CMenuFocusManager:

Classes

struct  StackEntry
 

Public Member Functions

HRESULT PushMenuBar (CMenuBand *mb)
 
HRESULT PushMenuPopup (CMenuBand *mb)
 
HRESULT PushTrackedPopup (HMENU popup)
 
HRESULT PopMenuBar (CMenuBand *mb)
 
HRESULT PopMenuPopup (CMenuBand *mb)
 
HRESULT PopTrackedPopup (HMENU popup)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 

Static Public Member Functions

static CMenuFocusManagerAcquireManager ()
 
static void ReleaseManager (CMenuFocusManager *obj)
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 

Protected Member Functions

 CMenuFocusManager ()
 
 ~CMenuFocusManager ()
 

Private Types

enum  StackEntryType { NoEntry, MenuBarEntry, MenuPopupEntry, TrackedMenuEntry }
 

Private Member Functions

HRESULT PushToArray (StackEntryType type, CMenuBand *mb, HMENU hmenu)
 
HRESULT PopFromArray (StackEntryType *pType, CMenuBand **pMb, HMENU *pHmenu)
 
LRESULT GetMsgHook (INT nCode, WPARAM wParam, LPARAM lParam)
 
LRESULT MsgFilterHook (INT nCode, WPARAM wParam, LPARAM lParam)
 
HRESULT PlaceHooks ()
 
HRESULT RemoveHooks ()
 
HRESULT UpdateFocus ()
 
HRESULT IsTrackedWindow (HWND hWnd, StackEntry **pentry=NULL)
 
HRESULT IsTrackedWindowOrParent (HWND hWnd)
 
void DisableMouseTrack (HWND parent, BOOL disableThis)
 
void SetMenuCapture (HWND child)
 
LRESULT ProcessMouseMove (MSG *msg)
 
LRESULT ProcessMouseDown (MSG *msg, BOOL isLButton)
 
LRESULT ProcessMouseUp (MSG *msg, BOOL isLButton)
 

Static Private Member Functions

static CMenuFocusManagerGetManager ()
 
static LRESULT CALLBACK s_MsgFilterHook (INT nCode, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK s_GetMsgHook (INT nCode, WPARAM wParam, LPARAM lParam)
 

Private Attributes

StackEntrym_current
 
StackEntrym_parent
 
StackEntrym_menuBar
 
HHOOK m_hMsgFilterHook
 
HHOOK m_hGetMsgHook
 
DWORD m_threadId
 
BOOL m_mouseTrackDisabled
 
POINT m_ptPrev
 
HWND m_captureHwnd
 
HWND m_hwndUnderMouse
 
StackEntrym_entryUnderMouse
 
HMENU m_selectedMenu
 
INT m_selectedItem
 
DWORD m_selectedItemFlags
 
BOOL m_movedSinceDown
 
HWND m_windowAtDown
 
HWND m_PreviousForeground
 
StackEntry m_bandStack [MAX_RECURSE]
 
int m_bandCount
 
int m_menuDepth
 

Static Private Attributes

static DWORD TlsIndex = 0
 

Additional Inherited Members

- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 24 of file CMenuFocusManager.h.

Member Enumeration Documentation

◆ StackEntryType

Constructor & Destructor Documentation

◆ CMenuFocusManager()

CMenuFocusManager::CMenuFocusManager ( )
protected

Definition at line 176 of file CMenuFocusManager.cpp.

176  :
177  m_current(NULL),
178  m_parent(NULL),
182  m_captureHwnd(0),
186  m_selectedItem(0),
191  m_bandCount(0),
192  m_menuDepth(0)
193 {
194  m_ptPrev.x = 0;
195  m_ptPrev.y = 0;
197 }
StackEntry * m_current
StackEntry * m_parent
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
StackEntry * m_entryUnderMouse
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458

◆ ~CMenuFocusManager()

CMenuFocusManager::~CMenuFocusManager ( )
protected

Definition at line 199 of file CMenuFocusManager.cpp.

200 {
201 }

Member Function Documentation

◆ AcquireManager()

CMenuFocusManager * CMenuFocusManager::AcquireManager ( )
static

Definition at line 97 of file CMenuFocusManager.cpp.

98 {
100 
101  if (!TlsIndex)
102  {
103  if ((TlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES)
104  return NULL;
105  }
106 
107  obj = GetManager();
108 
109  if (!obj)
110  {
111  obj = new CComObject<CMenuFocusManager>();
113  }
114 
115  obj->AddRef();
116 
117  return obj;
118 }
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1264
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1088
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:530
static CMenuFocusManager * GetManager()
static DWORD TlsIndex

Referenced by CMenuBand::CMenuBand().

◆ DisableMouseTrack()

void CMenuFocusManager::DisableMouseTrack ( HWND  parent,
BOOL  disableThis 
)
private

Definition at line 204 of file CMenuFocusManager.cpp.

205 {
206  BOOL bDisable = FALSE;
207  BOOL lastDisable = FALSE;
208 
209  int i = m_bandCount;
210  while (--i >= 0)
211  {
212  StackEntry& entry = m_bandStack[i];
213 
214  if (entry.type != TrackedMenuEntry)
215  {
216  HWND hwnd;
217  HRESULT hr = entry.mb->_GetTopLevelWindow(&hwnd);
218  if (FAILED_UNEXPECTEDLY(hr))
219  break;
220 
221  if (hwnd == parent)
222  {
223  lastDisable = disableThis;
224  entry.mb->_DisableMouseTrack(disableThis);
225  bDisable = TRUE;
226  }
227  else
228  {
229  lastDisable = bDisable;
230  entry.mb->_DisableMouseTrack(bDisable);
231  }
232  }
233  }
234  m_mouseTrackDisabled = lastDisable;
235 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
r parent
Definition: btrfs.c:2869
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
uint32_t entry
Definition: isohybrid.c:63
StackEntry m_bandStack[MAX_RECURSE]

Referenced by GetMsgHook(), ProcessMouseMove(), and UpdateFocus().

◆ GetManager()

CMenuFocusManager * CMenuFocusManager::GetManager ( )
staticprivate

Definition at line 91 of file CMenuFocusManager.cpp.

92 {
93  return reinterpret_cast<CMenuFocusManager *>(TlsGetValue(TlsIndex));
94 }
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1228
static DWORD TlsIndex

Referenced by AcquireManager(), s_GetMsgHook(), and s_MsgFilterHook().

◆ GetMsgHook()

LRESULT CMenuFocusManager::GetMsgHook ( INT  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
private

Definition at line 557 of file CMenuFocusManager.cpp.

558 {
559  BOOL isLButton = FALSE;
560  if (nCode < 0)
561  return CallNextHookEx(m_hGetMsgHook, nCode, hookWParam, hookLParam);
562 
563  if (nCode == HC_ACTION)
564  {
565  BOOL callNext = TRUE;
566  MSG* msg = reinterpret_cast<MSG*>(hookLParam);
567  POINT pt = msg->pt;
568 
569  switch (msg->message)
570  {
571  case WM_CAPTURECHANGED:
572  if (m_captureHwnd)
573  {
574  TRACE("Capture lost.\n");
576  }
577  break;
578 
579  case WM_NCLBUTTONDOWN:
580  case WM_LBUTTONDOWN:
581  isLButton = TRUE;
582  TRACE("LB\n");
583 
585  {
586  POINT pt = msg->pt;
588  BOOL hoveringMenuBar = m_menuBar->mb->IsWindowOwner(child) == S_OK;
589  if (hoveringMenuBar)
590  {
591  m_current->mb->_MenuItemSelect(MPOS_FULLCANCEL);
592  break;
593  }
594  }
595 
596  if (m_current->type == MenuPopupEntry)
597  {
599 
601  {
602  m_current->mb->_MenuItemSelect(MPOS_FULLCANCEL);
603  break;
604  }
605  }
606 
607  ProcessMouseDown(msg, isLButton);
608 
609  break;
610  case WM_NCRBUTTONUP:
611  case WM_RBUTTONUP:
612  ProcessMouseUp(msg, isLButton);
613  break;
614  case WM_NCLBUTTONUP:
615  case WM_LBUTTONUP:
616  isLButton = TRUE;
617  ProcessMouseUp(msg, isLButton);
618  break;
619  case WM_MOUSEMOVE:
620  callNext = ProcessMouseMove(msg);
621  break;
622  case WM_MOUSELEAVE:
623  callNext = ProcessMouseMove(msg);
624  //callNext = ProcessMouseLeave(msg);
625  break;
626  case WM_SYSKEYDOWN:
627  case WM_KEYDOWN:
628  if (m_current->type == MenuPopupEntry)
629  {
631  switch (msg->wParam)
632  {
633  case VK_ESCAPE:
634  case VK_MENU:
635  case VK_LMENU:
636  case VK_RMENU:
637  m_current->mb->_MenuItemSelect(MPOS_FULLCANCEL);
638  break;
639  case VK_RETURN:
640  m_current->mb->_MenuItemSelect(MPOS_EXECUTE);
641  break;
642  case VK_LEFT:
644  break;
645  case VK_RIGHT:
647  break;
648  case VK_UP:
650  break;
651  case VK_DOWN:
653  break;
654  }
655  msg->message = WM_NULL;
656  msg->lParam = 0;
657  msg->wParam = 0;
658  }
659  break;
660  }
661 
662  if (!callNext)
663  return 1;
664  }
665 
666  return CallNextHookEx(m_hGetMsgHook, nCode, hookWParam, hookLParam);
667 }
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1674
#define WM_NULL
Definition: winuser.h:1589
HRESULT IsTrackedWindowOrParent(HWND hWnd)
#define TRUE
Definition: types.h:120
StackEntry * m_current
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
#define pt(x, y)
Definition: drawing.c:79
#define VK_RMENU
Definition: winuser.h:2262
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define WM_CAPTURECHANGED
Definition: winuser.h:1790
#define VK_LEFT
Definition: winuser.h:2199
#define VK_DOWN
Definition: winuser.h:2202
#define VK_MENU
Definition: winuser.h:2179
#define VK_ESCAPE
Definition: winuser.h:2189
#define VK_RETURN
Definition: winuser.h:2176
static HWND child
Definition: cursoricon.c:298
#define VK_UP
Definition: winuser.h:2200
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_NCRBUTTONUP
Definition: winuser.h:1678
#define WM_MOUSELEAVE
Definition: commctrl.h:4971
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1697
StackEntry * m_menuBar
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT ProcessMouseUp(MSG *msg, BOOL isLButton)
virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd)
Definition: CMenuBand.cpp:757
#define WM_RBUTTONUP
Definition: winuser.h:1762
#define VK_LMENU
Definition: winuser.h:2261
#define VK_RIGHT
Definition: winuser.h:2201
#define S_OK
Definition: intsafe.h:59
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define HC_ACTION
Definition: winuser.h:48
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define WM_MOUSEMOVE
Definition: winuser.h:1757
HWND WINAPI WindowFromPoint(_In_ POINT)
LRESULT ProcessMouseDown(MSG *msg, BOOL isLButton)
#define msg(x)
Definition: auth_time.c:54
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
#define WM_NCLBUTTONUP
Definition: winuser.h:1675
LRESULT ProcessMouseMove(MSG *msg)
void DisableMouseTrack(HWND parent, BOOL disableThis)
HRESULT _MenuItemSelect(DWORD changeType)
Definition: CMenuBand.cpp:954

Referenced by s_GetMsgHook().

◆ IsTrackedWindow()

HRESULT CMenuFocusManager::IsTrackedWindow ( HWND  hWnd,
StackEntry **  pentry = NULL 
)
private

Definition at line 257 of file CMenuFocusManager.cpp.

258 {
259  if (pentry)
260  *pentry = NULL;
261 
262  for (int i = m_bandCount; --i >= 0;)
263  {
264  StackEntry& entry = m_bandStack[i];
265 
266  if (entry.type != TrackedMenuEntry)
267  {
268  HRESULT hr = entry.mb->IsWindowOwner(hWnd);
269  if (FAILED_UNEXPECTEDLY(hr))
270  return hr;
271  if (hr == S_OK)
272  {
273  if (pentry)
274  *pentry = &entry;
275  return S_OK;
276  }
277  }
278  }
279 
280  return S_FALSE;
281 }
HRESULT hr
Definition: shlfolder.c:183
HWND hWnd
Definition: settings.c:17
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:59
StackEntry m_bandStack[MAX_RECURSE]

Referenced by ProcessMouseDown(), ProcessMouseMove(), and ProcessMouseUp().

◆ IsTrackedWindowOrParent()

HRESULT CMenuFocusManager::IsTrackedWindowOrParent ( HWND  hWnd)
private

Definition at line 283 of file CMenuFocusManager.cpp.

284 {
285  for (int i = m_bandCount; --i >= 0;)
286  {
287  StackEntry& entry = m_bandStack[i];
288 
289  if (entry.type != TrackedMenuEntry)
290  {
291  HRESULT hr = entry.mb->IsWindowOwner(hWnd);
292  if (FAILED_UNEXPECTEDLY(hr))
293  return hr;
294  if (hr == S_OK)
295  return S_OK;
296  if (entry.mb->_IsPopup() == S_OK)
297  {
298  CComPtr<IUnknown> site;
299  CComPtr<IOleWindow> pw;
300  hr = entry.mb->GetSite(IID_PPV_ARG(IUnknown, &site));
301  if (FAILED_UNEXPECTEDLY(hr))
302  continue;
303  hr = IUnknown_QueryService(site, SID_SMenuBandParent, IID_PPV_ARG(IOleWindow, &pw));
304  if (FAILED_UNEXPECTEDLY(hr))
305  continue;
306 
307  HWND hParent;
308  if (pw->GetWindow(&hParent) == S_OK && hParent == hWnd)
309  return S_OK;
310  }
311  }
312  }
313 
314  return S_FALSE;
315 }
HRESULT hr
Definition: shlfolder.c:183
static IActiveScriptSite * site
Definition: script.c:149
HWND hWnd
Definition: settings.c:17
#define IID_PPV_ARG(Itype, ppType)
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1448
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define S_FALSE
Definition: winerror.h:2357
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:59
StackEntry m_bandStack[MAX_RECURSE]

Referenced by GetMsgHook().

◆ MsgFilterHook()

LRESULT CMenuFocusManager::MsgFilterHook ( INT  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
private

Definition at line 491 of file CMenuFocusManager.cpp.

492 {
493  if (nCode < 0)
494  return CallNextHookEx(m_hMsgFilterHook, nCode, hookWParam, hookLParam);
495 
496  if (nCode == MSGF_MENU)
497  {
498  BOOL callNext = TRUE;
499  MSG* msg = reinterpret_cast<MSG*>(hookLParam);
500 
501  switch (msg->message)
502  {
503  case WM_LBUTTONDOWN:
504  case WM_RBUTTONDOWN:
506  {
507  POINT pt = msg->pt;
509  BOOL hoveringMenuBar = m_menuBar->mb->IsWindowOwner(child) == S_OK;
510  if (hoveringMenuBar)
511  {
513  }
514  }
515  break;
516  case WM_MOUSEMOVE:
517  callNext = ProcessMouseMove(msg);
518  break;
519  case WM_INITMENUPOPUP:
520  TRACE("WM_INITMENUPOPUP %p %p\n", msg->wParam, msg->lParam);
521  m_selectedMenu = reinterpret_cast<HMENU>(msg->lParam);
522  m_selectedItem = -1;
524  break;
525  case WM_MENUSELECT:
526  TRACE("WM_MENUSELECT %p %p\n", msg->wParam, msg->lParam);
527  m_selectedMenu = reinterpret_cast<HMENU>(msg->lParam);
528  m_selectedItem = GET_X_LPARAM(msg->wParam);
529  m_selectedItemFlags = HIWORD(msg->wParam);
530  break;
531  case WM_KEYDOWN:
532  switch (msg->wParam)
533  {
534  case VK_LEFT:
536  {
538  }
539  break;
540  case VK_RIGHT:
542  {
544  }
545  break;
546  }
547  break;
548  }
549 
550  if (!callNext)
551  return 1;
552  }
553 
554  return CallNextHookEx(m_hMsgFilterHook, nCode, hookWParam, hookLParam);
555 }
HRESULT _BeforeCancelPopup()
Definition: CMenuBand.cpp:1101
#define TRUE
Definition: types.h:120
StackEntry * m_current
StackEntry * m_parent
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
#define pt(x, y)
Definition: drawing.c:79
#define WM_INITMENUPOPUP
Definition: winuser.h:1728
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
#define VK_LEFT
Definition: winuser.h:2199
#define MSGF_MENU
Definition: winuser.h:1161
static HWND child
Definition: cursoricon.c:298
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_MENUSELECT
Definition: winuser.h:1729
#define WM_KEYDOWN
Definition: winuser.h:1697
#define WM_RBUTTONDOWN
Definition: winuser.h:1761
StackEntry * m_menuBar
#define TRACE(s)
Definition: solgame.cpp:4
virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd)
Definition: CMenuBand.cpp:757
#define MF_POPUP
Definition: winuser.h:136
#define VK_RIGHT
Definition: winuser.h:2201
#define S_OK
Definition: intsafe.h:59
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define WM_MOUSEMOVE
Definition: winuser.h:1757
HWND WINAPI WindowFromPoint(_In_ POINT)
#define msg(x)
Definition: auth_time.c:54
#define HIWORD(l)
Definition: typedefs.h:246
LRESULT ProcessMouseMove(MSG *msg)
HRESULT _MenuItemSelect(DWORD changeType)
Definition: CMenuBand.cpp:954

Referenced by s_MsgFilterHook().

◆ PlaceHooks()

HRESULT CMenuFocusManager::PlaceHooks ( )
private

Definition at line 669 of file CMenuFocusManager.cpp.

670 {
671  if (m_hGetMsgHook)
672  {
673  WARN("GETMESSAGE hook already placed!\n");
674  return S_OK;
675  }
676  if (m_hMsgFilterHook)
677  {
678  WARN("MSGFILTER hook already placed!\n");
679  return S_OK;
680  }
682  {
683  TRACE("Entering MSGFILTER hook...\n");
685  }
686  else
687  {
688  TRACE("Entering GETMESSAGE hook...\n");
690  }
691  return S_OK;
692 }
#define WH_GETMESSAGE
Definition: winuser.h:33
StackEntry * m_current
#define WH_MSGFILTER
Definition: winuser.h:29
#define WARN(fmt,...)
Definition: debug.h:111
static LRESULT CALLBACK s_GetMsgHook(INT nCode, WPARAM wParam, LPARAM lParam)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define SetWindowsHookEx
Definition: winuser.h:5831
static LRESULT CALLBACK s_MsgFilterHook(INT nCode, WPARAM wParam, LPARAM lParam)
#define S_OK
Definition: intsafe.h:59

Referenced by UpdateFocus().

◆ PopFromArray()

HRESULT CMenuFocusManager::PopFromArray ( StackEntryType pType,
CMenuBand **  pMb,
HMENU pHmenu 
)
private

Definition at line 152 of file CMenuFocusManager.cpp.

153 {
154  if (pType) *pType = NoEntry;
155  if (pMb) *pMb = NULL;
156  if (pHmenu) *pHmenu = NULL;
157 
158  if (m_bandCount <= 0)
159  return S_FALSE;
160 
161  m_bandCount--;
162 
163  if (pType) *pType = m_bandStack[m_bandCount].type;
164  if (*pType == TrackedMenuEntry)
165  {
166  if (pHmenu) *pHmenu = m_bandStack[m_bandCount].hmenu;
167  }
168  else
169  {
170  if (pMb) *pMb = m_bandStack[m_bandCount].mb;
171  }
172 
173  return S_OK;
174 }
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define S_OK
Definition: intsafe.h:59
StackEntry m_bandStack[MAX_RECURSE]

Referenced by PopMenuBar(), PopMenuPopup(), and PopTrackedPopup().

◆ PopMenuBar()

HRESULT CMenuFocusManager::PopMenuBar ( CMenuBand mb)

Definition at line 923 of file CMenuFocusManager.cpp.

924 {
926  CMenuBand * mbc;
927  HRESULT hr;
928 
929  TRACE("PopMenuBar %p\n", mb);
930 
932  {
934  }
935 
936  hr = PopFromArray(&type, &mbc, NULL);
937  if (FAILED_UNEXPECTEDLY(hr))
938  {
939  UpdateFocus();
940  return hr;
941  }
942 
944  if (type != MenuBarEntry)
945  return E_FAIL;
946 
947  if (!mbc)
948  return E_FAIL;
949 
950  mbc->_SetParentBand(NULL);
951 
952  mbc->Release();
953 
954  hr = UpdateFocus();
955  if (FAILED_UNEXPECTEDLY(hr))
956  return hr;
957 
958  if (m_current)
959  {
962  }
963 
964  return S_OK;
965 }
StackEntry * m_current
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define E_FAIL
Definition: ddrawi.h:102
StackEntry * m_entryUnderMouse
smooth NULL
Definition: ftsmooth.c:416
HRESULT _SetChildBand(CMenuBand *child)
Definition: CMenuBand.cpp:603
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define _ASSERT(x)
#define S_OK
Definition: intsafe.h:59
char mbc
HRESULT PopFromArray(StackEntryType *pType, CMenuBand **pMb, HMENU *pHmenu)

Referenced by CMenuBand::ShowDW().

◆ PopMenuPopup()

HRESULT CMenuFocusManager::PopMenuPopup ( CMenuBand mb)

Definition at line 968 of file CMenuFocusManager.cpp.

969 {
971  CMenuBand * mbc;
972  HRESULT hr;
973 
974  TRACE("PopMenuPopup %p\n", mb);
975 
977  {
979  }
980 
981  m_menuDepth--;
982 
983  hr = PopFromArray(&type, &mbc, NULL);
984  if (FAILED_UNEXPECTEDLY(hr))
985  {
986  UpdateFocus();
987  return hr;
988  }
989 
991  if (type != MenuPopupEntry)
992  return E_FAIL;
993 
994  if (!mbc)
995  return E_FAIL;
996 
997  mbc->_SetParentBand(NULL);
998 
999  mbc->Release();
1000 
1001  hr = UpdateFocus();
1002  if (FAILED_UNEXPECTEDLY(hr))
1003  return hr;
1004 
1005  if (m_current)
1006  {
1009  }
1010 
1011  return S_OK;
1012 }
StackEntry * m_current
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define E_FAIL
Definition: ddrawi.h:102
StackEntry * m_entryUnderMouse
smooth NULL
Definition: ftsmooth.c:416
HRESULT _SetChildBand(CMenuBand *child)
Definition: CMenuBand.cpp:603
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define _ASSERT(x)
#define S_OK
Definition: intsafe.h:59
char mbc
HRESULT PopFromArray(StackEntryType *pType, CMenuBand **pMb, HMENU *pHmenu)

Referenced by CMenuBand::ShowDW().

◆ PopTrackedPopup()

HRESULT CMenuFocusManager::PopTrackedPopup ( HMENU  popup)

Definition at line 1015 of file CMenuFocusManager.cpp.

1016 {
1018  HMENU hmenu;
1019  HRESULT hr;
1020 
1021  TRACE("PopTrackedPopup %p\n", popup);
1022 
1023  hr = PopFromArray(&type, NULL, &hmenu);
1024  if (FAILED_UNEXPECTEDLY(hr))
1025  {
1026  UpdateFocus();
1027  return hr;
1028  }
1029 
1031  if (type != TrackedMenuEntry)
1032  return E_FAIL;
1033 
1034  if (hmenu != popup)
1035  return E_FAIL;
1036 
1037  hr = UpdateFocus();
1038  if (FAILED_UNEXPECTEDLY(hr))
1039  return hr;
1040 
1041  return S_OK;
1042 }
HRESULT hr
Definition: shlfolder.c:183
static HMENU hmenu
Definition: win.c:66
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define _ASSERT(x)
#define S_OK
Definition: intsafe.h:59
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
HRESULT PopFromArray(StackEntryType *pType, CMenuBand **pMb, HMENU *pHmenu)

Referenced by CMenuBand::_TrackContextMenu(), and CMenuBand::_TrackSubMenu().

◆ ProcessMouseDown()

LRESULT CMenuFocusManager::ProcessMouseDown ( MSG msg,
BOOL  isLButton 
)
private

Definition at line 399 of file CMenuFocusManager.cpp.

400 {
401  HWND child;
402  int iHitTestResult = -1;
403 
404  TRACE("ProcessMouseDown %d %d %d\n", msg->message, msg->wParam, msg->lParam);
405 
406  // Don't do anything if another window is capturing the mouse.
407  HWND cCapture = ::GetCapture();
408  if (cCapture && cCapture != m_captureHwnd && m_current->type != TrackedMenuEntry)
409  {
410  TRACE("Foreign capture active.\n");
411  return TRUE;
412  }
413 
414  POINT pt = msg->pt;
415 
417 
418  StackEntry * entry = NULL;
419  if (IsTrackedWindow(child, &entry) != S_OK)
420  {
421  TRACE("Foreign window detected.\n");
422  return TRUE;
423  }
424 
425  if (entry->type == MenuBarEntry)
426  {
427  if (entry != m_current)
428  {
429  TRACE("Menubar with popup active.\n");
430  return TRUE;
431  }
432  }
433 
434  if (entry)
435  {
437  iHitTestResult = SendMessageW(child, TB_HITTEST, 0, (LPARAM) &pt);
438 
439  if (iHitTestResult >= 0)
440  {
441  TRACE("MouseDown send %d\n", iHitTestResult);
442  entry->mb->_MenuBarMouseDown(child, iHitTestResult, isLButton);
443  }
444  }
445 
446  msg->message = WM_NULL;
447 
450 
451  TRACE("MouseDown end\n");
452 
453  return TRUE;
454 }
#define WM_NULL
Definition: winuser.h:1589
#define TB_HITTEST
Definition: commctrl.h:1264
#define TRUE
Definition: types.h:120
StackEntry * m_current
#define pt(x, y)
Definition: drawing.c:79
static HWND child
Definition: cursoricon.c:298
HWND WINAPI GetCapture(void)
Definition: message.c:2879
HRESULT IsTrackedWindow(HWND hWnd, StackEntry **pentry=NULL)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:59
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI WindowFromPoint(_In_ POINT)
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)

Referenced by GetMsgHook().

◆ ProcessMouseMove()

LRESULT CMenuFocusManager::ProcessMouseMove ( MSG msg)
private

Definition at line 317 of file CMenuFocusManager.cpp.

318 {
319  HWND child;
320  int iHitTestResult = -1;
321 
322  POINT pt2 = { GET_X_LPARAM(msg->lParam), GET_Y_LPARAM(msg->lParam) };
323  ClientToScreen(msg->hwnd, &pt2);
324 
325  POINT pt = msg->pt;
326 
327  // Don't do anything if another window is capturing the mouse.
328  HWND cCapture = ::GetCapture();
329  if (cCapture && cCapture != m_captureHwnd && m_current->type != TrackedMenuEntry)
330  return TRUE;
331 
333 
334  m_ptPrev = pt;
335 
337 
338  StackEntry * entry = NULL;
339  if (IsTrackedWindow(child, &entry) == S_OK)
340  {
341  TRACE("MouseMove");
342  }
343 
344  BOOL isTracking = FALSE;
345  if (entry && (entry->type == MenuBarEntry || m_current->type != TrackedMenuEntry))
346  {
348  iHitTestResult = SendMessageW(child, TB_HITTEST, 0, (LPARAM) &pt);
349  isTracking = entry->mb->_IsTracking();
350 
351  if (SendMessage(child, WM_USER_ISTRACKEDITEM, iHitTestResult, 0) == S_FALSE)
352  {
353  // The current tracked item has changed, notify the toolbar
354 
355  TRACE("Hot item tracking detected a change (capture=%p / cCapture=%p)...\n", m_captureHwnd, cCapture);
357  if (isTracking && iHitTestResult >= 0 && m_current->type == TrackedMenuEntry)
358  SendMessage(entry->hwnd, WM_CANCELMODE, 0, 0);
359  PostMessage(child, WM_USER_CHANGETRACKEDITEM, iHitTestResult, MAKELPARAM(isTracking, TRUE));
361  return FALSE;
362  }
363  }
364 
365  if (m_entryUnderMouse != entry)
366  {
367  // Mouse moved away from a tracked window
368  if (m_entryUnderMouse)
369  {
371  }
372  }
373 
374  if (m_hwndUnderMouse != child)
375  {
376  if (entry)
377  {
378  // Mouse moved to a tracked window
379  if (m_current->type == MenuPopupEntry)
380  {
381  ScreenToClient(child, &pt2);
382  SendMessage(child, WM_MOUSEMOVE, msg->wParam, MAKELPARAM(pt2.x, pt2.y));
383  }
384  }
385 
388  }
389 
390  if (m_current->type == MenuPopupEntry)
391  {
394  }
395 
396  return TRUE;
397 }
#define WM_USER_ISTRACKEDITEM
Definition: CMenuToolbars.h:25
#define GA_ROOT
Definition: winuser.h:2764
#define TB_HITTEST
Definition: commctrl.h:1264
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)
#define TRUE
Definition: types.h:120
StackEntry * m_current
long y
Definition: polytest.cpp:48
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
static HWND child
Definition: cursoricon.c:298
StackEntry * m_entryUnderMouse
#define WM_USER_CHANGETRACKEDITEM
Definition: CMenuToolbars.h:26
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT _ChangeHotItem(CMenuToolbarBase *tb, INT id, DWORD dwFlags)
Definition: CMenuBand.cpp:880
HWND WINAPI GetCapture(void)
Definition: message.c:2879
#define S_FALSE
Definition: winerror.h:2357
#define HICF_MOUSE
Definition: commctrl.h:1322
HRESULT IsTrackedWindow(HWND hWnd, StackEntry **pentry=NULL)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define PostMessage
Definition: winuser.h:5807
#define TRACE(s)
Definition: solgame.cpp:4
r parent
Definition: btrfs.c:2869
#define WM_CANCELMODE
Definition: winuser.h:1617
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:59
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_MOUSEMOVE
Definition: winuser.h:1757
HWND WINAPI WindowFromPoint(_In_ POINT)
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
#define msg(x)
Definition: auth_time.c:54
#define SendMessage
Definition: winuser.h:5818
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
void DisableMouseTrack(HWND parent, BOOL disableThis)

Referenced by GetMsgHook(), and MsgFilterHook().

◆ ProcessMouseUp()

LRESULT CMenuFocusManager::ProcessMouseUp ( MSG msg,
BOOL  isLButton 
)
private

Definition at line 456 of file CMenuFocusManager.cpp.

457 {
458  HWND child;
459  int iHitTestResult = -1;
460 
461  TRACE("ProcessMouseUp %d %d %d\n", msg->message, msg->wParam, msg->lParam);
462 
463  // Don't do anything if another window is capturing the mouse.
464  HWND cCapture = ::GetCapture();
465  if (cCapture && cCapture != m_captureHwnd && m_current->type != TrackedMenuEntry)
466  return TRUE;
467 
468  POINT pt = msg->pt;
469 
471 
472  StackEntry * entry = NULL;
473  if (IsTrackedWindow(child, &entry) != S_OK)
474  return TRUE;
475 
476  if (entry)
477  {
479  iHitTestResult = SendMessageW(child, TB_HITTEST, 0, (LPARAM) &pt);
480 
481  if (iHitTestResult >= 0)
482  {
483  TRACE("MouseUp send %d\n", iHitTestResult);
484  entry->mb->_MenuBarMouseUp(child, iHitTestResult, isLButton);
485  }
486  }
487 
488  return TRUE;
489 }
#define TB_HITTEST
Definition: commctrl.h:1264
#define TRUE
Definition: types.h:120
StackEntry * m_current
#define pt(x, y)
Definition: drawing.c:79
static HWND child
Definition: cursoricon.c:298
HWND WINAPI GetCapture(void)
Definition: message.c:2879
HRESULT IsTrackedWindow(HWND hWnd, StackEntry **pentry=NULL)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:59
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI WindowFromPoint(_In_ POINT)
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)

Referenced by GetMsgHook().

◆ PushMenuBar()

HRESULT CMenuFocusManager::PushMenuBar ( CMenuBand mb)

Definition at line 861 of file CMenuFocusManager.cpp.

862 {
863  TRACE("PushMenuBar %p\n", mb);
864 
865  mb->AddRef();
866 
867  _ASSERT(m_bandCount == 0);
868 
870  if (FAILED_UNEXPECTEDLY(hr))
871  return hr;
872 
873  return UpdateFocus();
874 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT PushToArray(StackEntryType type, CMenuBand *mb, HMENU hmenu)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define _ASSERT(x)
ULONG AddRef()

Referenced by CMenuBand::ShowDW().

◆ PushMenuPopup()

HRESULT CMenuFocusManager::PushMenuPopup ( CMenuBand mb)

Definition at line 877 of file CMenuFocusManager.cpp.

878 {
879  TRACE("PushTrackedPopup %p\n", mb);
880 
881  mb->AddRef();
882 
884 
886  if (FAILED_UNEXPECTEDLY(hr))
887  return hr;
888 
889  hr = UpdateFocus();
890 
891  m_menuDepth++;
892 
894  {
895  m_parent->mb->_SetChildBand(mb);
896  mb->_SetParentBand(m_parent->mb);
897  }
898 
899  return hr;
900 }
StackEntry * m_current
StackEntry * m_parent
HRESULT hr
Definition: shlfolder.c:183
HRESULT PushToArray(StackEntryType type, CMenuBand *mb, HMENU hmenu)
smooth NULL
Definition: ftsmooth.c:416
HRESULT _SetChildBand(CMenuBand *child)
Definition: CMenuBand.cpp:603
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define _ASSERT(x)
ULONG AddRef()
HRESULT _SetParentBand(CMenuBand *parent)
Definition: CMenuBand.cpp:614

Referenced by CMenuBand::ShowDW().

◆ PushToArray()

HRESULT CMenuFocusManager::PushToArray ( StackEntryType  type,
CMenuBand mb,
HMENU  hmenu 
)
private

Definition at line 139 of file CMenuFocusManager.cpp.

140 {
141  if (m_bandCount >= MAX_RECURSE)
142  return E_OUTOFMEMORY;
143 
145  m_bandStack[m_bandCount].mb = mb;
147  m_bandCount++;
148 
149  return S_OK;
150 }
static HMENU hmenu
Definition: win.c:66
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define MAX_RECURSE
#define S_OK
Definition: intsafe.h:59
StackEntry m_bandStack[MAX_RECURSE]

Referenced by PushMenuBar(), PushMenuPopup(), and PushTrackedPopup().

◆ PushTrackedPopup()

HRESULT CMenuFocusManager::PushTrackedPopup ( HMENU  popup)

Definition at line 903 of file CMenuFocusManager.cpp.

904 {
905  TRACE("PushTrackedPopup %p\n", popup);
906 
907  _ASSERT(m_bandCount > 0);
909 
911  if (FAILED_UNEXPECTEDLY(hr))
912  return hr;
913 
914  TRACE("PushTrackedPopup %p\n", popup);
915  m_selectedMenu = popup;
916  m_selectedItem = -1;
918 
919  return UpdateFocus();
920 }
StackEntry * m_current
HRESULT hr
Definition: shlfolder.c:183
HRESULT PushToArray(StackEntryType type, CMenuBand *mb, HMENU hmenu)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define _ASSERT(x)

Referenced by CMenuBand::_TrackContextMenu(), and CMenuBand::_TrackSubMenu().

◆ ReleaseManager()

void CMenuFocusManager::ReleaseManager ( CMenuFocusManager obj)
static

Definition at line 121 of file CMenuFocusManager.cpp.

122 {
123  if (!obj->Release())
124  {
126  }
127 }
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1264
smooth NULL
Definition: ftsmooth.c:416
static DWORD TlsIndex

Referenced by CMenuBand::~CMenuBand().

◆ RemoveHooks()

HRESULT CMenuFocusManager::RemoveHooks ( )
private

Definition at line 694 of file CMenuFocusManager.cpp.

695 {
696  if (m_hMsgFilterHook)
697  {
698  TRACE("Removing MSGFILTER hook...\n");
701  }
702  if (m_hGetMsgHook)
703  {
704  TRACE("Removing GETMESSAGE hook...\n");
707  }
708  return S_OK;
709 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define S_OK
Definition: intsafe.h:59

Referenced by UpdateFocus().

◆ s_GetMsgHook()

LRESULT CALLBACK CMenuFocusManager::s_GetMsgHook ( INT  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

Definition at line 134 of file CMenuFocusManager.cpp.

135 {
136  return GetManager()->GetMsgHook(nCode, wParam, lParam);
137 }
WPARAM wParam
Definition: combotst.c:138
LRESULT GetMsgHook(INT nCode, WPARAM wParam, LPARAM lParam)
static CMenuFocusManager * GetManager()
LPARAM lParam
Definition: combotst.c:139

Referenced by PlaceHooks().

◆ s_MsgFilterHook()

LRESULT CALLBACK CMenuFocusManager::s_MsgFilterHook ( INT  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

Definition at line 129 of file CMenuFocusManager.cpp.

130 {
131  return GetManager()->MsgFilterHook(nCode, wParam, lParam);
132 }
WPARAM wParam
Definition: combotst.c:138
LRESULT MsgFilterHook(INT nCode, WPARAM wParam, LPARAM lParam)
static CMenuFocusManager * GetManager()
LPARAM lParam
Definition: combotst.c:139

Referenced by PlaceHooks().

◆ SetMenuCapture()

void CMenuFocusManager::SetMenuCapture ( HWND  child)
private

Definition at line 237 of file CMenuFocusManager.cpp.

238 {
239  if (m_captureHwnd != child)
240  {
241  if (child)
242  {
245  TRACE("Capturing %p\n", child);
246  }
247  else
248  {
251  TRACE("Capture is now off\n");
252  }
253 
254  }
255 }
static HWND child
Definition: cursoricon.c:298
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HWND WINAPI SetCapture(_In_ HWND hWnd)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888

Referenced by UpdateFocus().

◆ UpdateFocus()

HRESULT CMenuFocusManager::UpdateFocus ( )
private

Definition at line 712 of file CMenuFocusManager.cpp.

713 {
714  HRESULT hr;
715  StackEntry * old = m_current;
716 
717  TRACE("UpdateFocus\n");
718 
719  // Assign the new current item
720  if (m_bandCount > 0)
722  else
723  m_current = NULL;
724 
725  // Remove the menu capture if necesary
727  {
729  if (old && old->type == MenuPopupEntry && m_PreviousForeground)
730  {
733  }
734  }
735 
736  // Obtain the top-level window for the new active menu
738  {
740  if (FAILED_UNEXPECTEDLY(hr))
741  return hr;
742  }
743 
744  // Refresh the parent pointer
745  if (m_bandCount >= 2)
746  {
747  m_parent = &(m_bandStack[m_bandCount - 2]);
749  }
750  else
751  {
752  m_parent = NULL;
753  }
754 
755  // Refresh the menubar pointer, if applicable
756  if (m_bandCount >= 1 && m_bandStack[0].type == MenuBarEntry)
757  {
758  m_menuBar = &(m_bandStack[0]);
759  }
760  else
761  {
762  m_menuBar = NULL;
763  }
764 
765  // Remove the old hooks if the menu type changed, or we don't have a menu anymore
766  if (old && (!m_current || old->type != m_current->type))
767  {
769  {
771  }
772 
773  hr = RemoveHooks();
774  if (FAILED_UNEXPECTEDLY(hr))
775  return hr;
776  }
777 
778  // And place new ones if necessary
779  if (m_current && (!old || old->type != m_current->type))
780  {
781  hr = PlaceHooks();
782  if (FAILED_UNEXPECTEDLY(hr))
783  return hr;
784  }
785 
786  // Give the user a chance to move the mouse to the new menu
787  if (m_parent)
788  {
790  }
791 
793  {
794  if (m_captureHwnd == NULL)
795  {
796  // We need to restore the capture after a non-shell submenu or context menu is shown
797  StackEntry * topMenu = m_bandStack;
798  if (topMenu->type == MenuBarEntry)
799  topMenu++;
800 
801  // Get the top-level window from the top popup
802  CComPtr<IServiceProvider> bandSite;
803  CComPtr<IOleWindow> deskBar;
804  hr = topMenu->mb->GetSite(IID_PPV_ARG(IServiceProvider, &bandSite));
805  if (FAILED(hr))
806  goto NoCapture;
807  hr = bandSite->QueryService(SID_SMenuPopup, IID_PPV_ARG(IOleWindow, &deskBar));
808  if (FAILED(hr))
809  goto NoCapture;
810 
811  CComPtr<IOleWindow> deskBarSite;
812  hr = IUnknown_GetSite(deskBar, IID_PPV_ARG(IOleWindow, &deskBarSite));
813  if (FAILED(hr))
814  goto NoCapture;
815 
816  // FIXME: Find the correct place for this
817  HWND hWndOwner;
818  hr = deskBarSite->GetWindow(&hWndOwner);
819  if (FAILED(hr))
820  goto NoCapture;
821 
823  if (m_PreviousForeground != hWndOwner)
824  ::SetForegroundWindow(hWndOwner);
825  else
827 
828  // Get the HWND of the top-level window
829  HWND hWndSite;
830  hr = deskBar->GetWindow(&hWndSite);
831  if (FAILED(hr))
832  goto NoCapture;
833  SetMenuCapture(hWndSite);
834  }
835 NoCapture:
836 
837  if (!m_parent || m_parent->type == MenuBarEntry)
838  {
839  if (old && old->type == TrackedMenuEntry)
840  {
841  // FIXME: Debugging code, probably not right
842  POINT pt2;
843  RECT rc2;
844  GetCursorPos(&pt2);
845  ScreenToClient(m_current->hwnd, &pt2);
847  if (PtInRect(&rc2, pt2))
849  else
851  }
852  }
853  }
854 
856 
857  return S_OK;
858 }
#define TRUE
Definition: types.h:120
StackEntry * m_current
StackEntry * m_parent
long y
Definition: polytest.cpp:48
HRESULT WINAPI IUnknown_GetSite(LPUNKNOWN lpUnknown, REFIID iid, PVOID *lppSite)
Definition: ordinal.c:2547
HRESULT hr
Definition: shlfolder.c:183
long x
Definition: polytest.cpp:48
HRESULT _GetTopLevelWindow(HWND *topLevel)
Definition: CMenuBand.cpp:874
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define IID_PPV_ARG(Itype, ppType)
#define WM_MOUSELEAVE
Definition: commctrl.h:4971
smooth NULL
Definition: ftsmooth.c:416
StackEntry * m_menuBar
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define _ASSERT(x)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define S_OK
Definition: intsafe.h:59
#define WM_MOUSEMOVE
Definition: winuser.h:1757
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define SendMessage
Definition: winuser.h:5818
void SetMenuCapture(HWND child)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
static const WCHAR rc2[]
Definition: oid.c:1216
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
StackEntry m_bandStack[MAX_RECURSE]
void DisableMouseTrack(HWND parent, BOOL disableThis)

Referenced by PopMenuBar(), PopMenuPopup(), PopTrackedPopup(), PushMenuBar(), PushMenuPopup(), and PushTrackedPopup().

Member Data Documentation

◆ m_bandCount

int CMenuFocusManager::m_bandCount
private

◆ m_bandStack

StackEntry CMenuFocusManager::m_bandStack[MAX_RECURSE]
private

◆ m_captureHwnd

HWND CMenuFocusManager::m_captureHwnd
private

◆ m_current

◆ m_entryUnderMouse

StackEntry* CMenuFocusManager::m_entryUnderMouse
private

Definition at line 74 of file CMenuFocusManager.h.

Referenced by PopMenuBar(), PopMenuPopup(), and ProcessMouseMove().

◆ m_hGetMsgHook

HHOOK CMenuFocusManager::m_hGetMsgHook
private

Definition at line 64 of file CMenuFocusManager.h.

Referenced by GetMsgHook(), PlaceHooks(), and RemoveHooks().

◆ m_hMsgFilterHook

HHOOK CMenuFocusManager::m_hMsgFilterHook
private

Definition at line 63 of file CMenuFocusManager.h.

Referenced by MsgFilterHook(), PlaceHooks(), and RemoveHooks().

◆ m_hwndUnderMouse

HWND CMenuFocusManager::m_hwndUnderMouse
private

Definition at line 73 of file CMenuFocusManager.h.

Referenced by ProcessMouseMove().

◆ m_menuBar

StackEntry* CMenuFocusManager::m_menuBar
private

Definition at line 61 of file CMenuFocusManager.h.

Referenced by GetMsgHook(), MsgFilterHook(), and UpdateFocus().

◆ m_menuDepth

int CMenuFocusManager::m_menuDepth
private

Definition at line 89 of file CMenuFocusManager.h.

Referenced by PopMenuPopup(), and PushMenuPopup().

◆ m_mouseTrackDisabled

BOOL CMenuFocusManager::m_mouseTrackDisabled
private

Definition at line 67 of file CMenuFocusManager.h.

Referenced by DisableMouseTrack().

◆ m_movedSinceDown

BOOL CMenuFocusManager::m_movedSinceDown
private

Definition at line 80 of file CMenuFocusManager.h.

Referenced by ProcessMouseDown(), and ProcessMouseMove().

◆ m_parent

StackEntry* CMenuFocusManager::m_parent
private

Definition at line 60 of file CMenuFocusManager.h.

Referenced by MsgFilterHook(), PushMenuPopup(), and UpdateFocus().

◆ m_PreviousForeground

HWND CMenuFocusManager::m_PreviousForeground
private

Definition at line 83 of file CMenuFocusManager.h.

Referenced by UpdateFocus().

◆ m_ptPrev

POINT CMenuFocusManager::m_ptPrev
private

Definition at line 69 of file CMenuFocusManager.h.

Referenced by CMenuFocusManager(), and ProcessMouseMove().

◆ m_selectedItem

INT CMenuFocusManager::m_selectedItem
private

Definition at line 77 of file CMenuFocusManager.h.

Referenced by MsgFilterHook(), and PushTrackedPopup().

◆ m_selectedItemFlags

DWORD CMenuFocusManager::m_selectedItemFlags
private

Definition at line 78 of file CMenuFocusManager.h.

Referenced by MsgFilterHook(), and PushTrackedPopup().

◆ m_selectedMenu

HMENU CMenuFocusManager::m_selectedMenu
private

Definition at line 76 of file CMenuFocusManager.h.

Referenced by MsgFilterHook(), and PushTrackedPopup().

◆ m_threadId

DWORD CMenuFocusManager::m_threadId
private

Definition at line 65 of file CMenuFocusManager.h.

Referenced by CMenuFocusManager(), and PlaceHooks().

◆ m_windowAtDown

HWND CMenuFocusManager::m_windowAtDown
private

Definition at line 81 of file CMenuFocusManager.h.

Referenced by ProcessMouseDown().

◆ TlsIndex

DWORD CMenuFocusManager::TlsIndex = 0
staticprivate

Definition at line 29 of file CMenuFocusManager.h.

Referenced by AcquireManager(), GetManager(), and ReleaseManager().


The documentation for this class was generated from the following files: