codebrothers.net :: Home  >  Matthias Denkmaier
User: Guest  Login
Matthias Denkmaier
C# - what else?
Blog search:  
Howto: Handle MouseWheel messages (WM_MOUSEWHEEL) manually

Today i had to manually handle the mouse wheel functionality in a customer project and suppress the raising of the MouseWheel event as long as a specific condition returned false.

After some research i found a fairly simple solution:

 

public const int WM_MOUSEWHEEL = 0×020A;
 
protected override void WndProc(ref Message m) 
{
     if (m.HWnd != this.Handle)       
     {            
            return;       
     } 
 
      switch (m.Msg)    
      {           
            case Win32Messages.WM_MOUSEWHEEL:
                  if( ! <your condition goes here> )
                  {
                         return;  
                  }               
                  break;           
            default:               
                  break;       
      }
      base.WndProc(ref m);  
}
 
 

Hope this helps!

 

Share this post: Email it!
Posted:  1/25/2008 7:58:00 AM  by  mdenkmaier
Tags:  How toC#Development
Comments are not allowed on this item!