PRB: InvalidateRect() Yields Empty Update Region on Win95Last reviewed: March 19, 1998Article ID: Q180330 |
The information in this article applies to:
SYMPTOMSThe Win32 InvalidateRect() function, or the MFC function with the same name, does not invalidate any region on Windows 95, even though the function's return value is nonzero. A call to GetUpdateRect() afterwards returns a null rectangle, as well as a return value of zero. The same code works correctly on Windows NT 4.0.
CAUSEInvalidateRect(), or the MFC function that wraps it, behaves differently depending on whether you use it on Windows 95 or Windows NT 4.0. On Windows NT 4.0, InvalidateRect() will accept a pointer to a non-normalized RECT and invalidate a region as if the RECT were normalized. Windows 95 requires that the RECT be normalized to use it successfully with InvalidateRect().
RESOLUTIONYou can normalize the RECT yourself, or use the MFC function CRect::NormalizeRect() on the RECT whose pointer you are passing to InvalidateRect(). To normalize a RECT, you must compare the top and bottom values, and swap them if the top is greater than the bottom. In addition, you must swap the left and right values if the left is greater than the right.
STATUSMicrosoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONA non-normalized rectangle can often be produced unintentionally if you use mapping modes other than MM_TEXT. MM_HIENGLISH, MM_LOENGLISH, MM_HIMETRIC, MM_LOMETRIC, and MM_TWIPS cause the y-axis to have the reverse direction of that for the default mapping mode (MM_TEXT). This can result in non- normalized RECTs. In addition, you can set up the two "custom" mapping modes (MM_ISOTROPIC and MM_ANISOTROPIC) so that either the y-axis or x- axis, or both, are reversed from that in MM_TEXT. You can produce non- normalized RECTs by using functions such as LPtoDP or DPtoLP when using a mapping mode other than the default. Please also note that InvalidateRect uses client area device coordinates, not logical coordinates. This is by design.
|
Additional query words: Invalid Update
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |