'this is the simple callback it takes one long arg and returns a long
Private Declare Function ext_SBCallBack Lib "COM.dll" Alias "SBCallBack" (ByVal EntryPoint As Long, ByVal arg As Long) As Long
Private Declare Function eng_SBCallBack Lib "sb_engine.dll" Alias "SBCallBack" (ByVal EntryPoint As Long, ByVal arg As Long) As Long
'this extended version will take a variant array as the argument and it will pass
'them as arguments to the callback function. It supports Long,Byte,Integer,Object, and string inputs
'The variant return result can be either a long or a string
'the arg count of the script basic function actually does not have to line up to the array count.
'extra args in the script declare will just be undef, or two few cause no problems either..
Private Declare Function ext_SBCallBackEx Lib "COM.dll" Alias "SBCallBackEx" (ByVal EntryPoint As Long, ByRef v As Variant) As Variant
Private Declare Function eng_SBCallBackEx Lib "sb_engine.dll" Alias "SBCallBackEx" (ByVal EntryPoint As Long, ByRef v As Variant) As Variant
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private m_owner As Sample
Private Function TriggerCallBack(nodeID As Long, argValue As Long)
'this little trick is so this works for both the standard COM extension,
'as well as the embedded sb_engine.dll project i am working on..
If GetModuleHandle("COM.dll") <> 0 Then
TriggerCallBack = ext_SBCallBack(nodeID, argValue)
ElseIf GetModuleHandle("sb_engine.dll") <> 0 Then
TriggerCallBack = eng_SBCallBack(nodeID, argValue)
Else
MsgBox "Could not find the extension dll or the sb_engine.dll to get the sbcallback export from?", vbExclamation
End If
End Function
Private Function TriggerCallBackEx(nodeID As Long, v() As Variant)
'this little trick is so this works for both the standard COM extension,
'as well as the embedded sb_engine.dll project i am working on..
If GetModuleHandle("COM.dll") <> 0 Then
TriggerCallBackEx = ext_SBCallBackEx(nodeID, v)
ElseIf GetModuleHandle("sb_engine.dll") <> 0 Then
TriggerCallBackEx = eng_SBCallBackEx(nodeID, v)
Else
MsgBox "Could not find the extension dll or the sb_engine.dll to get the sbcallback export from?", vbExclamation
End If
End Function
Function ShowCallBackForm(defVal As Long, owner As Sample) As Long
On Error Resume Next
Set m_owner = owner
txtValue = defVal
Me.Show 1
Set m_owner = Nothing
ShowCallBackForm = CLng(txtValue)
Unload Me
End Function
Private Sub cmdOp1_Click()
Dim nodeID As Long
Dim arg As Long
On Error Resume Next
nodeID = m_owner.CallBackHandlers("frmCallBack.cmdOp1_Click")
If nodeID = 0 Then
MsgBox "Script writer forgot to register a callback handler for me..", vbInformation
Exit Sub
End If
Dim tmp(5)
tmp(0) = CLng(txtValue)
tmp(1) = "two"
tmp(2) = 3
tmp(3) = "four"
tmp(4) = 5
Set tmp(5) = Me
' Dim tmp2(5) As Long
' For i = 0 To UBound(tmp2)
' tmp(2) = i
' Next
arg = CLng(txtValue)
retval = TriggerCallBackEx(nodeID, tmp)
If TypeName(retval) = "String" Then
MsgBox "String return received: " & retval
ElseIf TypeName(retval) = "Long" Then
txtValue = retval
Else
'returns type Empty on failure..
MsgBox "Typename(retVal) = " & TypeName(retval) & " Value=" & retval
End If