-1

I am trying to change my window background but the function GetWindowRect is not getting the left and top values right. The FillRect function only fills a quarter of the screen and the rest is left transparent. When I set the left and top values manually it works fine, filling the whole window.

case WM_ERASEBKGND:{
                hdc = BeginPaint(hwnd, &ps);
                RECT rect;
                GetWindowRect(hwnd, &rect);
                rect.left = 0; //It only works
                rect.top = 0;  //if I do this
                FillRect(hdc, &rect, CreateSolidBrush(RGB(240,240,240));
                EndPaint(hwnd, &ps);
                }
                break;
Kewyn Vieira
  • 339
  • 3
  • 9

1 Answers1

2

As @Richard Critten suggested, use GetClientRect(). GetWindowRect() returns the screen coordinates of the window, whereas GetClientRect() returns the coordinates of the client area within the window where the application's graphics are rendered.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Rich
  • 4,572
  • 3
  • 25
  • 31