Article | 41018062 |
Type | HowTo |
Product | Engine |
Version | 4.0.1.1018 |
Date Added | 4/8/2003 |
Submitted by | Paul E. Pisarchuk |
Keywords |
I have a situation where I need access to a figure or collection of entities that have been moved by the user via the interactive user interface (i.e. cmdMove).
I know I can use Jobxxxxx events, but how do I access those elements that were moved so I can do some additional processing with them?
Would it be possible to provide some examples in VB on how to do this?
In a new VB 6.0 project add the latest VectorDRaw control, 3 buttons and use the code below :
Option Explicit Dim ToPoint As Variant Dim FromPoint As Variant Dim FlagMove As Boolean Dim MovedObjectHandles As Variant Private Sub cmdInfo_Click() Dim mySelSet As vdSelection Dim myFig As vdFigure Dim I As Long Set mySelSet = VDPro.ActiveDocument.Selections.FindName("VDRAW_PREVIOUS_SELSET") MsgBox "Highlight the selected" For Each myFig In mySelSet myFig.HighLight = VdHightLightDot myFig.Invalidate Next MsgBox "Moved from point :" & FromPoint(0) & ", " & FromPoint(1) & ", " & FromPoint(2) & " " & Chr(13) & _ "To point :" & ToPoint(0) & ", " & ToPoint(1) & ", " & ToPoint(2) & " " For I = 0 To UBound(MovedObjectHandles) If Not IsEmpty(MovedObjectHandles(I)) Then Set myFig = VDPro.ActiveDocument.GetFromHandle(MovedObjectHandles(I)) myFig.PenColor = VdColorBlue myFig.Invalidate End If Next I MsgBox "Only the blue entities were moved (these were not lines)" End Sub Private Sub cmdMoveObj_Click() FlagMove = True ReDim MovedObjectHandles(0) VDPro.CommandAction.CmdMove "USER", "USER", "USER" FlagMove = False ToPoint = VDPro.ActiveDocument.LastPoint End Sub Private Sub cmdOpen_Click() VDPro.ActiveDocument.Open App.Path & "\test1.vdi" VDPro.CommandAction.Zoom "E", 0, 0 VDPro.CommandAction.Zoom "S", 0.98, 0 End Sub Private Sub Form_Load() FlagMove = False End Sub Private Sub VDPro_AfterModify(ByVal Figure As VDProLib.vdPrimary, ByVal ModificationType As Integer) Dim Sum As Long If ModificationType <> MODIFYTYPE_MOVE Then Exit Sub ' Only for .Move and .cmdMove actions Sum = UBound(MovedObjectHandles) MovedObjectHandles(Sum) = Figure.Handle ReDim Preserve MovedObjectHandles(Sum + 1) End Sub Private Sub VDPro_BeforeModify(ByVal Figure As VDProLib.vdPrimary, ByVal ModificationType As Integer, newValue As Variant, exValue As Variant, Cancel As Integer) If ModificationType <> MODIFYTYPE_MOVE Then Exit Sub If Figure.Type = "VDLINE" Then 'Don't move the vdLine objects Cancel = 1 End If End Sub Private Sub VDPro_JobMouseDown(ByVal JobID As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Double, ByVal y As Double, Cancel As Integer) If FlagMove Then FromPoint = VDPro.ActiveDocument.LastPoint End If End Sub