|
-
September 1st, 2009, 02:30 AM
#1
WH_MOUSE_LL hook freezes on title bar buttons
I have an application which has a hook on the mouse using WH_MOUSE_LL.
Code:
HMouseHook = SetWindowsHookEx(WH_MOUSE_LL,
(HOOKPROC)MouseMsgHook,
pApp->m_hInstance,
0);
static LRESULT CALLBACK MouseMsgHook(UINT nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode == HC_ACTION)
{
CWnd* pFrame = AfxGetMainWnd();
if ( pFrame )
{
PostMessage(pFrame->m_hWnd, UWM_MOUSEMOVE, 0, 0);
}
}
return CallNextHookEx(HMouseHook, nCode, wParam, lParam);
}
Overall it works quite well except for one thing. When I click on the title bar buttons of the applications that uses the hook, every thing seems to freeze for several seconds (it goes from barely visible on some PCs, not necessarily the fastest PCs, to 10 seconds).
By freezing, I mean the mouse is not moving, the clock or the task manager are not refreshing, ... And I have added traces that prove that the message takes that much time to get into the callback method, so it is the processing of the message to that callback that seem slow.
On the other hand, if I minimise or restore the application by clicking in the Windows task bar, or use the context menu from the title bar of the application, it works instantly. Any other click, anywhere else in the application or outside of it is processed instantly.
I have added a piece of code that write the time the message come in right of after "if (nCode == HC_ACTION)" and it does come up to 10 seconds after the actual click.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|