AutoScrollPosition reset to 0, 0 after dialog on top of form close

G

Guest

I have a main form (AutoScroll = false) that contains a panel (AutoScroll =
true) that contains a custom control that has its own OnPaint and draws
images on to the control form. The panel fits within the dimensions of the
main form while the custom control is larger than the panel. Everything seems
to work fine as far as displaying the scrollable area until any other dialog
is closed. The x,y coordinates of the ClientRectangle of the custom control
are reset to 0,0 when any other dialog withing the system close, thus the
scrollable region is repositioned. The same does not happen as the dialog is
being moved on top of the image being drawn or when other custom painting on
the customer control takes place. The issue here is that I don't want the
scrollable area to be repositioned when another form is closed. Is there
something obvious that I am missing on why the coordinates of the
CLientRectange are being reset to 0,0?
 
G

Guest

I wanted to clarify my problem. I have a form with AutoScroll = false, a
panel contained in the form with AutoScroll = true and then a custom control
which inherits from UserControl that actually does all the painting and uses
DrawImage(bitmap, e.ClipRectange, e.ClipRectangle.X, e.ClipRectangle.Y,
e.ClipRectangle.Width, e.ClipRectangle.Height, GraphicsUnit.Pixel); The
custom control’s OnPaint() does not know anything about scrolling. I can set
the Panel’s AutoScrollPosition and then force the custom control to refresh
and the image is positioned appropriately. Then using the scroll bars also
works fine. The problem is that when another dialog is loaded on top of the
image and then closed the panel’s AutoScrollPosition is reset to 0,0, i.e.
the custom control’s e.ClipRectangle.X and e.ClipRectangle.Y are both 0 in
OnPaint(). The bottom line is that the custom control handles all the
painting and does not know anything about AutoScroll. Is there a way to work
around this issue so that when a dialog closes that the image drawn by the
custom control will remain positioned its previous AutoScrollPosition? Or is
there a fundamental problem that the custom control does all the painting
while the only reason for the panel is to allow scrolling? I have seen other
posts discussing using transform and/or the AutoScrollPosition property when
drawing the image, but in my case that information is not available at the
time when the custom control’s OnPaint is active.
 
G

Guest

I did not get an answer to my post, I ended up rewriting the custom control
and not using the scrolling ability of the panel. I handled all the paint
issues within the custom control's OnPaint routine. Sorry that I cannot be
more helpful on this issue.
 

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