Apparently, we can solve this problem in the center of the program. Look at your code for the message loop that should be in your WinMain method:
while (GetMessage (&msg, NULL, 0, 0) > 0)
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
Here we just need to say that if the message is a WM_MOUSEWHEEL message, which we want to transfer to the window under the mouse, and not in the focus window:
POINT mouse;
while (GetMessage (&msg, NULL, 0, 0) > 0)
{
if (msg.message != WM_MOUSEWHEEL)
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
else
{
GetCursorPos (&mouse);
msg.hwnd = WindowFromPoint (mouse);
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
And now in the window under the mouse scrolls will always appear, rather than a focused window.
source
share