Results 1 to 5 of 5

Thread: XP style vs 98 [resolved]

  1. #1

    Thread Starter
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444

    XP style vs 98 [resolved]

    I have a major problem that i've had to overlook in many of my projects. If the program has a frame, and on load I want to make the size of the form the size of the frame with equal margin. Well with XP style i set the margins manually and it works, but when I change the style to win 98, the margin is no longer equal, especial with the height properties. Is there a function, API, etc to determine exact size of the borders so I could resize my form in any style and still get the same margins all around? Scalewidth doesn't really help the way i use it but i might be using it in a wrong way. Thanks.
    Last edited by Dmitri K; Mar 23rd, 2004 at 07:39 PM.

  2. #2

    Thread Starter
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444
    Anyone?

  3. #3
    Hyperactive Member
    Join Date
    Nov 2002
    Location
    Someplace 'ore the rainbow
    Posts
    392
    look up the SystemMetrics API

    cjqp
    When your answer is the Arc Sin of 1.015, you should check your Pythagorean triple.

  4. #4

    Thread Starter
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444
    They have almost no information that I could find about that API but I decided to write my own function to get border size. Although I'm sure many have already used this, but I think it's nice to have because I guess not as many people know as I thought; well my post was answered. Anyway, here's the code

    VB Code:
    1. Option Explicit
    2.  
    3. Private Type T_Borders
    4.     L As Long 'left
    5.     R As Long 'right
    6.     T As Long 'top
    7.     B As Long 'bottom
    8. End Type
    9.  
    10. Public B As T_Borders
    11.  
    12. Public Sub GetBorders(frm As Form)
    13. Dim horiz_d As Long
    14. Dim vertical_d As Long
    15.  
    16. horiz_d = (frm.Width - frm.ScaleWidth) / 2
    17. vertical_d = (frm.Height - frm.ScaleHeight) - horiz_d 'bottom is the same size as sides
    18.  
    19. B.L = horiz_d
    20. B.R = horiz_d
    21. B.T = vertical_d
    22. B.B = horiz_d
    23. End Sub

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    See if this works for you as well:
    VB Code:
    1. Option Explicit
    2.  
    3. Const SM_CXBORDER = 5
    4. Const SM_CYBORDER = 6
    5.  
    6. Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    7.  
    8. Private Sub Command1_Click()
    9.     Debug.Print "Side Border:   " & Str$(GetSystemMetrics(SM_CXBORDER)) * Screen.TwipsPerPixelX
    10.     Debug.Print "Bottom Border: " & Str$(GetSystemMetrics(SM_CYBORDER)) * Screen.TwipsPerPixelY
    11. End Sub

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