Results 1 to 8 of 8

Thread: [RESOLVED] Form Height

  1. #1

    Thread Starter
    Member
    Join Date
    May 2009
    Location
    Victoria, BC
    Posts
    36

    Resolved [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

  2. #2
    Fanatic Member Dungeon Keeper's Avatar
    Join Date
    Mar 2008
    Posts
    590

    Re: Form Height

    You set form Height with Form1.Height or FormName.Height , i don't understand your problem, or it is this simple?
    No, that wont do!

  3. #3

    Thread Starter
    Member
    Join Date
    May 2009
    Location
    Victoria, BC
    Posts
    36

    Re: Form Height

    Sorry. I am setting the Form1.Height based on how much the most bottom button has moved.

  4. #4
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    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

  5. #5

    Thread Starter
    Member
    Join Date
    May 2009
    Location
    Victoria, BC
    Posts
    36

    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?

  6. #6
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Form Height

    Quote Originally Posted by Kruis View Post
    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

  7. #7
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    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

  8. #8

    Thread Starter
    Member
    Join Date
    May 2009
    Location
    Victoria, BC
    Posts
    36

    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
  •  



Click Here to Expand Forum to Full Width