|
Question : Drawing and Scolling in Windows C# - ClientRectangle? Paint?
|
|
I have some issues understanding the interaction of drawing Your own control and scrolling.
firt of all: is the ClientRectangle the whole inner Rectangle of the control, wether it is screend at the moment or it is not? Or is the ClientRectangle just the visible area, when other areas are invisible because of the scolling?
Further I wonder if I had to adapt the paint method to the really visible area or can I draw my control as usual in the paint method, even when only a part of it will be screend due to scrolling?
Hope my Problem is understandable
|
|
Answer : Drawing and Scolling in Windows C# - ClientRectangle? Paint?
|
|
The ClientRectangle is a rectangle that encloses the entire control, regardless if it is clipped, visible, scrolled, or even drawn.
If your container (window or panel) does not scroll, you can just draw all your controls in your Paint method without regard to their size or position. However, if your content requires any significant processing to generate, you will be better off calculating the clipped and visible regions and only drawing portions of the controls inside that.
If your container does scroll you will have to calculate the position of each control inside the content area, based on the scrolled position, then clip the drawing so only the portion inside the scrolled area is drawn.
An introduction to drawing scrolled controls is at http://www.codeproject.com/KB/books/1861004990.aspx.
|
|
|
|