Microsoft KB Archive/94293

= FIX: Painting Problems When FontItalic Set True for Text Box =

Article ID: 94293

Article Last Modified on 1/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition

-



This article was previously published under Q94293



SYMPTOMS
When you use a text box for input in a program, you will encounter painting problems when the FontItalic property is set to True.



CAUSE
This problem is because of spacing. Italic fonts take up more room for each character entered, but the text box does not account for this. The problem occurs only when you type text into the text box. If you assign text to the Text property at run-time, the problem does not occur.



WORKAROUND
To work around the problem, use the Refresh method to refresh the text box each time a character is pressed. For best results, you should enable a timer from within the KeyPress event for the text box. From within the timer event, you can then use the Refresh method to refresh the contents of the text box.

For example, you can work around the problem by adding the following steps to those listed in the &quot;More Information&quot; section:

 Add a timer (Timer1) to Form1.  Add the following code to the Text1_KeyPress event: Sub Text1_KeyPress (KeyAscii As Integer) Timer1.Interval = 1 Timer1.Enabled = True End Sub   Add the following code to the Timer1_Timer event for Timer1. Sub Timer1_Timer Text1.Refresh

'Disable the timer since you do not want the timer event 'to be continually executed Timer1.Enabled = False

End Sub  From the Run menu, choose Start (ALT, R, S). Enter some text in the Text1 text box. The characters should now paint correctly.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in Microsoft Visual Basic version 2.0 for Windows. This problem was corrected in Microsoft Visual Basic version 3.0 for Windows.

<div class="moreinformation_section">

Steps to Reproduce Problem

 * 1) Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.
 * 2) Add a text box (Text1) to Form1.
 * 3) Set the FontItalic property to True in the Properties Window.
 * 4) From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program.
 * 5) Type ffff (4 f characters) in Text1.

Notice that when you press a character, the previous character does not paint correctly. For example, in the case of using the letter f, only the bottom half of the character paints.

Additional query words: buglist2.00 fixlist3.00 2.00 3.00

Keywords: kbbug kbfix KB94293

-

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

© Microsoft Corporation. All rights reserved.