Make tabpage not process mousewheel events (C#)?

Subclass TabPage and override the WndProc() method to ignore the WM_MOUSEWHEEL message.

Up vote 0 down vote favorite 1 share g+ share fb share tw.

I have made a MDI (tabbed) application that uses PictureBoxes inside TabPages. The picturebox is sometimes larger then the tabpage, so scrollbars appear. It is written in C# using Windows Forms.

Inside my tabpage, I capture and process mouse wheel events in the MouseWheel event (i use it to rotate some objects I draw in the picturebox). But when I have the scrollbars, when I rotate the mouse wheel, my objects rotate, but the tabpage also scrolls down. How can I make the tabpage not process the mousewheel event, and thus make it not scroll down?

I want it to only be scrollable if the user clicks and drags on the scrollbar. C# mousewheel tabpage link|improve this question asked Aug 29 '09 at 10:12Ove186113 84% accept rate.

Subclass TabPage and override the WndProc() method to ignore the WM_MOUSEWHEEL message: public class MyTabPage : TabPage { private const int WM_MOUSEWHEEL = 0x20a; protected override void WndProc(ref Message m) { // ignore WM_MOUSEWHEEL events if (m. Msg == WM_MOUSEWHEEL) { return; } base. WndProc(ref m); } } Then use your MyTabPage subclass in place of the standard TabPage.

Works! Thanks! PS: Is there another way, that wouldn't require me to create another class?

– Ove Aug 29 '09 at 10:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions