What is the difference in size and coordinate measurement in Forms from C #

3

In my project I work with the distance of elements and their size. But on a 600-by-600 screen, when you insert a 100-percent object, it appears to be much smaller than 1/6 of the screen, and when checking the distance from the object's center point to the Mouse

//descobrir o ponto central do objeto atual
Point ponto_central_obj = new Point(objeto.Location.X+50,objeto.Location.Y+50);
//calcular distancia X e Y
int distancia_x = ponto.X - ponto_central_obj.X;
int distancia_y = ponto.Y - ponto_central_obj.Y;
if(distancia_x < 0){distancia_x = distancia_x * -1;}
if(distancia_y < 0){distancia_y = distancia_y * -1;}
int distancia = Math.Sqrt((distancia_x ^ 2) + (distancia_y ^ 2));

And by passing the mouse near the edge the given distance is 15, 16 or something close, which is much smaller than 50, which is the minimum distance from the center point to the edge of the object.

Questions

Based on this I ask the following questions.

  • Are the x and y coordinates not the distance in pixels from the upper left corner of the screen?

  • If not, how to convert the value to distance in pixels ?

  • Are they relative to the size of the parent object?

asked by anonymous 05.09.2014 / 15:08

1 answer

2
  

Are the x and y coordinates not the distance in pixels from the upper-left corner of the screen?

     

Are they relative according to the size of the parent object?

Yes, this is it. The x, y value 0,0 means the top left of the container object. So if you put any other object inside the main Form which is your window at position 10.20 you will be placing in the "column" 10 (holding in a horizontal ruler) the useful part of the window (excluding border for example) and "line" 20 (on a vertical ruler).

Cartesian coordinates are always calculated inside the object where another object is being added. So this should be giving the feeling that you're wrong.

You are not in a canvas , on a free screen to put what you want, you always have the parent object as your "screen" at the moment.     

05.09.2014 / 18:03