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. Mobile Development
  3. Mobile
  4. How to get Window Rect coordinates wrt to its parent window rect coordinates.

How to get Window Rect coordinates wrt to its parent window rect coordinates.

Scheduled Pinned Locked Moved Mobile
c++tutorial
6 Posts 2 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.
  • S Offline
    S Offline
    subramjobmail
    wrote on last edited by
    #1

    Dear Friends, Does anybody know how to get child Window Rect coordinates wrt to parent window Rect coordinates. [Something similar to GetRectInContainer()]. I want in SDK rather than in MFC. Thanks in advance, subramjobmail.

    D 1 Reply Last reply
    0
    • S subramjobmail

      Dear Friends, Does anybody know how to get child Window Rect coordinates wrt to parent window Rect coordinates. [Something similar to GetRectInContainer()]. I want in SDK rather than in MFC. Thanks in advance, subramjobmail.

      D Offline
      D Offline
      Daniel Strigl
      wrote on last edited by
      #2

      Do you mean you want the position of your client window inside the parent window?

      RECT rtClient;
      // Get the position of the client in screen coordinates
      GetWindowRect(hClientWnd, &rtClient);
      // Converts the screen coordinates to client coordinates
      ScreenToClient(hClientWnd, (LPPOINT) &rtClient.left);
      ScreenToClient(hClientWnd, (LPPOINT) &rtClient.right);

      Daniel ;) --------------------------- Never change a running system!

      S 1 Reply Last reply
      0
      • D Daniel Strigl

        Do you mean you want the position of your client window inside the parent window?

        RECT rtClient;
        // Get the position of the client in screen coordinates
        GetWindowRect(hClientWnd, &rtClient);
        // Converts the screen coordinates to client coordinates
        ScreenToClient(hClientWnd, (LPPOINT) &rtClient.left);
        ScreenToClient(hClientWnd, (LPPOINT) &rtClient.right);

        Daniel ;) --------------------------- Never change a running system!

        S Offline
        S Offline
        subramjobmail
        wrote on last edited by
        #3

        You understanding is correct but the code block which you have given will give only wrt to screen point. But i want wrt to parent window RECT of hClientWnd. It should proper values (-ve values) if scrolled [partially visible] Something like how GetRectInContainer() gives in OCX wrt to IE

        D 1 Reply Last reply
        0
        • S subramjobmail

          You understanding is correct but the code block which you have given will give only wrt to screen point. But i want wrt to parent window RECT of hClientWnd. It should proper values (-ve values) if scrolled [partially visible] Something like how GetRectInContainer() gives in OCX wrt to IE

          D Offline
          D Offline
          Daniel Strigl
          wrote on last edited by
          #4

          But the ScreenToClient method will convert the screen coordinates to client coordinates! Daniel ;) --------------------------- Never change a running system!

          S 1 Reply Last reply
          0
          • D Daniel Strigl

            But the ScreenToClient method will convert the screen coordinates to client coordinates! Daniel ;) --------------------------- Never change a running system!

            S Offline
            S Offline
            subramjobmail
            wrote on last edited by
            #5

            But i want functionality some thing similar to what GetRectInContainer() of COleControl class gives in OCX control.

            D 1 Reply Last reply
            0
            • S subramjobmail

              But i want functionality some thing similar to what GetRectInContainer() of COleControl class gives in OCX control.

              D Offline
              D Offline
              Daniel Strigl
              wrote on last edited by
              #6

              Something like this?

              HWND hWndParent = ... // Handle to the parent window
              HWND hWndChild = ... // Handle to the child window

              ASSERT(hWndParent);
              ASSERT(hWndChild);

              RECT rt;
              ::GetWindowRect(hWndChild, &rt);
              ::MapWindowPoints(HWND_DESKTOP, hWndParent, (LPPOINT) &rt, 2);

              -- Cheers, Daniel ;)

              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