我用老师的模板只改了回调函数的内容,照写的,执行窗口白白的一片,什么原因各位....
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
HDC hdc;
PAINTSTRUCT ps;
static int cxClient, cyClient;
int iMapMode;
switch (message)
{
case WM_SIZE:
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
iMapMode = GetMapMode(hdc);//取得当前的映射模式
SetMapMode(hdc, MM_ANISOTROPIC);
SetWindowExtEx(hdc, 100, 100, NULL);
SetViewportExtEx(hdc, cxClient / 2, -cyClient / 2, NULL);
SetViewportOrgEx(hdc, cxClient / 2, -cyClient / 2, NULL);
Rectangle(hdc, -100, -100, 100, 100);
Ellipse(hdc, -80, -80, 80, 80);
SetMapMode(hdc, iMapMode);//还回映射模式
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
} 第22行:SetViewportOrgEx(hdc, cxClient / 2, -cyClient / 2, NULL);把负号去掉,即:
SetViewportOrgEx(hdc, cxClient / 2, cyClient / 2, NULL);
页:
[1]