LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Command Button Events

Using a command button (configured as "hot" or "validate") - When button is "pressed" I get the EVENT_LEFT_CLICK, but if the mouse is dragged away from the button before being release there is no EVENT_COMMIT. Something knows to change the color of the button - how do I detect or receive notification the mouse is no longer over the button?

Thanks,

Scott.
0 Kudos
Message 1 of 3
(2,806 Views)
You accurately describe the behavior of a command button in CVI. The control does not generate any event after EVENT_LEFT_CLICK if the mouse is dragged away from the control before being released. You don't need to program that behavior: it's built in. And it's not just CVI command buttons: try this in most Windows apps: goto File >> Open, select a file, then point to Open (or OK), press and hold the left mouse button, then drag the mouse off the control. The new file won't be opened.
OK, so maybe that's all something you already knew.
If you want to know if the mouse is over a control, you need to know the position of the mouse pointer and the position and size of the control. CVI does not generate a mouse-over event. You can use Extended Mouse Events in the
Programmer's Toolbox. Add toolbox.fp to your project. After you EnableExtendedMouseEvents(), EVENT_MOUSE_MOVE will be generated when you move the mouse. Then you can check if the pointer (location in eventData) is over the control. Click here to see some additional discussion. Chris Matthews gives a code snippet and some explanation. Near the bottom, I give an example of MouseOver with a non-rectangular control.
Message 2 of 3
(2,806 Views)
Thanks that helped.

I'm using Visual Studio, including toolbox.c in my project gives me access to the data I need.
0 Kudos
Message 3 of 3
(2,806 Views)