Implementation Callbacks for Non-Self-installing Plug-ins (COM API)
COM Callbacks for Custom Events
To use the XSIOnEvent callback function to declare your event handler (COM API)
This is the simplest way to handle events: you need to provide an external DLL or SO that includes the XSIOnEvent function containing a case for each bound event:
HRESULT WINAPI XSIOnEvent
(
LONG in_lEventID,
LPVARIANT in_pVar,
LONG in_lNum
)
{
switch (in_lEventID)
{
case siOnBeginSceneSave:
{
if (!CanSaveMyCurrentScene())
{
// abort the operation using the predefined abort argument
LPVARIANT pVar = V_VARIANTREF(&in_pVar[1]);
V_BOOL(pVar) = VARIANT_TRUE;
}
}
break;
};
return S_OK;
}
The XSIOnEvent callback function takes these arguments:
|
Type |
Description |
|
[in] DISPID |
Identifies the event that was fired by XSI. |
|
[in] VARIANT* |
Contains the argument value(s) specific to a particular event; for instance the OnEndSceneOpen will have the name of the scene being opened as argument. |
|
[in] LONG |
Number of arguments contained in the array. |
It returns an HRESULT with one possible value:
|
Type |
Description |
|
S_OK |
Indicates a successful operation. |
![]()
|
To abort the operation, set the Abort argument to TRUE. The position of this argument in the argument array is specific to the event itself. For more information, see the Programmer’s Reference section of the Reference guide. |
![]()
|
Not all events support an Abort argument. For example, OnTerminate cannot be interrupted. |
COM Callbacks for Custom Commands
To use the XSIOnCommand callback function to declare your command handler (COM API)
The XSIOnCommand callback function takes these arguments:
|
Type |
Description |
|
[in] LPCWSTR |
Identifies the command that was fired in XSI. |
|
[in] VARIANT* |
Contains the argument value(s) specific to a particular command. |
|
[in] ULONG |
Number of arguments contained in the array. |
|
[out,optional] VARIANT* |
Contains the returned value for this operation. This is typically used if the command is defined a s a function in VBScript. |
It returns an HRESULT with one possible value:
|
Type |
Description |
|
S_OK |
Indicates a successful operation. |
![]()
|
Don’t forget to export any command handler function you may have defined in your DLL or SO library file. For more information, see Exporting Entry Points, Event And Command Handlers. |
Exporting Entry Points, Event And Command Handlers
As is the case with developing any compiled COM function as part of a plug-in for XSI, you need to export the functions that need to be available to XSI with a DEF file so that XSI can find it.
To export your operator entry points with a DEF file
- Specify a a DEF file similar to this one:
LIBRARY MYFUNC
DESCRIPTION "COM Operator."
EXPORTS
ComSplatter_Update @1 PRIVATE
ComSplatter_Init @2 PRIVATE
ComSplatter_Term @3 PRIVATE
![]()
|
Remember that for calling callback functions, XSI uses the name of the function, not its ordinal value. |
To export your event handler function
- Specify a a DEF file similar to this one:
LIBRARY MYHNDL
DESCRIPTION "Event handler function."
EXPORTS
XSIOnEvent @1 PRIVATE
To export your command handler function
- Specify a a DEF file similar to this one:
LIBRARY MYHNDL
DESCRIPTION "Command handler function."
EXPORTS
XSIOnCommand @1 PRIVATE
![]()
|
XSIOnCommand and XSIOnEvent need to be exported only if they are defined in the .dll. |