为什么下列代码执行的时候一直闪烁,但是使用注释中的代码是没有这个现象LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ; switch (message)
{
case WM_PAINT:// hdc = BeginPaint (hwnd, &ps) ;
// GetClientRect (hwnd, &rect) ;
// DrawText (hdc, TEXT ("你好,欢迎你!"), -1, &rect,
// DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
// EndPaint (hwnd, &ps) ; hdc=GetDC(hwnd);
GetClientRect (hwnd, &rect) ;
DrawText (hdc, TEXT ("你好,欢迎你!"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
ReleaseDC(hwnd,hdc);
return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ; switch (message)
{
case WM_PAINT:// hdc = BeginPaint (hwnd, &ps) ;
// GetClientRect (hwnd, &rect) ;
// DrawText (hdc, TEXT ("你好,欢迎你!"), -1, &rect,
// DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
// EndPaint (hwnd, &ps) ; hdc=GetDC(hwnd);
GetClientRect (hwnd, &rect) ;
DrawText (hdc, TEXT ("你好,欢迎你!"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
ReleaseDC(hwnd,hdc);
return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
hdc=GetDC(hwnd);
[other program lines]
ReleaseDC(hwnd,hdc);
hdc=GetDC(hwnd);
[other program lines]
ReleaseDC(hwnd,hdc);
[other program lines]
ReleaseDC(hwnd,hdc);不可以在 WM_PAINT 中使用吗