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. Getting the coordinate of a child window

Getting the coordinate of a child window

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

    I having a problem with a control (say an edit box) on a Dialogue or FormView. in my resource script is as follows EDITTEXT IDC_EDIT1,34,50,26,14,ES_AUTOHSCROLL | NOT WS_BORDER PUSHBUTTON "&Size Info",IDC_SIZE_INFO,69,91,56,26 I've a handler for the button as follows:

    1. void CMyDialog::OnSizeInfo() { CRect ButtonRect, EditRect; CWnd *pEdit = GetDlgItem(IDC_EDIT1); CWnd *pButton = GetDlgItem(IDC_SIZE_INFO); pEdit->GetClientRect(EditRect); pButton->GetClientRect(ButtonRect); }
    2. void CMyDialog::OnSizeInfo() { CRect ButtonRect, EditRect; CWnd *pEdit = GetDlgItem(IDC_EDIT1); CWnd *pButton = GetDlgItem(IDC_SIZE_INFO); pEdit->GetWindowRect(EditRect); pButton->GetWindowRect(ButtonRect); }
    3. void CMyDialog::OnSizeInfo() { CRect ButtonRect, EditRect; CWnd *pEdit = GetDlgItem(IDC_EDIT1); CWnd *pButton = GetDlgItem(IDC_SIZE_INFO); ::GetClientRect(pEdit,EditRect); ::GetClientRect(pButton,ButtonRect); }
    4. void CMyDialog::OnSizeInfo() { CRect ButtonRect, EditRect; CWnd *pEdit = GetDlgItem(IDC_EDIT1); CWnd *pButton = GetDlgItem(IDC_SIZE_INFO); ::GetWindowRect(pEdit,EditRect); ::GetWindowRect(pButton,ButtonRect); }

    in all cases the top and left properties are 0 and 0 and not 34 and 50 (EditRect) or 69 and 91 (ButtonRect). How I get this programatically. Many thanks Alton

    O 1 Reply Last reply
    0
    • A Alton Williams

      I having a problem with a control (say an edit box) on a Dialogue or FormView. in my resource script is as follows EDITTEXT IDC_EDIT1,34,50,26,14,ES_AUTOHSCROLL | NOT WS_BORDER PUSHBUTTON "&Size Info",IDC_SIZE_INFO,69,91,56,26 I've a handler for the button as follows:

      1. void CMyDialog::OnSizeInfo() { CRect ButtonRect, EditRect; CWnd *pEdit = GetDlgItem(IDC_EDIT1); CWnd *pButton = GetDlgItem(IDC_SIZE_INFO); pEdit->GetClientRect(EditRect); pButton->GetClientRect(ButtonRect); }
      2. void CMyDialog::OnSizeInfo() { CRect ButtonRect, EditRect; CWnd *pEdit = GetDlgItem(IDC_EDIT1); CWnd *pButton = GetDlgItem(IDC_SIZE_INFO); pEdit->GetWindowRect(EditRect); pButton->GetWindowRect(ButtonRect); }
      3. void CMyDialog::OnSizeInfo() { CRect ButtonRect, EditRect; CWnd *pEdit = GetDlgItem(IDC_EDIT1); CWnd *pButton = GetDlgItem(IDC_SIZE_INFO); ::GetClientRect(pEdit,EditRect); ::GetClientRect(pButton,ButtonRect); }
      4. void CMyDialog::OnSizeInfo() { CRect ButtonRect, EditRect; CWnd *pEdit = GetDlgItem(IDC_EDIT1); CWnd *pButton = GetDlgItem(IDC_SIZE_INFO); ::GetWindowRect(pEdit,EditRect); ::GetWindowRect(pButton,ButtonRect); }

      in all cases the top and left properties are 0 and 0 and not 34 and 50 (EditRect) or 69 and 91 (ButtonRect). How I get this programatically. Many thanks Alton

      O Offline
      O Offline
      ohadp
      wrote on last edited by
      #2

      You can : CPoint pt(0,0); child->ClientToScreen(&pt); parent->ScreenToClient(&pt); I believe pt will now contain the position of child relative to parent.

      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