Sign in to follow this  
maya18222

Child windows not recieving WM_MOUSEWHEEL

Recommended Posts

I have a Parent window, with multiple child windows created with WM_CHILD. And for some reason, these windows will recieve other messages in their procedure like case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MOUSEMOVE: perfectly fine, but they wont recieve WM_MOUSEWHEEL, when i scroll the mouse in thier client area, instead it gets sent to the parent windows procedure. According to MSDN, this logic is the correct behaviour. "The WM_MOUSEWHEEL message is sent to the focus window when the mouse wheel is rotated. The DefWindowProc function propagates the message to the window's parent. There should be no internal forwarding of the message, since DefWindowProc propagates it up the parent chain until it finds a window that processes it." So, now my question is, how do i get the child windows procedures to recieve this message, when i move the mouse wheel in their client area? If the message gets sent to the parent, I guess i have to forward it back to the child, but the WM_MOUSEWHEEL doesnt seem to come with any infomation as to work out the window that the mouse was actually scrolled in.

Share this post


Link to post
Share on other sites
It goes to the window which currently has focus, so if your child window has focus it should get the message - is that what you're seeing?

Handling of the mouse wheel is rather hap-hazard in terms of behaviour, so it's up to you what you want to do, I guess. For example, Firefox scrolls whatever the mouse is hovering over, Explorer scrolls whatever currently has focus, Microsoft Word scrolls whatever the mouse is hovering over, etc.

To get the "scroll whatever the mouse is hovering over" behaviour, you should catch the WM_MOUSEWHEEL message in your parent's WndProc, then use ChildWindowFromPoint (coupled with GetCursorPos) to get the window the mouse is over.

Share this post


Link to post
Share on other sites
ah yes, im looking for the behaviour of "Send SCROLLMESSAGE to window under mouse" what ever that window maybe.

I shall try what you mentioned, cheers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this