Jump to content
  • Advertisement
Sign in to follow this  
SiS-Shadowman

WM_MOUSEHWEEL messages not generated

This topic is 3630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is really driving me nuts. I've got a simple plain MFC Dialog-based application and I add a WM_MOUSEWHEEL handler to the dialog, but I can't capture any mouse messages. Is there a way to either get the stupid MFC to work or use some other WIN32/C function to query the mouse wheel status?

Share this post


Link to post
Share on other sites
Advertisement
A little update:

I found out that when I add a TreeControl to a plain dialog, the OnMouseWheel function does not get called (Using ON_WM_MOUSEWHEEL, MFC unfortunately).

Since I was running out of patience, I decided to use a mouse hook instead (MFC is really a mess sometimes).
I'll post the code for others that have the same problem :)


HHOOK mousehkk = NULL;
LRESULT CALLBACK MouseHook( int nCode, WPARAM wParam, LPARAM lParam );

// Somewhere
mousehkk = SetWindowsHookEx( WH_MOUSE, &MouseHook, NULL, GetCurrentThreadId() );
if( !mousehkk )
{
DWORD nCode = GetLastError();
// Deal with the error
}

LRESULT CALLBACK MouseHook( int nCode, WPARAM wParam, LPARAM lParam )
{
if( nCode >= 0 )
{
PMOUSEHOOKSTRUCT pMouseHook = reinterpret_cast<PMOUSEHOOKSTRUCT>( lParam );

switch( wParam )
{
case WM_MOUSEWHEEL:
MOUSEHOOKSTRUCTEX *pMouseHookEX = reinterpret_cast<MOUSEHOOKSTRUCTEX*>( pMouseHook );
short zDelta = static_cast<short>( HIWORD( pMouseHookEX->mouseData ) );
// Now zDelta is a multiple value of 120, although on vista this may not be true anymore (see threads started by alot of annoyed programmers :))
break;
}
}

return CallNextHookEx( mousehkk, nCode, wParam, lParam );
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!