LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Events for movabel controls

When using movable controls as shown in the movedemo example, is there any specific event generated when the user starts moving a specific control?

And a specific event generated when the control is released in its new position?

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 1 of 10
(4,193 Views)

Vix:

 

The movedemo program was created before LabWindows/CVI had built-in support for mouse events.  You can see how they tracked the mouse by looking at the source for the movectrl function panel, movectrl.c under [CVI parent directory]\toolslib\custctrl.  For example, you can look at the TrackPartMove() function and the calls to GetRelativeMouseState().

 

With the newer CVI support for mouse events, you could use EVENT_LEFT_CLICK and EVENT_LEFT_CLICK_UP.

0 Kudos
Message 2 of 10
(4,185 Views)

 


With the newer CVI support for mouse events, you could use EVENT_LEFT_CLICK and EVENT_LEFT_CLICK_UP.

I know that CVI supports this events, but how can I know if one of them is a "simple" mouse click or is as "moving" mouse click?

 

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 3 of 10
(4,169 Views)

Vix:

 

First look for a left click with EVENT_LEFT_CLICK,

then watch for movement with EVENT_MOUSE_POINTER_MOVE,

until you receive EVENT_LEFT_CLICK_UP

 

You probably don't want to watch for EVENT_MOUSE_POINTER_MOVE until the control fires EVENT_LEFT_CLICK, otherwise you'll be processing mouse coordinate data whenever the pointer just passes over the control.

0 Kudos
Message 4 of 10
(4,166 Views)

Hi Al S,

probably I didn't explain my question very well.

I know how to use the mouse-related events, and I've already used them in a lot of applications.

 

The problem is that when the CTRL key is hold down, the EVENT_LEFT_CLICK is not generated, but EVENT_LEFT_CLICK_UP is generated.

And so I didn't find an easy way to know if the left-click happens when the CTRL key is hold (i.e.. what I called a "moving left-click")

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 5 of 10
(4,156 Views)

Vix:

 

EVENT_LEFT_CLICK is generated when the Control key is held down.  Try the attached example.  I tested it in CVI 6.0 and 2010.  I don't have 2009 installed on my machine.

 

If you want to check the Control key state when it's left-clicked, you can use the Windows SDK function GetKeyState().  You need to include windows.h in you calling C file, and add user32.lib to your project.  See the attached example.

0 Kudos
Message 6 of 10
(4,147 Views)

When the control has been converted to a movable one calling MakeMovableCtrl(), EVENT_LEFT_CLICK is swallowed by the dynamic callback of the movable control, so this event is no more sent to my application.

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 7 of 10
(4,143 Views)

Vix:

 

OK, now I think I finally understand your question.  Sorry it took so long to sink in.

 

I don't think there is a MOVE event for controls.  (There is one for panels).

 

How about using Windows messaging?

 

You could InstallWinMsgCallback() in your app, and modify movectrl.c to call the Windows SDK functions PostMessage() or SendMessage() when you start to move or stop moving a control.

0 Kudos
Message 8 of 10
(4,132 Views)

I prefer not to modify the instruments supplied by CVI because I have to manually update them after every CVI update.

In this case I need to be notified if a control has been moved (so that I can perform some actions): the solution in quite simple (in my mind)

  1. save the original coordinates at CTRL+left click event
  2. save the final coordinates at left click-up event
  3. check if the coordinates are different

Isn't there any simple way to do this?

Should I modify the movectrl.c source file?

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 9 of 10
(4,118 Views)

Vix:

 

Here's a suggestion that's cumbersome but straight-forward.

 

At startup, create a global array and save the coordinates for all the controls that you will allow to be moved.

Since you already found out that Ctrl-Left-click gets swallowed once the control is movable, you won't know when the movement starts, but you will know (using EVENT_LEFT_CLICK_UP) when the movement stops.

In each control callback, on EVENT_LEFT_CLICK_UP, get the current control coordinates and compare them to the coordinates in your gobal array.  Update the array and take appropriate action if the coordinates are different.

 

This may be a pain and a performance hit if you have a lot of controls that might be movable.

 

You could also post a suggestion to the CVI Idea exchange that NI create an EVENT for moving a control.

http://forums.ni.com/t5/LabWindows-CVI-Idea-Exchange/idb-p/cviideas

 

0 Kudos
Message 10 of 10
(4,112 Views)