Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / February 2007

Tip: Looking for answers? Try searching our database.

MouseWheel Events

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bern11 - 19 Feb 2007 03:42 GMT
I have an panel containing an image which creates scrollbars if the
image is too large for the panel.  MouseWheel events automatically
scroll the scroll-bars.  How do I intercept the mouse-wheel and make it
perform another function?  I added a delegate mousewheel handler, but
now I get both events (panel scroll plus intended new function).  I want
to switch between functions based on a flag.

I've already sub-classed the panel to gain access to other properties,
should I simply over-ride the mousewheel event and call the base event
based on a flag setting?   Seems kindof the hard way....

PS.  I also just noticed I never set the autoscroll property to true,
but the autoscrollbar behaviour seems to be enabled when I set the
autoscrollminsize property.  Is this supposed to happen or did I just
get lucky and my code might not always work.

PPS.  Why doesn't MouseWheel event show up in the designer?  I had to
type the whole thing in, delegate declaration and all.
Oliver Sturm - 21 Feb 2007 10:27 GMT
Hello bern11,

>I've already sub-classed the panel to gain access to other properties,
>should I simply over-ride the mousewheel event and call the base event
>based on a flag setting?   Seems kindof the hard way....

Well, this seems kind of the right way to me though :-) Hard way? Well,
you're doing something non-standard, so you first have to find a way to
get rid of the standard behaviour, and stealing away the event is often a
good way of doing that.

>PS.  I also just noticed I never set the autoscroll property to true, but
>the autoscrollbar behaviour seems to be enabled when I set the
>autoscrollminsize property.  Is this supposed to happen or did I just get
>lucky and my code might not always work.

Have a look at Reflector - it shows you that the setter for the
AutoScrollMinSize property looks like this:

    set
    {
        if (value != this.userAutoScrollMinSize)
        {
            this.userAutoScrollMinSize = value;
            this.AutoScroll = true;
            base.PerformLayout();
        }
    }

So, it definitely looks like the programmer wanted AutoScroll to be set to
true in this case.

>PPS.  Why doesn't MouseWheel event show up in the designer?  I had to type
>the whole thing in, delegate declaration and all.

Because it's marked [Browsable(false)] on the Control (once more, see
Reflector). Oh, why did they do that? I don't know. Maybe it's a mistake,
or they had a genuine reason not to expose the event - I couldn't find
much useful info about this.

               Oliver Sturm
Signature

http://www.sturmnet.org/blog


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.