Option Explicit
'Default Property Values:
Const m_def_Draggable = True
Const m_def_MinWidth = 240
Const m_def_MaxWidth = 100000
Const m_def_MinHeight = 240
Const m_def_MaxHeight = 100000
Const m_def_HandleSize = 45
'Property Variables:
Dim m_Draggable As Boolean
Dim m_MinWidth As Long
Dim m_MaxWidth As Long
Dim m_MinHeight As Long
Dim m_MaxHeight As Long
Dim m_HandleSize As Long
Dim Resizing As Boolean
Dim Moving As Boolean
Dim StartX As Single
Dim StartY As Single
' *********************************************
' Start resizing the control.
' *********************************************
Private Sub Corner_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not Draggable Then Exit Sub
Resizing = True
StartX = X
StartY = Y
End Sub
' *********************************************
' Resize the control.
' *********************************************
Private Sub Corner_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim dw As Single
Dim dh As Single
Dim wid As Single
Dim hgt As Single
Dim w As Single
Dim h As Single
' Do nothing unless we're resizing.
If Not Resizing Then Exit Sub
dw = X - StartX
dh = Y - StartY
If dw = 0 And dh = 0 Then Exit Sub
wid = Width + dw
' Make sure we will fit on the form.
w = ScaleX(wid, ScaleMode, Parent.ScaleMode)
If w > Parent.ScaleWidth - Extender.Left Then
w = Parent.ScaleWidth - Extender.Left
wid = ScaleX(w, Parent.ScaleMode, ScaleMode)
End If
' Stay between MinWidth and MaxWidth.
If wid < m_MinWidth Then wid = m_MinWidth
If wid > m_MaxWidth Then wid = m_MaxWidth
hgt = Height + dh
' Make sure we will fit on the form.
h = ScaleX(hgt, ScaleMode, Parent.ScaleMode)
If h > Parent.ScaleHeight - Extender.Top Then
h = Parent.ScaleHeight - Extender.Top
hgt = ScaleY(h, Parent.ScaleMode, ScaleMode)
End If
' Stay between MinHeight and MaxHeight.
If hgt < m_MinHeight Then hgt = m_MinHeight
If hgt > m_MaxHeight Then hgt = m_MaxHeight
Size wid, hgt
End Sub
' *********************************************
' Stop resizing the control.
' *********************************************
Private Sub Corner_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Resizing = False
End Sub
|