I am a Chinese student, and here is my first question I asked in an external forum. I wrote two programs, you can work fine, but the other failed.
Here is the normal one: <i>
case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; if(fIsTime) ShowTime(hdc, &st); else ShowDate(hdc, &st); EndPaint (hwnd, &ps) ; return 0 ;
Here's the bad one: <i>
case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; hdcMem = ::CreateCompatibleDC(hdc); hBitmap = ::CreateCompatibleBitmap(hdc, cxClient, cyClient); ::SelectObject(hdcMem, hBitmap); if(fIsTime) ShowTime(hdcMem, &st); else ShowDate(hdcMem, &st); ::BitBlt(hdcMem, 0, 0, cxClient, cyClient, hdc, 0, 0, SRCCOPY); ::DeleteObject(hBitmap); ::DeleteDC(hdcMem); EndPaint (hwnd, &ps) ; return 0 ;
The only difference between the two codes is the WM_Paint code WM_Paint , the latter cannot display anything. I am confused by where is the error in the last code?
source share