LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can not show control in the position of the mouse click

Hello,

 

Hope by the "NewCtrl()" function to generate a picture ring control on a canvas when clicking the canvas control.

 

Using the "GetRelativeMouseState(panelHandle, CANVAS_ID, &xCoor, &yCoor, NULL, NULL, NULL); " to get the mouse click coordinate, then using NewCtrl() to generate the control, but the picture ring cannot be placed on the click position. How to get the right position?

 

 

David

0 Kudos
Message 1 of 2
(2,941 Views)

This is the expected behaviour: GetRelativeMouseState gives coordinates referred to the canvas (command help clarifies it: "xCoordinate and yCoordinate return the position of the mouse relative to the top and left coordinates of a specific control"), while you must set the control in absolute panel coordinates.

If you are handling a click event, you can use eventData parameters that holds mouse coordinates, this way:

 

        controlID = NewCtrl (panel, CTRL_NUMERIC_LS, 0, eventData1, eventData2);



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?
Message 2 of 2
(2,928 Views)