views:

177

answers:

1

Forms on Windows 7 and Vista have thicker borders than those of XP. As a result, some content that spans the entire height or width of a form will be cut off. Is there a simple way to fix this, or do all the forms of my application need to be resized to accommodate for this?

Update: It appears to be the fault of the form size and not the borders that are causing the problem. See the following images for an example. Notice how the controls have the correct location at the top-right corners, but they reach the each of the form in Windows 7 while a border is retained in XP. The same code is used to resize and position the controls.

Here's what a form looks like in XP: alt text

And here's the same form in Windows 7: alt text

+1  A: 

You should fix the size of the form programatically, to make sure the client size is big enough to fit everything. You can easily calculate the difference between the current size and client size of the form, and increase/decrease by the right amount.

You probably want to perform this inside Form_Load.

In VB6, the client size and width are referred to as ScaleWidth and ScaleHeight for forms. Setting these values just messes up the scaling, rather than resizing the form, so you instead have to do calculations so you can set the normal Width and Height properties.

BorderSize = Me.Width - Me.ScaleWidth
Me.Width = BorderSize + CorrectScaleWidth
//Same for height!
KernelJ
I know VB.Net has a ClientSize property. Is there an equivalent for VB6? I can't seem to find it.
Everett
Yes, but you can't set the value of it, you have to calculate the size of the border, and set the normal size properties. Edited solution into the answer.
KernelJ