title: How to repaint a push button in Win32?
body: <p>I have a window with a button that paints the entire window red when clicked, but my code paints the whole window, even the button. When I resize the window or cause the part of the window where the button is to repaint, the button will return. I've only been able to paint the button a solid color after painting the window, but that only makes it look like a square with nothing in it.</p>
  
  <p>So how do I paint the button its default color?</p>
  
  <pre><code>//WinMain 
  hmain = CreateWindowEx (0, L"Window", L"Window", WS_OVERLAPPEDWINDOW, 0, 0, 200, 200,
      NULL, NULL, hinstance, NULL);
  
  HWND hwnd2 = CreateWindowEx (0, L"Button", L"Red", WS_CHILD | BS_PUSHBUTTON, 0, 0, 50, 50,
      hmain, (HMENU) redbtt, hinstance, NULL);
  //Winmain
  
  //WndProc
  COLORREF red = RGB (255, 0, 0);
  HBRUSH redbrush = CreateSolidBrush (red);
  
  switch (msg) {
      case WM_COMMAND: {
          if (LOWORD (wparam) == redbtt) {
              color = 'r';
              RECT rect;
              GetClientRect (hmain, &amp;rect);
              HDC hdc = GetDC (hmain);
              FillRect (hdc, &amp;rect, redbrush);
              ReleaseDC (hmain, hdc);
  
              /*GetClientRect ((HWND) lparam, &amp;rect);
              hdc = GetDC ((HWND) lparam);
              COLORREF color = GetBkColor (hdc);
              HBRUSH brush = CreateSolidBrush (color);
              FillRect (hdc, &amp;rect, brush);
              ReleaseDC ((HWND) lparam, hdc);*/
          }
  
          break;
                       }
      case WM_PAINT: {
          HBRUSH brush;
  
          if (color == ' ') {
              brush = (HBRUSH) (COLOR_WINDOW + 1);
          } else if (color == 'r') {
              brush = redbrush;
          }
  
          PAINTSTRUCT ps;
          HDC hdc = BeginPaint (hmain, &amp;ps);
          FillRect (hdc, &amp;ps.rcPaint, brush);
          EndPaint (hmain, &amp;ps);
          break;
                     }
  //WndProc
  </code></pre>