Scrolling a picture box.

D

David D Webb

I am trying to scroll a picture larger than the screen.

I have a form with a panel on it (240H). On this panel, I have a picture
box that is larger than the panel (960H). I have a vertical scroll bar on
the form next to the panel. Changing the scrollbar moves the picture box up
and the panel defines the viewing area:
this.pboxWeekCal.Top = -(this.vScrollBar.Value * 40);

Now, I didn't think the picture box would handle the clipping and redrawing
correctly. But I thought it would only have a blank area where the new
region came into view from the scrolling. What is happening though, is the
entire picturebox goes blank by just moving the scrollbar one change value.
Is the default paint event wiping it clear or something like that? Is there
a better way to do this. I have an offscreen bitmap that I can buffer from,
and worse case scenario, I'll redraw the entire viewable region for every
scroll change - in that case I'll just get rid of the picturebox and copy
onto the first panel directly.

Thanks,

Dave

Using Visual Studio 2003 and .NET CF sp2.
 
D

David D Webb

Thanks Alex, that confirms my thoughts on having to double buffer with the
offscreen bitmap and redraw the entire viewable area on each scroll
movement. Would a custom control work any faster than just using a panel on
a form? (besides the re-usability factor)

Thanks,
Dave
 
D

David D Webb

Converting my code from the panel in a form to a custom control worked
considerably better. Being able to override the
OnPaintBackground event eliminates the flicker you get in the panel when
scrolling. Double buffering with an offscreen bitmap and clipping the
rectangle to update the viewable area on the OnPaint event of the control
works very smoothly. If anyone ever needs a (very rough) control for a
simple Pocket Outlook type viewer, let me know.

-Dave

spivey@[no spam].post.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top