FIX: Painting Problems When FontItalic Set True for Text Box

Last reviewed: October 30, 1997
Article ID: Q94293
2.00 WINDOWS kbprg kbbuglist

The information in this article applies to:

- Microsoft Visual Basic programming system for Windows, version 2.0

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 "More Information" section:

  1. Add a timer (Timer1) to Form1.

  2. Add the following code to the Text1_KeyPress event:

       Sub Text1_KeyPress (KeyAscii As Integer)
          Timer1.Interval = 1
          Timer1.Enabled = True
       End Sub
    
    

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

  4. From the Run menu, choose Start (ALT, R, S).

  5. Enter some text in the Text1 text box. The characters should now

        paint correctly.
    

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.

MORE INFORMATION

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 reference words: buglist2.00 fixlist3.00 2.00 3.00
KBCategory: kbprg kbbuglist
KBSubcategory: PrgCtrlsStd
Solution Type : kbfix


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: October 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.