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