The "Ctrl_Open()" function is called when sliceOmatic need to open your interface window.
This is typically when its button has been clicked either in the Tool menu (for Tool modules) or the Mode menu (for Mode modules).
Syntax
extern "C" __declspec(dllexport) int Ctrl_Open(
unsigned short id
)
Parameters
id
The "id" (0 to n) of the ctrl interface for this module. This value is only valid if the module can support multiple instances of itself. This is only the case for some of the class interfaces. For example, we can have multiple instances of the class "DICOM Tree" instanced at the same time. If the user open the interface for one of these, we need to know which one.
Return value
The function returns "0" if an error occurred, "1" otherwise.
Remarks
The function will update the "Flag_Ctrl_Wnd_On" variable, for a Tool module, this only consist of setting the variable to 1, for Mode and Class modules, we need to set it to the module ID of the current window.
The function will also update the "Flag_Ctrl_Id" variable to this mode's instance (given by the "id" parameter). This variable is only useful if your your module can be instance multiple times. This is only the case for Class interfaces.
We will typically place a call to "Ctrl_Update()" here to insure that the window is opened with all the right parameters.
Requirements
Header:
sliceO_include.hpp
Library:
sliceO_Structures.lib
Example
Example Tool module:
|
...
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Open
//
// Parameters: id (unsigned short) Id of the ctrl interface (if
// multiple instances are supported)
// Returns: (int) 0 if error
//
// This is called each time your control is activate from the "Mode" menu
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Open( unsigned short id )
{
// --- the Ctrl Window is now "ON" ---
Flag_Ctrl_Wnd_On = 1 ;
// --- make sure we have the correct values ---
Ctrl_Update( UPDATE_3D_LIGHT ) ;
return( 1 ) ;
}
...
|
|
Example Class module:
|
...
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Open
//
// Parameters: id (unsigned short) Id of the ctrl interface (if
// multiple instances are supported)
// Returns: (int) 0 if error
//
// This is called each time your control is activate from the "Mode" menu
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Open( unsigned short id )
{
// --- the Ctrl Window is now "ON" ---
SliceO_Window *Window_Cur = (SliceO_Window *) Fct_Variable_Value( "$WINDOW_CUR" ) ;
Flag_Ctrl_Wnd_On = Window_Cur ? Window_Cur->Module_Get() : 1 ;
Flag_Ctrl_Id = id ;
Error_Fct( hwnd, ERROR_CODE_REPORT, "\xF1 --- Entering Oblique Class Mode (#%d) ---", id+1 ) ;
// --- make sure we have the correct values ---
Ctrl_Update( UPDATE_DB ) ;
return( 1 ) ;
}
...
|
|
Example Mode module:
|
...
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Open
//
// Parameters: id (unsigned short) Id of the ctrl interface (if
// multiple instances are supported)
// Returns: (int) 0 if error
//
// This is called each time your control is activate from the "Mode" menu
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Open( unsigned short id )
{
// --- the Ctrl Window is now "ON" ---
SliceO_Window *Window_Cur = (SliceO_Window *) Fct_Variable_Value( "$WINDOW_CUR" ) ;
Flag_Ctrl_Wnd_On = Window_Cur ? Window_Cur->Module_Get() : 1 ;
Error_Fct( hwnd, ERROR_CODE_REPORT, "\xF1 --- Entering Edit Mode ---") ;
// --- make sure we have the correct values ---
Ctrl_Update( UPDATE_SELECTION
| UPDATE_CUR_TAG
| UPDATE_CUR_BRUSH
| UPDATE_TAG_LOCK
| UPDATE_TAG_LABEL
| UPDATE_COLOR_TAG ) ;
return( 1 ) ;
}
...
|
|
See also
Ctrl_close