O'Reilly logo

Application Development Using Visual Basic® and .NET by Dana L. Wyatt, Peter Thorsteinson, Robert J. Oberg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Clipping Rectangle

Our drawing code up until now has been straightforward, but it is not as efficient as it could be. In OnPaint we always redraw the entire client rectangle, whether it is necessary or not. The PaintEventArg argument that is passed to OnPaint and to paint event handlers contains a property ClipRectangle, which indicates the rectangle in which to paint. By paying attention to this clipping rectangle, you can make your painting code more efficient.

There are two ways in which the clipping rectangle can be set. The first is by the system—for example, when part of a window is obscured by another window and then uncovered. The second is by the program through a call to the Invalidate method of the Control class. This method has several ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required