user5809481
user5809481

Reputation:

Erase previously drawn window in mfc

am trying to move a custom button whose base class is CWnd, am using MoveWindow() method but each time i move the window the previously drawn window is still visible. i tryed to call InvalidateWindow, InvalidateRect together with UpdateWindow on the parent window but all didn't work. i also tried RedrawWindow nothing happend. how can i properly update the parent window with the new position of the button? here is my sample code

void CCalendarCtrl::Shift()
{
   RECT rc;
   m_Up.GetWindowRect(&rc);
   rc.top -= 20;
   rc.bottom -=20;
   m_Up.MoveWindow(&rc,TRUE);
   RedrawWindow();

}

Upvotes: 1

Views: 885

Answers (2)

sergiol
sergiol

Reputation: 4335

https://social.msdn.microsoft.com/Forums/en-US/d6da8041-747c-4b31-b493-343e4516b452/are-the-coordinates-returned-by-cwndgetwindowrect-mfc-and-cwndmovewindow-mfc?forum=vcmfcatl

GetWindowRect returns screen coordinates. MoveWindow works using Client coordinates. So you need to do ScreenToClient(&rc) between the two calls.

Upvotes: 1

Santosh
Santosh

Reputation: 1815

Call Invalidate() after movewindow().

Upvotes: 1

Related Questions