Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. prob with coordinates

prob with coordinates

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicsquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Krauze
    wrote on last edited by
    #1

    I'm coding with VC++2008. When designing the layout of the controls in the .rc file, we can see their coordinates in the bottomright of the screen. And now I have a control with (4,30) shown there and another one with (5,156). Then I wanna draw a line between these 2 controls using the coordinates by GDI.

    pDC->MoveTo(4,30);
    pDC->LineTo(5,156);
    

    But at runtime, the line doesn't correspond to those coordinates. I mean there is a big offset from the expected position. What's wrong? Thx in advance.

    M C 2 Replies Last reply
    0
    • K Krauze

      I'm coding with VC++2008. When designing the layout of the controls in the .rc file, we can see their coordinates in the bottomright of the screen. And now I have a control with (4,30) shown there and another one with (5,156). Then I wanna draw a line between these 2 controls using the coordinates by GDI.

      pDC->MoveTo(4,30);
      pDC->LineTo(5,156);
      

      But at runtime, the line doesn't correspond to those coordinates. I mean there is a big offset from the expected position. What's wrong? Thx in advance.

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      Units in the resource editor are in DLU ( Dialog (il)Logical Unit); they are used to handle the large font/small font display settings. from msdn : dialog unit A unit of horizontal or vertical distance within a dialog box. A horizontal DLU is the average width of the current dialog-box font divided by 4. A vertical DLU is the average height of the current dialog-box font divided by M.

      Watched code never compiles.

      K 1 Reply Last reply
      0
      • M Maximilien

        Units in the resource editor are in DLU ( Dialog (il)Logical Unit); they are used to handle the large font/small font display settings. from msdn : dialog unit A unit of horizontal or vertical distance within a dialog box. A horizontal DLU is the average width of the current dialog-box font divided by 4. A vertical DLU is the average height of the current dialog-box font divided by M.

        Watched code never compiles.

        K Offline
        K Offline
        Krauze
        wrote on last edited by
        #3

        thx a lot!

        1 Reply Last reply
        0
        • K Krauze

          I'm coding with VC++2008. When designing the layout of the controls in the .rc file, we can see their coordinates in the bottomright of the screen. And now I have a control with (4,30) shown there and another one with (5,156). Then I wanna draw a line between these 2 controls using the coordinates by GDI.

          pDC->MoveTo(4,30);
          pDC->LineTo(5,156);
          

          But at runtime, the line doesn't correspond to those coordinates. I mean there is a big offset from the expected position. What's wrong? Thx in advance.

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          if you want to draw a line between two controls, the safest way is to get the controls' actual on-screen positions, something like:

          CRect r1, r2;
          ctrl1.GetWindowRect(&r1);
          ScreenToClient(r1);

          ctrl2.GetWindowRect(&r2);
          ScreenToClient(r2);

          dc.MoveTo(r1.right, r1.top);
          dc.LineTo(r2.left, r2.top);

          image processing toolkits | batch image processing

          K 1 Reply Last reply
          0
          • C Chris Losinger

            if you want to draw a line between two controls, the safest way is to get the controls' actual on-screen positions, something like:

            CRect r1, r2;
            ctrl1.GetWindowRect(&r1);
            ScreenToClient(r1);

            ctrl2.GetWindowRect(&r2);
            ScreenToClient(r2);

            dc.MoveTo(r1.right, r1.top);
            dc.LineTo(r2.left, r2.top);

            image processing toolkits | batch image processing

            K Offline
            K Offline
            Krauze
            wrote on last edited by
            #5

            thx a lot

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups