Jump to content

Athanasios Gardos

Member Since 21 Mar 2005
Offline Last Active Nov 01 2016 06:35 PM

Topics I've Started

How to limit only vertical or horizontal resize but not diagonal

17 March 2016 - 12:04 PM

Private Sub cAvax1_SelectRegionStretch(StretchHandles() As Long, xOldMin As Single, yOldMin As Single, xOldMax As Single, yOldMax As Single, xNewMin As Single, yNewMin As Single, xNewMax As Single, yNewMax As Single, fCancel As Boolean)
    Dim dxOld As Single
    Dim dyOld As Single
    Dim dxNew As Single
    Dim dyNew As Single
    dxOld = Abs(xOldMax - xOldMin)
    dyOld = Abs(yOldMax - yOldMin)
    dxNew = Abs(xNewMax - xNewMin)
    dyNew = Abs(yNewMax - yNewMin)
    If Not (AlmostTheSame(dxOld, dxNew) = True And AlmostTheSame(dyOld, dyNew) = True) Then
        If Not ((xNewMin <> xOldMin And yNewMin <> yOldMin) Or _
           (xNewMax <> xOldMax And yNewMax <> yOldMax) Or _
           (xNewMin <> xOldMin And yNewMax <> yOldMax) Or _
           (xNewMax <> xOldMax And yNewMin <> yOldMin)) Then
           fCancel = True
        End If
    End If
End Sub

Private Function AlmostTheSame(a As Single, b As Single) As Boolean
    If Abs(a - b) < 0.0001 Then AlmostTheSame = True
End Function

Private Sub Form_Load()
    Call cAvax1.StartAvax
    cAvax1.Add_Line 0, 0, 0, 10, 10, 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Call cAvax1.EndAvax
End Sub