LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get x position from a canvas control

How to get a x position from a canvas control after call func CanvasDrawTextAtPoint (panel, ctrl,distxt,text_style, MakePoint(x,y), VAL_LOWER_LEFT);  
 
for example: x=5,y=20;
distxt="This is a test"
 
I want to get a value of x after calling above function. Anybody know? thanks in advance
0 Kudos
Message 1 of 3
(3,215 Views)
I'm not sure I understand your question completely, but my guess is that you would like to know where the right edge of your text string is, in the canvas. Assuming that you are not changing the x and y offsets of the canvas, the coordinates used by the canvas are just pixels. So to find out the right edge of the string, you only need to find out how wide it is, and then add the initial x to it.

The function GetTextDisplaySize can tell you how much space a given string takes, when using a particular font. Just pass it the same distxt and text_style parameters that you are passing to CanvasDrawTextAtPoint

Luis
NI
0 Kudos
Message 2 of 3
(3,210 Views)
Your guess is correct, that func. is the one I needed
 
Thanks LuisG
0 Kudos
Message 3 of 3
(3,193 Views)