Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15728

How to set form interior size (ScaleWidth and ScaleHeight) to specific dimensions

$
0
0
Hey

I need to set a form's interior size to specific dimensions.

frm.Width and frm.Height define not only the form's interior but also include window borders and possibly other things, which vary in size, and I don't care about those. frm.ScaleWidth and frm.ScaleHeight define the form's interior and I am interested in programmatically setting the interior size to specific dimensions. Unfortunately both of these properties are read-only.

How can one do that?

One idea I have is to first determine the size of the borders and then to set the form's size to the desired size + borders:
Code:

    reqXPx = 1280
    reqYPx = 768

    borderXTw = frm.Width - frm.ScaleWidth
    borderYTw = frm.Height - frm.ScaleHeight

    frm.Width = pixelsToTwipsH(reqXPx) + borderXTw
    frm.Height = pixelsToTwipsV(reqYPx) + borderYTw

Is there a better way?

Viewing all articles
Browse latest Browse all 15728

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>