esmail (8) [Avatar] Offline
#1
Hi,

I've worked up to chapter 9.

If the image is shown in actual size and the
display window is small we get scroll bars (as
we should). I can scroll the image up/down with
the mouse. I.e. I point at the scroll bar, and click
and drag the bar up/down. However, I don't seem
to be able to do this with my mouse's wheel.

Is this something that will be covered later in
the book, or do I have a bug somewhere? (note,
I am typing in all of the code myself - so that
wouldn't be so unlikely).

Thanks,
Esmail
eebrown (89) [Avatar] Offline
#2
Re: scrolling w/ mouse wheel?
Esmail,

Yeah, just doesn't work. The problem is that the Panel cannot receive focus, and by design will only scroll off the wheel if a contained control has the focus. Since we draw our content by hand, no mouse wheel. The same applies to the other container classes (but not the UserControl class, I believe).

There is a good discussion of this at http://www.dotnet247.com/247reference/msgs/36/180466.aspx. You'll note at the end that if you derive a new control from the Panel class, you can modify its styles and manually set focus to it to enable wheel scrolling.

Erik