ok got the callbacks working. but I had to cache a pSupportTable pointer when entering CallByName, the VB is single threaded and modal blocking..sooo should be safe I think. The following is about as clean as i can see it getting..
import com.inc
function Button1_Click(arg)
print "Back in script basic Button1_Click arg=", arg, "\n"
Button1_Click = arg + 1
end function
function Button2_Click(arg)
print "Back in script basic Button2_Click arg=", arg, "\n"
Button2_Click = arg * 2
end function
obj = CreateObject("VB6.Sample")
if obj = 0 then
print "CreateObject failed!\n"
else
print "obj = ", obj, "\n"
oCollection = CallByName(obj, "CallBackHandlers", VbGet)
print "oCollection = ", oCollection, "\n"
CallByName(oCollection, "Add", VbMethod, ADDRESS(Button1_Click()), "frmCallBack.cmdOp1_Click" )
CallByName(oCollection, "Add", VbMethod, ADDRESS(Button2_Click()), "frmCallBack.cmdOp2_Click" )
retVal = CallByName(obj, "LaunchCallBackForm", vbMethod, 21)
print "LaunchCallBackForm returned ", retVal, "\n"
ReleaseObject(obj)
print "test complete!\n"
end if
you will have to change the project -> properties -> C++ -> additional include directories to compile the com.dll on your system.
so the way it works is the script registers which function handler it wants to use for each button event. The event names are actually
arbitrary, its just a format that both the script and the activex control agree on. Then when the button is clicked on in the UI, it will query
the registered handlers for the nodeID for the collection key it uses. Then does the call back passing an int arg.
consider it an experimental design at this point I guess. maybe a different design would be more useful or cleaner but its what I came up with as a first take.