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. Problem with Coordinates....

Problem with Coordinates....

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialquestion
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.
  • R Offline
    R Offline
    Ravi Sankar S
    wrote on last edited by
    #1

    Hello All, I am having a List control in my [B]Form View[/B]. I want to create it dynamically by calling "CreateEx". My problem is when I am creating it is creating in different location than where I placed in the form. The code ( VC++ 6.0 / Windows 2000) is given below DWORD dwStyle = LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP; CRect rect; GetDlgItem (IDC_LIST1)->GetWindowRect(&rect); VERIFY(m_oTabList.CreateEx(WS_EX_CLIENTEDGE, _T("TestControl"), _T(""), dwStyle, rect, this, IDC_LIST1, NULL)); GetWindowRect returns values {104, 400, 27, 498}. The Control is placed much below the location where i created. Then I tried to use GetClientRect instead of GetWindowRect. At this time the value returned {0, 292, 0, 467} This time it draws at the top of the client area. How to get the control location with respect to client area? Thanks in Advance Ravi

    T P 2 Replies Last reply
    0
    • R Ravi Sankar S

      Hello All, I am having a List control in my [B]Form View[/B]. I want to create it dynamically by calling "CreateEx". My problem is when I am creating it is creating in different location than where I placed in the form. The code ( VC++ 6.0 / Windows 2000) is given below DWORD dwStyle = LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP; CRect rect; GetDlgItem (IDC_LIST1)->GetWindowRect(&rect); VERIFY(m_oTabList.CreateEx(WS_EX_CLIENTEDGE, _T("TestControl"), _T(""), dwStyle, rect, this, IDC_LIST1, NULL)); GetWindowRect returns values {104, 400, 27, 498}. The Control is placed much below the location where i created. Then I tried to use GetClientRect instead of GetWindowRect. At this time the value returned {0, 292, 0, 467} This time it draws at the top of the client area. How to get the control location with respect to client area? Thanks in Advance Ravi

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      Ravi Sankar S wrote: How to get the control location with respect to client area? Api [ScreenToClient] Will help

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta VC Forum Q&A :- I/ IV

      1 Reply Last reply
      0
      • R Ravi Sankar S

        Hello All, I am having a List control in my [B]Form View[/B]. I want to create it dynamically by calling "CreateEx". My problem is when I am creating it is creating in different location than where I placed in the form. The code ( VC++ 6.0 / Windows 2000) is given below DWORD dwStyle = LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP; CRect rect; GetDlgItem (IDC_LIST1)->GetWindowRect(&rect); VERIFY(m_oTabList.CreateEx(WS_EX_CLIENTEDGE, _T("TestControl"), _T(""), dwStyle, rect, this, IDC_LIST1, NULL)); GetWindowRect returns values {104, 400, 27, 498}. The Control is placed much below the location where i created. Then I tried to use GetClientRect instead of GetWindowRect. At this time the value returned {0, 292, 0, 467} This time it draws at the top of the client area. How to get the control location with respect to client area? Thanks in Advance Ravi

        P Offline
        P Offline
        PravinSingh
        wrote on last edited by
        #3

        You have two options: i) Use GetWindowRect (which gives you rect in terms of screen coordinates) and then convert it using ScreenToClient. Then add the offset that you want to have for your list control from the top-left of your dialog. ii) Use GetClientRect (which will directly give you the rectangle of YOUR COMPLETE DIALOG). So you need to add some offset to the top-left point (which is (0,0) right now), and subtract some offset from the bottom-right point. Ravi Sankar S wrote: At this time the value returned {0, 292, 0, 467} This time it draws at the top of the client area. So from your description, I think using the rect {10, 250, 10, 400} would perhaps suit your needs.:) Regards, Pravin.

        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