Microsoft KB Archive/132116

= FIX: CheckAutoCenter May Return TRUE with DS_ABSALIGN =

Article ID: 132116

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1 

-



This article was previously published under Q132116



SYMPTOMS
Positioning a dialog box, using DS_ABSALIGN and the Y axis screen coordinate of zero causes the dialog box to be centered within the application's main window.



CAUSE
The function Dialog::CheckAutoCenter is called to determine whether the dialog should be centered. In the case of y == 0, CheckAutoCenter will always return TRUE. This happens because of the following code from CheckAutoCenter in WINCORE.CPP: BOOL bResult = !(lpTemplate->style & DS_ABSALIGN) && lpTemplate->x == 0 || lpTemplate->y == 0; Note that because of the way C/C++ handles logical expressions, if lpTemplate->style == DS_ABSALIGN, then lpTemplate->x == 0 will not be evaluated. However, lpTemplate->y == 0 is evaluated and therefore is capable of returning TRUE to CheckAutoCenter.



RESOLUTION
Do not use a Y coordinate of zero with DS_ABSALIGN.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual C++ 5.0 for Windows.

<div class="moreinformation_section">

MORE INFORMATION
To reproduce this problem set the DS_ABSALIGN style and a y position of zero for the about box of a standard Appwizard-generated application.

Additional query words: center

Keywords: kbbug kbfix kbnoupdate kbuidesign kbvc500fix KB132116

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.