Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get frm.Width & frm.Height when window is maximized

Status
Not open for further replies.

perplexd

Programmer
May 9, 2002
154
US
I'm trying to get the frm.Width and frm.Height properties at run-time, so as I can position my controls on the form. The problem is that I want the form to be maximized on opening (hence I have set the windowstate to maximized), however this does not adjust the .Width and .Height properties.

How can I get these properties for the maximized form or am I going about it in the wrong way?

(Although I am designing on a monitor of 1024x768 pixels, this project will be used on computers with monitors using different numbers of pixels.)
 
perplexed,
This:
---------------------------------------------------------
Private Sub Command1_Click()
Me.WindowState = vbMaximized
MsgBox Me.Width
End Sub

Private Sub Form_Load()
MsgBox Me.Width
End Sub
---------------------------------------------------------

Verifies that the .width always reflects the width of form regardless of the windowstate. Also look into .scalewidth & .scaleheight which are the correct measures to use when scaling/positioning the controls.
How did you come to the conclusing that .width does not adjust when changing the .windowstate?
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
In the form_load procedure I had the code:
Dim a As Double
a = Me.Width

a would have a value of 13815 all the time...which is the non-maximized design-time width...that's how I came to this conclusion.

Even when I did as you said and inserted Me.WindowState = vbMaximized at run-time, the value of a still remains the same.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top