Results 1 to 5 of 5

Thread: Size of a forms title bar.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Location
    Belfast
    Posts
    28
    Does anybody know an API function that returns the depth of a form's title bar. (with different display settings the depth of the title bar changes).

    If not is there another way to work this out.

    Any help would really be appreciated.

  2. #2
    Guest
    You can calculate it by useing the forms height and width and the scale height en width

    The scale.... gives the size of the client area

    Example:
    Code:
    Private Function FormBorderWidth(ByVal frm As Form) As Long
        'Form width is the complete width of the form
        'Form scalewidth is the width of the client area of the form(the useable area)
        
        'Substracting the scale witdth from the width gives the total width of the _
        'non client area(borders) devide this by 2 to get the width of the individual _
        'borders
        FormBorderWidth = (frm.Width - frm.ScaleWidth) / 2
    End Function
    
    Private Function FormTitlebarHeight(ByVal frm As Form) As Long
        'Height - scaleheight, get total non client height
        'Substract 1 borderwidth (height of the bottom border)
        FormTitlebarHeight = (frm.Height - frm.ScaleHeight) - FormBorderWidth(frm)
    End Function
    Call it like this:
    Debug.Print "Border Width: " & FormBorderWidth(Me)
    Debug.Print "Titlebar Height: " & FormTitlebarHeight(Me)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Location
    Belfast
    Posts
    28
    Thanks Azzmodan

    I will give that a go.


  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    What about different scalemodes? And especially user, it will change from case to case. Well Azzmodan you could have this, it works for all scalemodes
    Code:
    Private Function FormBorderWidth(ByVal frm As Form) As Long
        'Form width is the complete width of the form
        'Form scalewidth is the width of the client area of the form(the useable area)
        
        'Substracting the scale witdth from the width gives the total width of the _
        'non client area(borders) devide this by 2 to get the width of the individual _
        'borders
        FormBorderWidth = (frm.Width - frm.ScaleX(frm.ScaleWidth, frm.ScaleMode, vbTwips)) / 2
    End Function
    
    Private Function FormTitlebarHeight(ByVal frm As Form) As Long
        'Height - scaleheight, get total non client height
        'Substract 1 borderwidth (height of the bottom border)
        FormTitlebarHeight = (frm.Height - ScaleY(frm.ScaleHeight, frm.ScaleMode, vbTwips)) - FormBorderWidth(frm)
    End Function
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest
    Aah yes, i posted a sample from one of my old modules.
    I'll pay attention to what i post next time =]

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