WinXP and height of a window

I made a program using VB6 on windows 95. The program resizes its self at one point, which works fine. However when I used it on an XP machine, the window was chopping of some bits at the bottom of my form. I presume this is due to the big chunky title bar WinXP has - although the form is being resized to the correct size, the useable area is smaller since the title bar takes up more room. I would like to make the form the right size no matter what the size of the title bar is. Any help would be great.
Thanks
Benoni

Comments

  • : I made a program using VB6 on windows 95. The program resizes its self at one point, which works fine. However when I used it on an XP machine, the window was chopping of some bits at the bottom of my form. I presume this is due to the big chunky title bar WinXP has - although the form is being resized to the correct size, the useable area is smaller since the title bar takes up more room. I would like to make the form the right size no matter what the size of the title bar is. Any help would be great.
    : Thanks
    : Benoni
    :

    So you need to adjust for the width/height of the border and caption?

    You can calculate the border width by getting half of the difference between the form's total size and it's inner size.

    [code]Border = (Me.Width - Me.ScaleWidth) / 2
    [/code]

    You can then get the height of the caption bar by subtracting the border's height (top and bottom) and the form's inner height from the form's total height.

    [code]CaptionHeight = Me.Height - Border * 2 - Me.ScaleHeight
    [/code]

    Finally, to get a specific inner size, you add the height you want to the caption bar height and top and bottom borders, and the width to the side borders.

    You'll also need to make sure that the form's .ScaleMode property is in Twips so it matches the screen.

    Here's a public subroutine you can use:

    [code]Public Sub InnerSize(frm As Form, ByVal X As Long, ByVal Y As Long)

    Dim OldScale As Long 'ScaleModeConstants?
    Dim Border As Long
    Dim CaptionHeight As Long
    'Store the old scalemode
    OldScale = frm.ScaleMode
    'modify form's scalemode
    frm.ScaleMode = vbTwips
    'Get the border's size
    Border = (frm.Width - frm.ScaleWidth) / 2
    'Get the caption's height:
    CaptionHeight = frm.Height - Border * 2 - frm.ScaleHeight
    'Change the form's width and height
    frm.Move frm.Left, frm.Top, X + Border * 2, _
    Y + Border * 2 + CaptionHeight
    'Restore the old ScaleMode
    frm.ScaleMode = OldScale

    End Sub
    [/code]

    The size must be passed in twips because I don't know how to convert anything other than pixels. Here's how you can use it:

    [code]InnerSize Me, 12000, 9000
    [/code]

    That should give you an inner region of 800x600.

    Hope this helps!
    KDL
  • Thanks.
    I've got that to work. Really simple - I should have been able to think of that. Duh, duh, duh.
    Thanks again
    Benoni
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories