R – VB6 Form Height/Width Ignored with Command Line Build

adaptertruncationvb6

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.

Ugh..

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.

Jon

Best Answer

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.

Related Topic