PRB: InvalidateRect() Yields Empty Update Region on Win95

Last reviewed: March 19, 1998
Article ID: Q180330
The information in this article applies to:
  • The Microsoft Foundation Classes (MFC) included with: - Microsoft Visual C++, 32-bit Editions, version 5.0

SYMPTOMS

The 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.

CAUSE

InvalidateRect(), 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().

RESOLUTION

You 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.

STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

A 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
Keywords : MfcUI
Technology : kbMFC
Version : win95:5.0;winnt:5.0
Platform : Win95 winnt
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 19, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.