VBA Code:
Option Explicit
Dim obElem_DragBegin As Element
Dim obPicture As DynPicture
Dim obElements As Elements
Dim bDropEnabled As Boolean
'#########################################################################################################
'Start draging -> get information about the "start" element
Public Sub DragBegin_Select(obElem As Element, vPosX As Variant, vPosY As Variant)
Set obElem_DragBegin = obElem
End Sub
'#########################################################################################################
'Drop Event -> if validation is correct, then write the value to the target element
Public Sub DragDrop_Variable(obElem As Element, vPosX As Variant, vPosY As Variant)
If DragOver_SelectVar(obElem) = False Then Exit Sub
'write the value of the source variable to the target variable
obElem.ItemVariable(0).Value = obElem_DragBegin.ItemVariable(0).Value
End Sub
'#########################################################################################################
'Hover Event -> Validation if the variable (start element) can be droped to the target element
Public Function DragOver_SelectVar(obElem As Element) As Boolean
Dim bSelected As Boolean
Dim i As Integer
bSelected = True
'Enable DragDrop...
If (Not obElem_DragBegin Is Nothing) Then
'check if a variable is linked at the target element
If obElem.CountVariable = 0 Then
bSelected = False
DragOver_SelectVar = bSelected
Exit Function
'check if linked variables are of the same datatype (i.e. UINT -> UINT)
ElseIf obElem.ItemVariable(0).DataType <> obElem_DragBegin.ItemVariable(0).DataType Then
bSelected = False
End If
End If
bDropEnabled = bSelected
DragOver_SelectVar = bSelected
End Function
This document governs the use of our Community Forum. By registering and using the platform, you accept these conditions.
The COPA-DATA Community Forum serves to encourage the exchange of information and experience about the zenon software between forum users respectively zenon users.
Please mind that any published information on the Community Forum is the subjective opinion and view based on the experience and the level of knowledge of the author. COPA-DATA does not overtake any responsibility for the content and the accuracy of the shared information.
Users of the Community Forum are encouraged to share only well-founded experiences and to point out any risks associated with the implementation of proposed solutions to problems. COPA-DATA at its absolute discretion, reserves the right to moderate the forum. In this connection COPA-DATA may remove any information containing false facts, potentially dangerous solutions, bad language or content that may insult, degrade or discriminate others. COPA-DATA may block a non-complying user from forum access if the user violated this provision.
COPA-DATA reserves the right to change this document from time to time at own discretion.
Ing. Punzenberger COPA-DATA GmbH
Karolingerstraße 7b · 5020 Salzburg · Austria
www.copadata.com