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. coordinates of a child window bug??

coordinates of a child window bug??

Scheduled Pinned Locked Moved C / C++ / MFC
helptoolstutorialquestionlearning
3 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.
  • A Offline
    A Offline
    Alton Williams
    wrote on last edited by
    #1

    I wanted to know the coordinate of a child window in relation to a parent window. To recap my resource scriptEDITTEXT IDC_EDIT1,34,50,26,14,ES_AUTOHSCROLL | NOT WS_BORDER PUSHBUTTON "&Size Info",IDC_SIZE_INFO,69,91,56,26 Someone replied (thanks) saying that i code as follows: CPoint pt(0,0); //initialised to zero for calculations child->ClientToScreen(&pt); // called from the child window parent->ScreenToClient(&pt); // called from the parent window My problem is that not getting the correct correct coordinates can anyone explain why it's happening and how to I go about doing it. Many thanks in advance. Alton

    A RaviBeeR 2 Replies Last reply
    0
    • A Alton Williams

      I wanted to know the coordinate of a child window in relation to a parent window. To recap my resource scriptEDITTEXT IDC_EDIT1,34,50,26,14,ES_AUTOHSCROLL | NOT WS_BORDER PUSHBUTTON "&Size Info",IDC_SIZE_INFO,69,91,56,26 Someone replied (thanks) saying that i code as follows: CPoint pt(0,0); //initialised to zero for calculations child->ClientToScreen(&pt); // called from the child window parent->ScreenToClient(&pt); // called from the parent window My problem is that not getting the correct correct coordinates can anyone explain why it's happening and how to I go about doing it. Many thanks in advance. Alton

      A Offline
      A Offline
      Antony M Kancidrowski
      wrote on last edited by
      #2

      To get a client rectangle of a child do the following:

      CRect crChild;

      pWndChild->GetWindowRect(&crChild);
      ScreenToClient(&crChild);

      Things to Note: This is called from the CWnd derived class of the parent. pWndChild is a pointer to the child window you want the coordinates for. Ant.

      1 Reply Last reply
      0
      • A Alton Williams

        I wanted to know the coordinate of a child window in relation to a parent window. To recap my resource scriptEDITTEXT IDC_EDIT1,34,50,26,14,ES_AUTOHSCROLL | NOT WS_BORDER PUSHBUTTON "&Size Info",IDC_SIZE_INFO,69,91,56,26 Someone replied (thanks) saying that i code as follows: CPoint pt(0,0); //initialised to zero for calculations child->ClientToScreen(&pt); // called from the child window parent->ScreenToClient(&pt); // called from the parent window My problem is that not getting the correct correct coordinates can anyone explain why it's happening and how to I go about doing it. Many thanks in advance. Alton

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #3

        Coordinates in a resource file are specified in dialog base units, while coordinates used in Windows get/move/size APIs are specified in pixels. GetDialogBaseUnits() is one method you can use to convert between the two. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        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