HOWTO: How to Get Smallest Bounding Rectangle for Drawing Functions (139217)
The information in this article applies to:
- Microsoft Win32 Application Programming Interface (API), when used with:
- Microsoft Windows NT Server 3.5
- Microsoft Windows NT Server 3.51
- Microsoft Windows NT Server 4.0
- Microsoft Windows NT Workstation 3.5
- Microsoft Windows NT Workstation 3.51
- Microsoft Windows NT Workstation 4.0
This article was previously published under Q139217 SUMMARY
Windows maintains an accumulated bounding rectangle for each application.
An application can retrieve this bounding rectangle by calling
GetBoundsRect, and it can set this rectangle by calling SetBoundsRect. But
this rectangle may not be the smallest bounding rectangle if your drawing
functions contain functions doing text output such as TextOut. GDI does not
calculate ahead of time how far across the TextOut functions are going to draw. GDI just sets the right side of the bounding rectangle to a large number.
MORE INFORMATION
To get an accurate and smallest bounding rectangle, call LockWindowUpdate
and pass the handle of the window to which you are going to draw. Then
Windows records the extent of any attempted operations in a bounding
rectangle without doing the actual drawing. When the window is unlocked by
LockWindowUpdate(NULL), you can either use GetUpdateRect or intercept the
rcPaint member of the PAINTSTRUCT in your WM_PAINT message handler to
retrieve this smallest bounding rectangle.
Modification Type: | Major | Last Reviewed: | 12/1/2003 |
---|
Keywords: | kbhowto KB139217 |
---|
|