Results 1 to 10 of 10

Thread: [Rslvd:Thnx 2 Mendhak,Crptcblade] How do I find the Height of the Titlebar of a Form?

  1. #1

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397

    [Rslvd:Thnx 2 Mendhak,Crptcblade] How do I find the Height of the Titlebar of a Form?

    When placing controls dynamically on a form, I'd like to resize the form to be a certain amount more than the bottom edge of the bottom control placed on the form. However, its the same old problem, the vertical position of a control does not include the height of the titlebar of the form, so saying something like:

    VB Code:
    1. Me.Size = New Size(New Point(Me.Width, mybuttons(255).Bottom + mybuttons(255).Height))

    still cuts off the control array.


    -Lou

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    I think it's a constant of 25. But I don't know what it'd be if you had XP styles in there.

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Try SystemInformation.CaptionHeight
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by crptcblade
    Try SystemInformation.CaptionHeight
    I learn something new every day.

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Not me. I just forget stuff I used to know.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  6. #6

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    Originally posted by mendhak
    I think it's a constant of 25. But I don't know what it'd be if you had XP styles in there.
    Nope! No XP Styles. {Hmmm, Now you've got me thinking about how to do that.}

    However, it seems that 25 is a good guesstimate.

    I don't know why, but you inspired me to check out the "hidden" area of the forms code, came across "clientsize", and so I added the following to my load event:

    VB Code:
    1. MyExtra = Me.Size.Height - Me.ClientSize.Height

    and it turns out Msgboxing MyExtra reveals MyExtra = 27.

    Which perfectly adjusts my forms size to just where I want it.


    -Thanks
    -Lou

  7. #7

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    Originally posted by crptcblade
    Try SystemInformation.CaptionHeight
    Hmmm, it returns 19, a little too small compared to the 27 that MyExtra returns. Must be the height of the Hypothetical Label in the titlebar.

    I'll just file this little tidbit away under "Things that might be handy."

    now, lets see what other nifty little items are in this SystemInformation Dot Popup


    -Lou

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by NotLKH

    However, it seems that 25 is a good guesstimate.
    See that, Joe!! I win!

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by NotLKH
    Nope! No XP Styles. {Hmmm, Now you've got me thinking about how to do that.}

    http://searchvb.techtarget.com/vsnet...293674,00.html

  10. #10
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    Instead of trying to calculate the forms total height, you can just set the ClientSize.

    So if you need a clientheight of e.g. 400, you would normally set it to about 425.

    But instead just set Me.ClientSize=New Size(Me.Width,400)
    Then VB will automatically set the "true" form size accordingly.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

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