Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Retrieving Mouse States

0 ratings | 0.00 out of 5
Print
There are various ways of retrieving mouse states in CVI. The mouse control events return the coordinates of the mouse. When you have an EVENT_LEFT_CLICK, EVENT_RIGHT_CLICK, EVENT_LEFT_DOUBLE_CLICK or EVENT_RIGHT_DOUBLE_CLICK then the callback functions eventData1 and eventData2 parameters contain the current location of the mouse. This is useful, for example, when you want to display a pop-up menu in your program whenever you right click on a control.

There are also two functions in CVI that are useful in getting the state of the mouse.
  • The GetGlobalMouseState function obtains information about the state of the mouse cursor where the X and Y coordinates are set to the position of the mouse relative to the top, left corner of the screen.
  • The GetRelativeMouseState function obtains information about the state of the mouse cursor where the X and Y coordinates are set to the position of the mouse relative to the top and left coordinates of the control specified.

If Control ID of 0 is passed in the above functions, the coordinate information is relative to the top and left coordinates of the panel specified, excluding the frame and title bar. The coordinates return even if the mouse is not over the control or the panel.

Another useful function is the SetMouseCursor function, which is available in the User Interface Library. This function allows you to change the style of the cursor. For example, you can display the cursor as a cross hair, box, pointing finger, or hour glass.


0 ratings | 0.00 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).