4
我是中國學生,這是我在國外論壇上提出的第一個問題。 我寫了兩個程序,一個可以正常運行,但另一個失敗。關於windows GDI的困惑。新手程序員
這裏是正常的:
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
if(fIsTime)
ShowTime(hdc, &st);
else
ShowDate(hdc, &st);
EndPaint (hwnd, &ps) ;
return 0 ;
這裏是一個失敗:
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 ;
兩個代碼之間的唯一區別是WM_Paint
代碼塊,後者不能顯示任何內容。我對後面的代碼中錯誤的位置感到困惑?
哦,我扭轉目的地和來源..非常感謝你。 – nvfumayx