Tags: box, control, coordinates, corner, form, net, picture, placed, point, screen, sharp, upper

How to get screen coordinates of a control

On .Net » .Net C# (C sharp)

868 words with 2 Comments; publish: Sat, 09 Feb 2008 13:35:00 GMT; (10066.41, « »)


i have to find out screen coordinates of upper left corner of a picture box placed on the form.

Point p = pictureBox1.PointToScreen(pictureBox1.Location);

i use PointToScreen() to get the coordiantes but these are not exact screen coordinates as i validate it by using PointToScreen() in MouseDown method and find the screen coordinates on mouse down but the coordinates are not same.

can any one helps me.



All Comments

Leave a comment...

    • pictureBox1.Location is picturebox top-left point in parent form coordinates. To translate it to screen coordinates, you need to call parent's function:

      Point p = this->PointToScreen(pictureBox1.Location);

      (Assuming that this code belongs to parent form).

      #1; Fri, 09 Nov 2007 01:52:00 GMT
    • hi,

      its working

      Point p = this.PointToScreen(pictureBox1.Location);



      #2; Fri, 09 Nov 2007 01:53:00 GMT