How to get screen coordinates of a control
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: How to get screen coordinates of a control

  1. #1
    Join Date
    May 2002
    Posts
    72

    How to get screen coordinates of a control

    hi,

    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.

    Regards
    Alexen

  2. #2
    Join Date
    Jul 2002
    Posts
    2,526

    Re: How to get screen coordinates of a control

    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).

  3. #3
    Join Date
    May 2002
    Posts
    72

    Re: How to get screen coordinates of a control

    hi,

    its working

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

    Thanks
    Alexen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center