| MIL 10 Reference
| Customize Help
| Save Settings

MgraHookFunction



See also
Availability
Available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
Synopsis
Hook a function to a graphics list event.
Syntax
void MgraHookFunction(
MIL_ID GraListId, //in
MIL_INT HookType, //in
MIL_GRA_HOOK_FUNCTION_PTR HookHandlerPtr, //in
void *UserDataPtr //in
)
Description

This function allows you to attach or detach a user-defined function to a specified graphics list event (for example, a modification to the graphics list's contents). Once a hook-handler function is defined and hooked to an event, it is automatically called when the event occurs.

You can hook more than one function to an event by making separate calls to MgraHookFunction() for each function that you want to hook. MIL automatically chains and keeps an internal list of all these hooked functions. When a function is hooked, this new function is added to the end of the list. When the event happens, all user-defined functions in the list will be executed in the same order that they were hooked to the event. You can also remove any function from the list; in this case, MIL preserves the order of the remaining functions in the list.

Unlike most other functions that modify a MIL object, you can call this function concurrently from multiple threads on the same MIL graphics list (GraListId) without using an M_MUTEX object, as long as all the other parameters of the concurrent calls do not also share data.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
GraListId

Specifies the identifier of the graphics list to which to hook a function. The graphics list must have been previously allocated on the required system using MgraAllocList().

HookType

Specifies the graphics list event to which to hook the function. This parameter can be set to one of the following values:

function map For specifying the graphics list event
CollapseValue Description
Collapse M_GRAPHIC_LIST_MODIFIED +

Calls the hook-handler function each time the specified graphics list is modified in any way, either by a MIL function or by interactive manipulations. Any of the other events will also trigger this event, and it will always be the last event to be triggered.

(summarize)
Collapse M_GRAPHIC_MODIFIED +

Calls the hook-handler function each time the specified graphics list's graphics are modified by a MIL function or by interactive manipulations. This includes the creation of a new graphic (for example, using MgraLine() or by interactive manipulations), its deletion (using MgraControlList() with M_DELETE or MgraClear()) and any modification to a graphic using MgraControlList(), except for changing the selection (MgraControlList() with M_GRAPHIC_SELECTED).

Note that this event can be triggered even if no modification occurred. For example, calling MgraControlList() with M_POSITION_X and passing the current value returned by MgraInquireList() with M_POSITION_X will not modify the graphic, but will still trigger the event.

(summarize)
Collapse M_GRAPHIC_SELECTION_MODIFIED +

Calls the hook-handler function each time a graphic is selected or deselected, either by a MIL function or by interactive manipulations.

Collapse M_INTERACTIVE_GRAPHIC_STATE_MODIFIED +

Calls the hook-handler function each time the specified graphics list's interactive state is modified by a MIL function or by interactive manipulations.

Combination constant for the values listed in For specifying the graphics list event.

You can add the following value to the above-mentioned values to set whether to detach the hook-handler function.

function map For detaching the hook-handler function
CollapseCombination value Description
Collapse M_UNHOOK

Unhooks the specified function if hooked to the specified event.

HookHandlerPtr

Specifies the address of the function that should be called when the specified event occurs. The hook-handler function must be declared as follows:

MIL_INT MFTYPE HookHandler(
MIL_INT HookType,
MIL_ID EventId,
void *UserDataPtr
)
Parameters
HookType

Type of graphics list event that generated the call.

EventId

Event identifier to pass to MgraGetHookInfo() when inquiring about the hooked event.

UserDataPtr

User data pointer that was passed to the UserDataPtr parameter of MgraHookFunction().

Upon successful completion, the hook-handler function should return M_NULL. Note MFTYPE and MIL_GRA_HOOK_FUNCTION_PTR are reserved MIL predefined types for functions and data pointers.

UserDataPtr

Specifies the address of the user data that you want to make available to the hook-handler function. This address is passed to the hook-handler function, through its UserDataPtr parameter, when the specified event occurs. Set this parameter to M_NULL if not used.

Compilation information
Header Include mil.h.
Library Use mil.lib.
DLL Requires mil.dll.
GRAPHIC LIST MODIFIED GRAPHIC MODIFIED GRAPHIC SELECTION MODIFIED INTERACTIVE GRAPHIC STATE MODIFIED UNHOOK