CreateDynamicCommand Method
|
|
Applies To
|
BasicTcl Object, AdvancedTcl Object
|
Prototype
|
CreateDynamicCommand(Interpreter As Long, CommandName As String, ObjectName As String, MethodName As String, ClientData As Long, NotifyObject As Object, Reserved As Long) As Long
|
Input
|
The "Interpreter" parameter, which must be a valid interpreter pointer.
The "CommandName" parameter, which is the name of the new command to be added to the interpreter.
The "ObjectName" parameter, which is the ProgID of the object that will be used to handle the command.
The "MethodName" parameter, which is the method responsible for handling the new command.
The "ClientData" parameter, which is user defined data to be passed into the method as a parameter when called by the interpreter.
The "NotifyObject" parameter, which is the optional object to be notified immediately after each temporary object is created and immediately before each temporary object is destroyed.
The "Reserved" parameter, which is reserved for future use and must be zero.
|
Output
|
None.
|
Returns
|
Undefined.
|
COM Results
|
S_OK: Success.
E_INVALIDARG: Either a NULL pointer was passed or the "Interpreter" parameter is invalid. E_FAIL: An unexpected error was encountered. |
Side Effects
|
Upon success, a COM reference is added to the object specified in the "NotifyObject" parameter, if a valid object was supplied, and a custom command is added to the specified interpreter.
|
Description
|
This method is a wrapper around the Tcl_CreateCommand function.
It creates the custom command in the specified interpreter and sets up the internal data necessary to call the specified object via the IDispatch interface.
When the interpreter attempts to call the command procedure, the component intercepts the call and performs the translation (non-trivial), creates a COM object instance based on the ProgID, invokes the COM object, and then destroys the COM object instance.
|
Notes
|
The object specified in the "NotifyObject" parameter, when supplied, must have a "Notify" method with the following prototype:
Notify(ByVal Interpreter As Long, ByVal CommandName As String, ByVal NotifyType As Long, ByVal CallbackObject As Object, ByVal ClientData As Long, ByVal Flags As Long, ByVal Reserved As Long) As Long
The "Interpreter" parameter, which is the interpreter that is to be serviced by the custom command.
The "CommandName" parameter, which is the name of the command being serviced.
The "NotifyType" parameter, which can be zero to indicate the object is being destroyed or non-zero to indicate object is being created.
The "CallbackObject" parameter, which is the object that is either being created or destroyed (this parameter is always a valid object).
The "ClientData" parameter, which is the same user defined data originally passed into the CreateDynamicCommand method call that created this command.
The "Flags" parameter, which is reserved for future use and will be zero.
The "Reserved" parameter, which is reserved for future use and will be zero.
Currently, this method must return a value of zero (or False).
|
Example
|
Private Sub Command1_Click()
Dim poTcl As TclBridge.BasicTcl Dim plInterpreter As Long Set poTcl = New TclBridge.BasicTcl Call poTcl.CreateInterpreter(plInterpreter) Call poTcl.CreateDynamicCommand(plInterpreter, "Tester1", "Project1.Class1", "Test1", 1234&, Nothing, 0&) ' the EvaluateString method or the EvaluateFile method could be used here to test the new custom command... Call poTcl.DeleteCommand(plInterpreter, "Tester1") Call poTcl.DeleteInterpreter(plInterpreter) Set poClass = Nothing Set poTcl = Nothing End Sub |