Jump to content

Athanasios Gardos

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

Posts I've Made

In Topic: How to limit only vertical or horizontal resize but not diagonal

19 March 2016 - 03:44 PM

When we have a vertical rectangle and we want to control that only the Y’s(height) can be changed.

(When it is a horizontal rectangle, the X’s (width)can be changed.)

We can use the following code:

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 lCnt As Long, lMax As Long
    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)
    lMax = UBound(StretchHandles())
    If Not (AlmostTheSame(dxOld, dxNew) = True And AlmostTheSame(dyOld, dyNew) = True) Then
        For lCnt = 1 To lMax
            Select Case LCase$(cAvax1.GetHandleKey(StretchHandles(lCnt)))
                Case "vertical rectangle"
                    If Not ((yNewMin <> yOldMin) Or _
                       (yNewMax <> yOldMax) Or _
                       (yNewMax <> yOldMax) Or _
                       (yNewMin <> yOldMin)) Then
                       fCancel = True
                    End If
                Case "horizontal rectangle"
                    If Not ((xNewMin <> xOldMin) Or _
                       (xNewMax <> xOldMax) Or _
                       (xNewMin <> xOldMin) Or _
                       (xNewMax <> xOldMax)) Then
                       fCancel = True
                    End If
                Case Else
                    fCancel = True
                    Exit Sub
            End Select
        Next lCnt
    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()
    Dim h() As Long
    Call cAvax1.StartAvax
    ReDim h(3) As Long
    h(1) = cAvax1.Add_Rectangle(0, 0, 100, 50)
    Call cAvax1.SetHandleKey(h(1), "horizontal rectangle")
    h(2) = cAvax1.Add_Rectangle(120, 0, 50, 100)
    Call cAvax1.SetHandleKey(h(2), "vertical rectangle")
    h(3) = cAvax1.Add_Rectangle(180, 0, 50, 100)
    Call cAvax1.SetHandleKey(h(3), "vertical rectangle")
    cAvax1.Command = AutoLimits_c
End Sub

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

In Topic: XY location on MouseMove

17 March 2016 - 12:18 PM

Please have a look at the following source code:

 Private Sub cAvax1_OnMouseMove(ByVal Sender As Object, ByVal e As Avax.cAvax.MouseMoveEventArgs) Handles CAvax1.OnMouseMove
     Dim x1, y1 As Single
     If CAvax1.CurrentXY(x1, y1) = True Then
         Debug.Print(x1 & " " & y1)
     End If
 End Sub

Avax.chm help file contains examples for every function.

You can also find examples at c:\Program Files\Avax Vector NET\Examples\ folder and at