Results 1 to 25 of 25

Thread: [VB6] SizeGrip without StatusBar

Threaded View

  1. #1

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    [VB6] SizeGrip without StatusBar

    Some controls will get this for you automatically. For example when ScrollBars join at the lower-right corner of the Form, or you have a StatusBar, etc.

    However when you don't have or want these but your Form is sizable you may want the sizing grip because in the post-Win7 world you no longer get fat borders. Actually they still are fat, but the fat part is transparent making them look thin to the user.

    It turns out that you can turn a VB6 intrinsic ScrollBar control into a sizing grip fairly easily. It works both with and without Common Controls 6.0 UxTheming, and it is a real sizing grip visible as such to Windows Accessibility unlike funky hacks like sticking a Label or something in the corner and capturing the mouse when hovered over and clicked.


    Name:  sshot.png
Views: 2251
Size:  8.6 KB


    Code:
    Private Sub Form_Load()
        With hsbSizeGrip
            'Turn the HScrollBar into a Sizing Grip:
            SetWindowLong .hWnd, _
                          GWL_STYLE, _
                          GetWindowLong(.hWnd, GWL_STYLE) Or SBS_SIZEGRIP
            'Size the Sizing Grip to the system dimensions for such things.  This
            'is not automatic:
            MoveWindow .hWnd, _
                       0, _
                       0, _
                       GetSystemMetrics(SM_CXVSCROLL), _
                       GetSystemMetrics(SM_CYHSCROLL), _
                       True
            'Set the MousePointer to system lower-right resize arrows:
            .MousePointer = vbSizeNWSE
        End With
    End Sub
    However you do still have to position it in your Resize event handler, because it doesn't get docked/aligned automagically:

    Code:
    Private Sub Form_Resize()
        If WindowState <> vbMinimized Then
            'Position the Sizing Grip.  It is not automatically anchored to the
            'corner of the Form:
            With hsbSizeGrip
                .Move ScaleWidth - .Width, ScaleHeight - .Height
            End With
        End If
    End Sub
    Of course the attached demo moves and sizes a few more controls in its Resize handler.
    Attached Files Attached Files
    Last edited by dilettante; Apr 22nd, 2017 at 08:53 AM.

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