winapi - WM_MOUSEHOVER in a global hook -
I have implemented custom tooltips for some controls in my application (MFC) but I want to make it normal for everyone Control.
I am currently calling TrackMouseEvent in WM_MOUSEMOVE
and then holding WM_MOUSEHOVER
(both overwrite function window-off control). But in this way I would have to duplicate the code for every control, so my intention was to set a global hook for the events of the mouse and ask the control to display the message in the tooltip.
The problem is that I am not able to capture
WM_MOUSEHOVER
in a global hook, this code is:
hMouseHook = SetWindowsHookEx (WH_MOUSE, CallWandMouseProc, NULL, AfxGetThread () - & gt; m_nThreadID); HMainHook = SetWindowsHookEx (WH_CALLWNDPROC, CallWindProc, NULL, AfxgetThread () -> M_nThreadID); LRESULT Callback CallWandMouseProc (Int nCode, WPARAM wParam, LPARAM lParam) {if (nCode == HC_ACTION) {MOUSEHOOKSTRUCT * pwp = (MOUSEHOOKSTRUCT *) lParam; Trace (_T ("Message:% x hwnd:% xx:% dy:% d \ n"), wParam, pwp-> hwnd, pwp- & gt; pt.x, pwp-> pt.y ); TrackMobileEvent Event Track; EventTrack.cbSize = sizeof (TRACKMOUSEEVENT); EventTrack.dwFlags = TME_HOVER; EventTrack.dwHoverTime = HOVER_DEFAULT; EventTrack.hwndTrack = pwp- & gt; HWD; _TrackMouseEvent (& amp; eventTrack); If (WPARM == WM_MOUSEHOVER) {AFFESSEBox (_T ("CallWindMos Speaker: WM_MOUSEHOVER")); }} // Let the message next to come through the call through the callEXXHX (HMIIX, Encoded, WPAMM, LPAMM); } LRESULT Callback CallWindProc (Int nCode, WPARAM wParam, LPARAM lParam) {if (nCode == HC_ACTION) {CWPSTRUCT * pData = (CWPSTRUCT *) lParam; If (pData-> Message == WM_MOUSEHOVER) {FIX Message Box (_T ("CallWindPro: WM_MOUSEHOVER")); }} / / Let's go through the message to call next hook CallNextHookEx (hMainHook, ncode, wParam, lParam); }
Both hooks are being called for the rest of the message and I'm sure that WM_MOUSEHOVER
is being sent because this window capture function is captured in. For example, this is a custom window function for CListBox:
LRESULT CMyListBox :: WindowProc (UINT message, WPARAM wParam, LPARAM lParam) {if (message == WM_MOUSEHOVER) {AfxMessageBox (_T ("Window type: WM_MOUSEHOVER")); } Return CListBox :: WindowProc (Message, wParam, lParam); }
OK, so am I missing? Is not it possible to capture this message in a global hook?
Thank you.
Javier
WM_MOUSEHOVER is posted in the message queue of the thread, so You will not see it with WH_CALLWNDPROC (which is for messages sent). WH_MOUSE posts a message, so I find it a little weird that you are not seeing it ... Maybe hook only gets low level mouse input messages? Try the WH_GETMESSAGE hook.
Comments
Post a Comment