WIDTH Statement in Form_Load Not Set Until After Form_Load

ID: Q90903


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0


SYMPTOMS

If you use a WIDTH statement to change the screen resolution in a Form_Load event procedure, the WIDTH will not take affect until after the Form_Load event procedure has finished.

One result of this behavior is that if you are sizing or moving the form, the size of the form will be set based on the current screen resolution rather than the resolution specified by the WIDTH statement as you might expect.


STATUS

Microsoft has confirmed this to be a bug in Microsoft Visual Basic for MS-DOS, version 1.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


MORE INFORMATION

Steps to Reproduce Problem

  1. Start VBDOS.EXE (you will be in 25-line mode by default).


  2. From the File menu, choose New Form.


  3. From the File menu in FD.EXE, choose Exit, and save the changes.


  4. Add the following code to the Form_Load event procedure:
    
          SUB Form_Load()
             WIDTH, 43
             'SHOW    'Leave this line out for now.
             Form1.Height = 40
          END SUB 


  5. Run the application.


You may expect to see a form 40 lines in height on a screen that is in 43 line mode. Instead, a form 25 lines in height on a screen in 43 line mode is displayed.

This is because the assignment of the Height property of the form was done in the Form_Load event. The setting by the WIDTH statement has not yet been processed, so you are trying to set the Height of the form to 40 lines while still in 25-line mode. This results in the form Height being set to a maximum value of 25 lines.

When the Form_Load event procedure ends, the WIDTH setting is processed and set, so you now get the 43 line mode display, but the form is still only 25 lines in height.

To work around this problem, you can add a SHOW statement just after the WIDTH statement. This will force the form to be shown, then the rest of the code in the Form_Load event will be executed. As a result, the WIDTH statement is processed and the form is displayed in 43 line mode; when the Height is set to 40, it is within the maximum value of 43 for 43-line mode.

For more information about how form height is limited to screen resolution, query on the following words in the Microsoft Knowledge Base:
form and height and width and screen

Additional query words: VBmsdos buglist1.00 1.00

Keywords :
Version : MS-DOS:1.0
Platform : MS-DOS
Issue type :


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