|
-
Jun 16th, 2009, 06:33 PM
#1
Thread Starter
Member
[RESOLVED] Form Height
Been searching for the easiest way to do this and can not find an answer.
How can I set the form.Height correctly? My code is simple, I have a button at the bottom of my window, which is forced to move down, based on the number of items above it. I want my window/form size to grow along with it. But it is always short.
I know it has to do with the conversion of my form twips to screen pixels.
Form Property:
Scale Mode = Twip
Border = Fixed
Code:
Private Const PADDING = 100
Dim SomeSpace As Long
SomeSpace = 2000
btnOk.Top = SomeSpace
Me.ScaleHeight = (btnOk.Top + btnOk.Height + PADDING) * Screen.TwipsPerPixelY
Me.Refresh
-
Jun 16th, 2009, 06:40 PM
#2
Fanatic Member
Re: Form Height
You set form Height with Form1.Height or FormName.Height , i don't understand your problem, or it is this simple?
-
Jun 16th, 2009, 06:42 PM
#3
Thread Starter
Member
Re: Form Height
Sorry. I am setting the Form1.Height based on how much the most bottom button has moved.
-
Jun 16th, 2009, 06:48 PM
#4
Re: Form Height
This may help you, its based on the size of a data in a label:
Code:
Dim i As Integer
Dim TopOffSet As Long
lblMessage.AutoSize = True
lblMessage.WordWrap = True
lblMessage.Width = Me.ScaleWidth - 500
TopOffSet = Me.Height - Me.ScaleHeight
Dim msg As String
msg = "dsfgsdgfd dgfdsfgdfg dsgdfgdfgg dgdsfgdfgdg sdfsfdfs" & _
"sfsdfsdfsfdf f sfs fsdfdfsdf sdfsdfsdf sfsdfsdf sfsdfsdfs fdshgfhfgh" & _
"dfgdgfsfsafsf af asdsfwr werwerwr bnvbnvbn vbcbcvbcv cvbcvbcbv" & Len(msg)
Me.lblMessage.Caption = msg
Me.Height = lblMessage.Height + 1200 + TopOffSet
Me.Width = Me.Width + lblMessage.Left
cmdOk.Top = Me.ScaleHeight - Me.cmdOk.Height - 100
cmdOk.Left = Me.Width / 2 - cmdOk.Width / 2
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Jun 16th, 2009, 06:57 PM
#5
Thread Starter
Member
Re: Form Height
Hi isnoend07, that won't do exactly what I want.
Me.Height = lblMessage.Height + 1200 + TopOffSet
I need to know exactly how to convert this to the form1.hieght.
SPACE_PADDING = 100
Form1.Hieght = button.Top + button.Bottom + SPACEPADDING
Form1.Height seems to be in a different measurement then the buttons and other controls. Is this true?
-
Jun 16th, 2009, 08:24 PM
#6
Re: Form Height
 Originally Posted by Kruis
Hi isnoend07, that won't do exactly what I want.
Me.Height = lblMessage.Height + 1200 + TopOffSet
I need to know exactly how to convert this to the form1.hieght.
SPACE_PADDING = 100
Form1.Hieght = button.Top + button.Bottom + SPACEPADDING
Form1.Height seems to be in a different measurement then the buttons and other controls. Is this true?
The form can be set to a lot of scales. The default is twips.
Use the ScaleTop, ScaleWidth, ScaleHeight to position controls using these
gives the inside size of your form
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Jun 17th, 2009, 03:27 AM
#7
Re: Form Height
>Form1.Hieght = button.Top + button.Bottom + SPACEPADDING
You are forgetting to include the height of the Form's Caption bar which isnoend07 calls TopOffset in his example so try;
TopOffSet = Me.Height - Me.ScaleHeight
Form1.Hieght = button.Top + button.Bottom + SPACEPADDING + TopOffSet
-
Jun 17th, 2009, 10:18 AM
#8
Thread Starter
Member
Re: Form Height
Thanks Magic Ink, that works perfect. The entire time I thought it was a conversion issue, and here I was missing the title bar.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|