Admin Production ni-theme
Current Publication

GetRelativeMouseState

LabWindows/CVI

GetRelativeMouseState

int GetRelativeMouseState (int panelHandle, int controlID, int *xCoordinate, int *yCoordinate, int *leftButtonDown, int *rightButtonDown, int *keyModifiers);

Purpose

Obtains information about the state of the mouse cursor. xCoordinate and yCoordinate return the position of the mouse relative to the top and left coordinates of a specific control. If you pass zero as the controlID, the coordinate information references the top and left coordinates of the panel, excluding the panel frame and title bar. GetRelativeMouseState returns the coordinates even if the mouse is not over the control or the panel.

Supported Controls

You can use GetRelativeMouseState with all LabWindows/CVI user interface controls.

Parameters

Input
Name Type Description
panelHandle int Specifier for a particular panel that is currently in memory. You can obtain this handle from functions such as LoadPanel and NewPanel.
controlID int Defined constant, located in the .uir header file, that you assign to the control in the User Interface Editor, or the ID returned by functions such as NewCtrl and DuplicateCtrl.

You can pass 0 if you want the coordinate information to be relative to the top and left coordinates of the panel, excluding the frame and title bar.
Output
Name Type Description
xCoordinate int X-coordinate of the mouse cursor relative to the left edge of the control, or panel, if controlID is 0.

You can pass NULL.
yCoordinate int Y-coordinate of the mouse cursor relative to the top of the control, or panel, if controlID is 0.

You can pass NULL.
leftButtonDown int The state of the left mouse button.

0 if the left button is up. 1 if the left button is down.

You can pass NULL.
rightButtonDown int The state of the right mouse button.

0 if the right button is up. 1 if the right button is down.

You can pass NULL.
keyModifiers int State of the keyboard modifiers, in other words, the <Ctrl>, <Alt>, and <Shift> keys.

If no keys are down, the value is 0. Otherwise, the value is the bitwise OR of the appropriate key masks: VAL_MENUKEY_MODIFIER, VAL_UNDERLINE_MODIFIER, VAL_SHIFT_MODIFIER, and VAL_SHIFT_AND_MENUKEY.

You can pass NULL.

Return Value

Name Type Description
status int Return value indicating whether the function was successful. A negative number indicates that an error occurred.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later

Examples

Refer to the following examples that use the GetRelativeMouseState function:

  • apps\life\life.cws

    Open example
  • userint\canvas.cws

    Open example
  • userint\moustate.cws

    Open example
  • userint\custctrl\cviogl\oglarm.cws

    Open example