vs2005双缓冲绘图下FillRect函数不能通常填充

vs2005双缓冲绘图下FillRect函数不能正常填充?
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

  // TODO: 在此放置代码。
MSG msg;
HACCEL hAccelTable;

// 初始化全局字符串
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_WINSAMPLE, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);

// 执行应用程序初始化:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

    //以下9行为默认代码外添加的
windowDC = GetDC(hwnd);
memDC = CreateCompatibleDC(windowDC);
RECT rect;
GetClientRect(hwnd, &rect);
memBMP = CreateCompatibleBitmap(memDC, rect.right - rect.left, rect.bottom - rect.top);
SelectObject(memDC, memBMP);
HBRUSH brush = CreateSolidBrush(RGB(255, 0, 0));
FillRect(memDC, &rect, brush);
BitBlt(windowDC, 0, 0, rect.right - rect.left, rect.bottom - rect.top, memDC, 0, 0, SRCCOPY);

hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WINSAMPLE));

// 主消息循环:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return (int) msg.wParam;
}


结果是这样的
vs2005双缓冲绘图下FillRect函数不能通常填充
求解为什么会这样
------解决思路----------------------
memBMP = CreateCompatibleBitmap(windowDC, rect.right - rect.left, rect.bottom - re