显然,我们可以在该计划的核心问题上解决这个问题.查看消息循环的代码,该代码应该在WinMain方法中:
while (GetMessage (&msg, NULL, 0, 0) > 0)
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
Run Code Online (Sandbox Code Playgroud)
在这里,我们只需要说如果消息是WM_MOUSEWHEEL消息,我们想将它传递给鼠标下的窗口,而不是焦点窗口:
POINT mouse;
while (GetMessage (&msg, NULL, 0, 0) > 0)
{
//Any other message.
if (msg.message != WM_MOUSEWHEEL)
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
//Send the message to the window over which the mouse is hovering.
else
{
GetCursorPos (&mouse);
msg.hwnd = WindowFromPoint (mouse);
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,鼠标下的窗口将始终获得滚动消息,而不是聚焦窗口.
| 归档时间: |
|
| 查看次数: |
2448 次 |
| 最近记录: |