LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NewCtrl vs DrawCanvas Coordinate System

I created a new control using

 int control = NewCtrl (panelHandle, CTRL_ROUND_LED, 0, y, x);

and then I drew a line using the same coordinate (x,y) using the code below.

I expected the cross hair lines to be at least near the newly created LED, 

but they are not.  They are far away.  The CanvasDrawLine(), I think

is using the top-left as the origin.  The NewCtrl() seems NOT.

How do I reconcile the coordinates used in CanvasDrawLine() and

NewCtrl() functions.

 

Point start, end;

start.x = x - 50; end.x = x + 50;
start.y = y; end.y = y;
CanvasDrawLine(panelHandle, canvas, start, end);

start.x = x; end.x = x;
start.y = y - 50; end.y = y + 50;
CanvasDrawLine(panelHandle, canvas, start, end);

 

 

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

NewCtrl indeed uses the top left corner of the panel as the origin, the same applies to ATTR_TOP and ATTR_LEFT control attributes (including of course your canvas control). The origin of all CanvasDraw functions, instead, is the top left corner of the canvas itself. That is to say, coordinates of controls placed on top of a canvas can be mapped to point on the canvas by offsetting them by the top and left position of the canvas control.

 

As a side note, if you are using a menubar in your panel, this is not considered in getting control coordinates: the top position of controls always refers to the point immediately below the title bar, regardless the presence of a menu bar.



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 2
(2,200 Views)