Visual Basic Window/Form Routines
ReleaseCapture: Simulating a Working Size-Grip on a VB Form
Posted:   Tuesday January 21, 2003
Updated:   Monday December 26, 2011
Applies to:   VB4-32, VB5, VB6
Developed with:   VB6, Windows XP
OS restrictions:   None
Author:   Michael Cole, VBnet - Randy Birch
Related:   SendMessage: Creating a Scrollable Viewport to Simulate a Scrollable Form
SendMessage: Move Controls to Simulate Form Scrolling
ReleaseCapture: Simulating a Working Size-Grip on a VB Form

Every once in a while a really cool workaround is presented in the msnews groups. Here, Michael Cole's code from microsoft.public.vb.general.discussion shows how to use a label and a simple API call to display a simulated form resizing handle on a form using Windows' Marlett font, and how to react to a click and drag to resize the form.
 BAS Module Code

 Form Code
Add a label (Label1) to a form; all code to set up, position and use the fake size grip is below:

Option Explicit
' Copyright 1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce 
'               or publish this code on any web site,
'               online service, or distribute as source 
'               on any media without express permission.
Private Declare Function ReleaseCapture Lib "user32" () As Long

Private Declare Function SendMessage Lib "user32" _
   Alias "SendMessageA" _
  (ByVal hwnd As Long, _
   ByVal wMsg As Long, _
   ByVal wParam As Long, _
   lParam As Any) As Long

Private Const HTBOTTOMRIGHT = 17

Private Sub Form_Load()

   With Label1
      .ForeColor = &H80000015
      .BackStyle = vbTransparent
      .AutoSize = True
      .Font.Size = 12
      .Font.Name = "Marlett"
      .Caption = "o"      
      .Font.Bold = False
   End With
End Sub

Private Sub Form_Resize()

   Label1.Move Me.ScaleLeft + Me.ScaleWidth - (Label1.Width + 40), _
               Me.ScaleTop + Me.ScaleHeight - (Label1.Height + 40)
End Sub

Private Sub Label1_MouseDown(Button As Integer, _
                             Shift As Integer, _
                             X As Single, _
                             Y As Single)

  If Button = vbLeftButton Then
  End If

End Sub

Private Sub Label1_MouseMove(Button As Integer, _
                             Shift As Integer, _
                             X As Single, _
                             Y As Single)

   Label1.MousePointer = 8
End Sub
Remember that since a label is lower on the graphics ZOrder than other windowed controls, sizing such that the label becomes obscured will cause it to fall behind other windowed controls..


PayPal Link
Make payments with PayPal - it's fast, free and secure!


Copyright 1996-2011 VBnet and Randy Birch. All Rights Reserved.
Terms of Use  |  Your Privacy


Hit Counter