Original Post
I've got a problem in one of my win32 application, case WM_PAINT: hdc = BeginPaint (hwnd, &ps); while (i < 20){ SelectObject (hdc, CreateSolidBrush (RGB(rand () % 256, rand () % 256, rand () % 256))); Rectangle (hdc, 3 * cxClient / 8, i * cyClient / 20, 5 * cxClient / 8, (i + 1)*cyClient / 20) ; i++; } when i resize the window,the blocks i drawed just disappeared,left only a blank in the client area,but if i don't use the loop,like SelectObject (hdc, CreateSolidBrush (RGB (rand () % 256, rand () % 256, rand () % 256))) ; Rectangle (hdc, 3 * cxClient / 8, 0 * cyClient / 20, 5 * cxClient / 8, 1 * cyClient / 20) ; SelectObject (hdc, CreateSolidBrush (RGB (rand () % 256, rand () % 256, rand () % 256))) ; Rectangle (hdc, 3 * cxClient / 8, 1 * cyClient / 20, 5 * cxClient / 8, 2 * cyClient / 20) ; SelectObject (hdc, CreateSolidBrush (RGB (rand () % 256, rand () % 256, rand () % 256))) ; Rectangle (hdc, 3 * cxClient / 8, 2 * cyClient / 20, 5 * cxClient / 8, 3 * cyClient / 20) ; draw each block manually,it shows what should be when i resize the window,i don't why,could someone kind tell me why and how i can slove this problem?