   Window resize
  Hello, I have this problem, when I resize the window, button which moves along with the border starts to paint itself all over the window.I tried returning DefWindowProc in WM_ERASEBKGND, also 1 and 0.Can you help me figure this out?Thanks,Martin   
  Try to call the InvalidateRect(...) function inside your WM_RESIZE handler.   ;  case WM_SIZE:{m_pSCurrentWindow->iWidth = LOWORD(lParam);m_pSCurrentWindow->iHeight = HIWORD(lParam);InvalidateRect(m_pSCurrentWindow->hWindow, NULL, NULL);return 0;}This was before (except return 0). Still same effect.   ;  try to add UpdateWindow(hWnd); too   ;  Unfortunately it still doesn't work...case WM_SIZE:{m_pSCurrentWindow->iWidth = LOWORD(lParam);m_pSCurrentWindow->iHeight = HIWORD(lParam);InvalidateRect(m_pSCurrentWindow->hWindow, NULL, NULL);UpdateWindow(m_pSCurrentWindow->hWindow);return 0;}Maybe something's wrong with WM_PAINT?case WM_PAINT:{HBITMAP hButton = (HBITMAP)LoadImage(m_hInstance, m_pSCurrentWindow->SButton->wszName.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);if (hButton == NULL)MessageBox(m_pSCurrentWindow->hWindow, L"Button failed to initialize", L"Button", NULL);PAINTSTRUCT psWindow;m_pSCurrentWindow->hdcWindow = BeginPaint(m_pSCurrentWindow->hWindow, &psWindow);HDC hdcButton = CreateCompatibleDC(m_pSCurrentWindow->hdcWindow);SelectObject(hdcButton, hButton);RECT R;R.top = 10;R.bottom = 480;R.left = 10;R.right = 800;DrawText(m_pSCurrentWindow->hdcWindow, m_pSCurrentWindow->wssText.str().c_str(), m_pSCurrentWindow->wssText.str().length(), &R, DT_WORDBREAK | DT_VCENTER);BitBlt(m_pSCurrentWindow->hdcWindow, m_pSCurrentWindow->iWidth - m_pSCurrentWindow->SButton->iWidth - 50, m_pSCurrentWindow->iHeight - m_pSCurrentWindow->SButton->iHeight - 50, m_pSCurrentWindow->SButton->iWidth, m_pSCurrentWindow->SButton->iHeight, hdcButton, 0, 0, SRCCOPY);EndPaint(m_pSCurrentWindow->hWindow, &psWindow);return 0;}