PRB: RoundRect() and Ellipse() Don't Match Same Shaped Regions

ID: Q119455

3.10 4.00 | 3.10 3.50 3.51 WINDOWS | WINDOWS NT kbgraphic kbprb
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) 3.1
  • Microsoft Win32 Application Programming Interface (API), used with:
    • Microsoft Windows NT, versions 3.5, 3.51, 4.0
    • Microsoft Windows 95


SYMPTOMS

When CreateRoundRectrRgn() is used to create a region with the shape of a rectangle that has rounded corners and RoundRect() is called with the same parameters to draw the same rectangle that has rounded corners, the calculated region does not match the drawn rectangle. The same can be said of the ellipses created by CreateEllipticRgn() and Ellipse().


CAUSE

This behavior is because of the design on Windows. The mismatch between fills and frames is because of the way that the boundaries and fills must be specified in order to get polygons to fit together properly. Windows NT duplicates this behavior for compatibility.


RESOLUTION

Perform the fill first, then draw the frame. Some of the frame pixels will overwrite fill pixels and some will not; however, there will be no gap between the frame and the fill, and the fill will not extend past the frame. Use CreateRoundRectRgn() or CreateEllipticRgn() for the fill and RoundRect() or Ellipse, respectively, for the frame. Use the same parameters for both the region API and the filled-shape API.

NOTE: If you use a NULL pen when drawing the filled shape, the pixels will match those drawn by creating a region through the corresponding region API and then calling FillRgn() with the same parameters. It draws the frame with the pen from the filled-shape API that causes the discrepancy.


STATUS

This behavior is by design.

Additional query words: 3.10 4.00

Keywords : kbNTOS350 kbNTOS351 kbNTOS400 kbSDKWin32 kbWinOS95
Version : WINDOWS:3.1,95; winnt:3.5,3.51,4.0
Platform : WINDOWS winnt
Issue type : kbprb


Last Reviewed: June 16, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.