Tutorial :VB6 Form Height/Width Ignored with Command Line Build


We are moving out of VB6 as quickly as we can, but in the meantime we've begun building our VB6 applications from the command line on a Build Server.

Problem: The build server has a basic video adapter and causes the forms to be truncated down to the resolution of the basic adapter rather than the Height and Width in the Form itself.

One workaround that we've discovered requires going into each Form's Load Event and manually setting the Height and Width properties to the observed sizes in the Form Properties window.


There are many dozens of forms involved in this application and more applications with more dozens of forms to come. I want to build a script to handle this.

Two questions:

1) Where in the code/project/etc do I find the Height and Width of the form as shown in the Properties window? A search of the *.frm file doesn't turn up any winners; neither does opeing the *.frx file and converting a known Height or Width to Hex (then searching).

2) Is there something else I can do besides edit each and every form?

Thanks in advance.



The FRM format is documented in the VB6 manual. It says the height and width are stored in Twips, as Angry Jim observed. It doesn't explain about ClientHeight and ClientWidth but as OneNerd and cmsjr have said, that's the size of the interior of the form (without menu bars and borders). The build server may also be changing the ClientLeft and ClientTop, if you have any forms with StartupPosition set to manual.

Don't ever set the Height and Width of the form at run time. Those include the menu bar and borders, which are different thicknesses on different versions of Windows or with different themes. So you'll get the wrong sizes. Set the ScaleHeight and ScaleWidth instead, which are the dimensions of the interior of the form. The VB6 runtime calculates the appropriate Height and Width from those.

And finally, just buy a new build server (or a new video card). Lead all the developers to the boss waving flaming torches and pitchforks, or perhaps just calmly explain the difference between the cost of a PC and the cost of developer time.


If you open the .frm files in notepad or any plain text editor, the form sizes are defined a few lines from the top:

for example:

 ClientHeight    =   8445   ClientLeft      =   60   ClientTop       =   450   ClientWidth     =   9960  

I am not sure why you are encountering the issue - seems strange - but if your build server is causing an issue, then the only options I see are (1) changing your build server (or upgrading the video card perhaps), or writing in the code in the load event for each form as you mention, although that may have an effect on centering of the form if you have the postion->center set in the IDE so verify that your forms are still centered if that is your desired result.


Based on this I would say that the height as seen in the property window is a calculated value that includes the form's ClientHeight (which is in the .frm) + the border and title bar heights. So ClientHeight is probably the number you are looking for.


The height and width are stored in Twips (a device-independent unit of measure), so you have to divide by Screen.TwipsPerPixelX and -Y to get the proper value. For most displays, this will be 15. (Using the width in OneNerd's example, 9960 twips is 664 pixels.)

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »