Microsoft KB Archive/154820

= FIX: Common Dialog May Not Display the Current Font =

Article ID: 154820

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q154820



SYMPTOMS
When you have set the common dialog controls FontName property, displaying the Font common dialog can result in the selected font being blank.



CAUSE
The problem is caused by setting the FontName property before setting the Flags property. It also occurs when the Flags property has already been set.



RESOLUTION
Set the Flags property to 0 before setting the FontName property. Then set the Flags property to the desired combination of flags after setting the FontName property.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been fixed in Visual Basic 5.0.



Steps to Reproduce Problem
 Start a project in Visual Basic. Form1 is created by default. Place two Command buttons on the form. Place a common dialog control onto the form.  Add the following to the Command1_Click event: Private Sub Command1_Click

'This method will fail CommonDialog1.Flags = cdlCFBoth + cdlCFEffects CommonDialog1.FontName = "MS Sans Serif" CommonDialog1.ShowFont

End Sub   Add the following to the Command2_Click event: Private Sub Command2_Click

'This method will work CommonDialog1.Flags = 0  'Required before setting FontName CommonDialog1.FontName = "MS Sans Serif" CommonDialog1.Flags = cdlCFBoth + cdlCFEffects CommonDialog1.ShowFont

End Sub </li> Choose Start from the Run menu, or press the F5 key to start the program.</li> Click the Command buttons and observe the behavior.</li></ol>

Additional query words: kbVBp400bug kbVBp500fix kbVBp kbdsd kbDSupport kbControl

Keywords: kbbug kbfix KB154820

-

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

© Microsoft Corporation. All rights reserved.