Scripting Dynamic Callbacks
Is this possible?
Wednesday, March 23, 2005 by Dangerousdaze | Discussion: DesktopX
myControl.subscribe "params"
This control actually creates a callback called
sub myControl_newMessage
[Code to handle the new message]
end sub
I've created this in my script but it doesn't fire. Can you create event handlers on the fly for events from COM objects?
Thanks!
Nick
Reply #2 Monday, March 28, 2005 7:10 AM
Reply #3 Monday, March 28, 2005 10:14 AM
Nick
Reply #4 Tuesday, March 29, 2005 12:42 AM
Here is an example of a callback function that works.
The interesting peice is setting the call back function
http.onreadystatechange=GetRef("processMsg")
Hope this helps
Dim http
'Called when the script is executed
Sub Object_OnScriptEnter
getNewMessage()
MsgBox("done on enter")
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
On Error Resume Next
http.abort
Set http = Null
End Sub
Function getNewMessage()
Set http = createObject("microsoft.xmlhttp")
http.onreadystatechange=GetRef("processMsg")
http.Open "GET","http://www.w3schools.com/xml/note.xml",True
http.Send
End Function
Function processMsg()
If http.readyState=2 Then
MsgBox("http request started")
End If
If http.readyState=4 Then
MsgBox("http response complete")
End If
End Function
Reply #5 Saturday, April 2, 2005 8:44 AM
The documentation just states:# Declare a variable for the listener.
Dim WithEvents myListener as TibrvListener
This declaration triggers VB to automatically define a private subroutine callback stub named myListener_OnMsg. The program must complete this method stub for each listener object.
Nick
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!







Reply #1 Sunday, March 27, 2005 6:24 PM
Nick