PC Review


Reply
Thread Tools Rate Thread

MouseWheel Events

 
 
bern11
Guest
Posts: n/a
 
      19th Feb 2007
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.
 
Reply With Quote
 
 
 
 
Oliver Sturm
Guest
Posts: n/a
 
      21st Feb 2007
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
--
http://www.sturmnet.org/blog
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MouseWheel =?Utf-8?B?UHJpbmNl?= Microsoft Access Form Coding 11 17th Oct 2006 07:18 PM
mousewheel events =?Utf-8?B?c2FtbWFydGlu?= Microsoft Dot NET Framework 1 10th Oct 2006 07:16 PM
Using the mousewheel Jean Paul Mertens Microsoft Dot NET Framework Forms 1 28th Jul 2006 06:22 PM
How do I enable a Panel to recieve MouseWheel events? Robin Tucker Microsoft VB .NET 2 20th Jul 2004 02:55 PM
MouseWheel Todd Microsoft Access 6 3rd Dec 2003 12:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:22 PM.