- Selva V Pasupathy, HSBC Global Resourcing, Hyderabad 1
Copy following code and paste in a userform module to add form resizer.
Original Source: Andy Pope
Option Explicit
Private Const MResizer = "ResizeGrab"
Private WithEvents m_objResizer As MSForms.Label
Private m_sngLeftResizePos As Single
Private m_sngTopResizePos As Single
Private m_blnResizing As Single
'________________________________________
Private Sub UserForm_Initialize()
m_AddResizer
End Sub
'________________________________________
Private Sub UserForm_Terminate()
Me.Controls.Remove MResizer
End Sub
'________________________________________
Private Sub m_AddResizer()
'
'add resizing control to bottomright corner of form
'
Set m_objResizer = Me.Controls.Add _
("Forms.label.1", MResizer, True)
With m_objResizer
With .Font
.Name = "Marlett"
.Charset = 2
.Size = 14
.Bold = True
End With
.BackStyle = fmBackStyleTransparent
.AutoSize = True
.BorderStyle = fmBorderStyleNone
.Caption = "o"
.MousePointer = fmMousePointerSizeNWSE
.ForeColor = RGB(100, 100, 100)
.ZOrder
.Top = Me.InsideHeight - .Height
.Left = Me.InsideWidth - .Width
End With
End Sub
'________________________________________
Private Sub m_objResizer_MouseDown( _
ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)
If Button = 1 Then
m_sngLeftResizePos = X
m_sngTopResizePos = Y
m_blnResizing = True
End If
End Sub
'________________________________________
Private Sub m_objResizer_MouseMove( _
ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)
If Button = 1 Then
With m_objResizer
.Move .Left + X _
- m_sngLeftResizePos, _
.Top + Y - m_sngTopResizePos
Me.Width = Me.Width + _
X - m_sngLeftResizePos
Me.Height = Me.Height + Y - m_sngTopResizePos
.Left = Me.InsideWidth - .Width
.Top = Me.InsideHeight - .Height
End With
End If
End Sub
'________________________________________
Private Sub m_objResizer_MouseUp( _
ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)
If Button = 1 Then
m_blnResizing = False
End If
End Sub
|