LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to move controls without using the CTRL key via the movedemo example

But have been unable to determine how I could accomplish this task. Inserting a Timer control with FakeKeystroke doesn't work and there are not event callback functions that I can use or modify. Anyone have a idea how I could do this? I've attached the movedemo.zip file to this post. Thanks Dalemcc55
0 Kudos
Message 1 of 4
(3,428 Views)
The ability to detect mouse actions and move controls lies inside the movectrl.fp, precisely in the DynamicCtrlCallback automatically chained to the control when you call MakeMovableCtrl from your source.

To modify the behaviour of this program you will need to modify the movedemo.c source and generate a new version of the instrument; be careful to study present behaviour of the instrument in order to fully understand its internal structure.

I personally don't like to do this 'cause you will need to check your modified version of the instrument at every future release of CVI, since this may rely on functions that have been updated; but if this modification is necessary for your application, the source code of the instrument is distributed so you can modify it.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(3,401 Views)
The attached example shows one way of allowing the operator to move controls after using radio buttons to select Edit Mode vs. Run Mode. The example does the following:
Select some controls to be movable. The selection is hard-coded, not run-time selectable.
Save the initial control positions as default positions.
Use radio buttons to select Run Mode or Edit Mode.
If in Edit Mode, watch panel for left-clicks and check if the click is on a movable control. Use extended mouse events EVENT_MOUSE_MOVE and EVENT_LEFT_MOUSE_UP from Programmer's Toolbox (after adding toolbox.fp to the project) to update the control position as its being moved and stop moving it when the mouse button is released.
What's wrong with the way movedemo works using the Control key? How would you like to move controls?
0 Kudos
Message 3 of 4
(3,378 Views)
I must be using a different version of CVI that you 5.5 because upon running the program I get a NON_FATAL RUN TIME ERROR at the LoadPanel function. The .uir file must contain a new or upgraded control type. But I appreceiate your efforts on my behalf. I found a way to move controls and have attached the code segments below.
Maybe they will become useful for you or someone else one day. Thanks again! Dale

In the control callback function a global variable is set to the selected control value. i.e. Control = control;
Then the panel callback function is called and it does all the work.

int CVICALLBACK Panel (int panel, int event, void *callbackData,
int eventData1, int eventData2)
{
int status;
int keyMods, rightState, leftState, x, y;

if ( Control == 0 ) return 0; //if no control exit function
if ( Control == PANEL_QUITBUTTON ) return 0; //exit function if Quit button clicked
switch (event)
{
case EVENT_LEFT_CLICK:
SetCtrlAttribute (panel, Control, ATTR_CTRL_VAL, 1); //change control color (LED)
do
{
status = GetRelativeMouseState (panel, 0, &x, &y, &leftState, &rightState,keyMods);
SetCtrlAttribute (panel, Control, ATTR_LEFT, x - 20);
SetCtrlAttribute (panel, Control, ATTR_TOP, y - 20);
SetCtrlAttribute (panel, Control, ATTR_ZPLANE_POSITION, 0);
ProcessDrawEvents ();

} while(leftState == DOWN );
SetCtrlAttribute (panel, Control, ATTR_CTRL_VAL, 0); //change color back to default
Reorder(Control, x, y);
break;
case EVENT_CLOSE:
QuitUserInterface (0);
break;
}
return 0;
}
0 Kudos
Message 4 of 4
(3,346 Views)