LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Also the movectrl.fp usage

In the usage , I must hold the Ctrl key to move a control , is there any way to move a control
just to use the mouse at run-time ?
0 Kudos
Message 1 of 3
(2,982 Views)
If you don't want to use the Ctrl plus mouse combinations in movectrl.fp, you can move a control using extended mouse events from toolbox.fp.
Add toolbox.fp to your project.
#include "toolbox.h" in your source code.
Call EnableExtendedMouseEvents for the control you want to be able to move.
Create a callback function for the control you want to be able to move.
In the callback function, check for EVENT_LEFT_CLICK, EVENT_LEFT_MOUSE_UP, and EVENT_MOUSE_MOVE.
Do some logic with some globals or the control's callbackData.
Enable the move when you get EVENT_LEFT_CLICK.
Stop the move when you get EVENT_LEFT_MOUSE_UP.
Know where to move using the eventData1 and eventData2 in EVENT_MOUSE_MOVE.
Move the control using SetCtrlAttribute() to set the control's Left and Top pos
ition.
Note that you'll get EVENT_MOUSE_MOVE when the mouse is moved anywhere on the panel, not just over the control. Ignore EVENT_MOUSE_MOVE unless the move was enabled by EVENT_LEFT_CLICK.
You may want to qualify the move based on a minimum distance or minimum time from EVENT_LEFT_CLICK to EVENT_LEFT_MOUSE_UP so you don't move the control anytime the user clicks on it.
Depending on the control, you may want to include a checkbox to enable control moves. For example, if you have a slider or tank control, you want to be able to use the mouse to operate the control, not just move it. It you have a string control, you may want to use the mouse to select text, not just move the control.
0 Kudos
Message 2 of 3
(2,982 Views)
Hi AIS ,

Thanks for your advise . But I am still not get the gist , would you please give me a simple example ? Your advise is highly appreciated .

David
(davidlee@163.com)
0 Kudos
Message 3 of 3
(2,982 Views)