Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
3 ratings:
 4.66 out of 5     Rate this Document

Monitoring Mouse Position in LabWindows/CVI

Primary Software: LabWindows/CVI Development Systems>>Full Development System
Primary Software Version: 8.1
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:
When a command button on the user interface is pressed and held down, I want some repetitive task to occur (i.e. a button controlling the volume of a stereo). In this situation, I need two pieces of information which are whether the mouse button is still down or not and whether the user has moved the mouse cursor outside the region of the button. How can I detect these mouse settings in LabWindows/CVI?

Solution:
In LabWindows/CVI you can use the GetGlobalMouseState() and GetRelativeMouseState() functions to attain the information mentioned above. The GetGlobalMouseState function returns the position of the mouse relative to the top, left corner of the screen. The GetRelativeMouseState function returns the position of the mouse relative to the top and left coordinates of a specific control. Both functions return information about the left and right mouse button state as well as whether a keyboard modifier was pressed.

You can also enable extended mouse events by using the EnableExtendedMouseEvents() function. This function enables a control to receive the following extended mouse events in addition to the built-in mouse events
  • EVENT_MOUSE_MOVE
  • EVENT_LEFT_MOUSE_UP
  • EVENT_RIGHT_MOUSE_UP

LabWindows/CVI 8.1 made the EnableExtendedMouseEvents function obsolete as new built-in mouse events were introduced.

Refer to the LabWindows/CVI Help for more information about built-in mouse events and the functions mentioned earlier.

Related Links:
KnowledgeBase 4449ACGJ: Capturing Left and Right Click Up Mouse Events in LabWindows/CVI
Developer Zone Tutorial: Retrieving Mouse States
Developer Zone Example: Determine the Current State of the Mouse

Attachments:





Report Date: 12/18/1995
Last Updated: 12/29/2006
Document ID: 0GHA3UZL

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit