Code Comments
Programming Forum and web based access to our favorite programming groups.According to all articles about GetWindowRect it returns positon relative to "upper left corner". However, when I try MoveWindow into this position it does not move into area advertized. What am I missing?
Post Follow-up to this messageThe GetWindowRect function retrieves the dimensions of the bounding rectangl e of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen. If you are moving to return value of GetWindowRect then you are moving the window to the same place. What are your cordinates? (0,0) should be top lef t of desktop. Watch out for task bars at top of desktop! I hate it when windows hide them selves under the task bar. "Vaclav" wrote: > According to all articles about GetWindowRect it returns positon relative to > "upper left corner". However, when I try MoveWindow into this position it > does not move into area advertized. > What am I missing? > >
Post Follow-up to this message"Terry" wrote: > The GetWindowRect function retrieves the dimensions of the bounding rectan gle > of the specified window. The dimensions are given in screen coordinates th at > are relative to the upper-left corner of the screen. > > If you are moving to return value of GetWindowRect then you are moving the > window to the same place. What are your cordinates? (0,0) should be top l eft > of desktop. Watch out for task bars at top of desktop! I hate it when > windows hide them selves under the task bar. > > "Vaclav" wrote: > Here is my test code . Basically I have two CStatic "objects" in the CFormView - created in associated dialog. I want to move them together, side by side. I can get the CDC pointer and can draw a test line from upper left corner to the lower right corner using eitherGetClientRect or GetWindowRect( followed by ScreenToClient). Both of these "methods" apparently set the object window origin to upper left corner of the objects. GetWindowRect retruns what appears to be relative coordinates at random origin, but they are the dimensions of the objects! I am using m_test.GetWindowRect(&rect1); without using m_test.ScreenToClient(&rect1); When I use MoveWindow on m_test object it moves into these coorinates which ARE NOT correct. I must be doing something wrong! . Either CBrush brush(RGB(255,0,0)); CPen pen(PS_SOLID,10,RGB(0,0,0)); CPen pen1(PS_SOLID,5,RGB(255,0,0)); CDC *pDC = m_test.GetDC(); m_test.GetClientRect(&rect); /* m_test.GetWindowRect(&rect1); m_test.ScreenToClient(&rect1); pDC->SelectObject(pen); pDC->MoveTo(rect.left,rect.top); pDC->LineTo(rect.right,rect.bottom); pDC->SelectObject(pen1); pDC->MoveTo(rect1.left,rect1.top); pDC->LineTo(rect1.right,rect1.bottom); */ //CPen pen1(PS_SOLID,2,RGB(0,255,0)); CDC *pDC1 = m_test1.GetDC(); pDC1->SelectObject(pen1); // m_test1.GetClientRect(&rect1); m_test1.GetWindowRect(&rect2); m_test1.ScreenToClient(&rect2); pDC1->MoveTo(rect1.left,rect1.top); pDC1->LineTo(rect2.right,rect2.bottom);
Post Follow-up to this message"Vaclav" <Vaclav@discussions.microsoft.com> wrote in message news:65E08BE2-8D47-4C5F-81B9-2464F42F0F13@microsoft.com... > Here is my test code . > Basically I have two CStatic "objects" in the CFormView - created in > associated > dialog. > I want to move them together, side by side. > I can get the CDC pointer and can draw a test line from upper left corner to > the lower right corner using eitherGetClientRect or GetWindowRect( followed > by ScreenToClient). > Both of these "methods" apparently set the object window origin to upper > left corner of the objects. > > GetWindowRect retruns what appears to be relative coordinates at random > origin, but they are the dimensions of the objects! > I am using > m_test.GetWindowRect(&rect1); > without using > m_test.ScreenToClient(&rect1); > > When I use MoveWindow on m_test object it moves into these coorinates which > ARE NOT correct. > I must be doing something wrong! My guess is that after calling m_test.GetWindowRect you need to then call the parent CFormView's ScreenToClient before calling m_test.MoveWindow. -- Jeff Partch [VC++ MVP]
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.