ISDBScriptControl::RegisterEvent: Difference between revisions
Jump to navigation
Jump to search
(→Method description: Added information about calling from JScript) |
(added JScript example, clarified parameters) |
||
Line 5: | Line 5: | ||
{{MethodParameters | {{MethodParameters | ||
|ObjectVar |Object |Object of the event | |ObjectVar |Object |Object of the event | ||
|EventName |String | |EventName |String |Event name – check manual for actual event names for given object | ||
|HandlerName |String |Procedure name of the handler (string)}} | |HandlerName |String |Procedure name of the handler (string)}} | ||
Line 14: | Line 14: | ||
JScript note: Method does not accept anonoymous functions or callbacks. A handler function must be defined within global script scope. Then handler function's name should be passed to the method. | JScript note: Method does not accept anonoymous functions or callbacks. A handler function must be defined within global script scope. Then handler function's name should be passed to the method. | ||
===Example code=== | ===Example code=== | ||
VBScript: | |||
<source lang="vb"> | <source lang="vb"> | ||
Sub ShutdownHandler | |||
' Event code goes here... | |||
End Sub | |||
Script.RegisterEvent SDB, "OnShutdown", "ShutdownHandler" | Script.RegisterEvent SDB, "OnShutdown", "ShutdownHandler" | ||
</source> | |||
JScript: | |||
<source lang="javascript"> | |||
function shutdown_handler() { | |||
// Event code goes here... | |||
}; | |||
Script.RegisterEvent(SDB, 'OnShutdown', 'shutdown_handler'); | |||
</source> | </source> | ||
Revision as of 20:25, 20 April 2013
CoClass SDBScriptControl, Interface ISDBScriptControl
Sub RegisterEvent(ObjectVar As Object, EventName As String, HandlerName As String)
Parameters
Name | Type | Description |
---|---|---|
ObjectVar | Object | Object of the event |
EventName | String | Event name – check manual for actual event names for given object |
HandlerName | String | Procedure name of the handler (string) |
Method description
Registers COM object event to be handled by a script.
JScript note: Method does not accept anonoymous functions or callbacks. A handler function must be defined within global script scope. Then handler function's name should be passed to the method.
Example code
VBScript:
Sub ShutdownHandler
' Event code goes here...
End Sub
Script.RegisterEvent SDB, "OnShutdown", "ShutdownHandler"
JScript:
function shutdown_handler() {
// Event code goes here...
};
Script.RegisterEvent(SDB, 'OnShutdown', 'shutdown_handler');