返回首页

在Win32 API程序,设备上下文是它是如何工作的?| 只是想为这个功能,在注释的问题:

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM IParam){

	HDC hdc; //what's the hdc,how it works?

	PAINTSTRUCT ps;

	RECT rect;

	switch(message){

	case WM_CREATE:

		PlaySound(TEXT("hellowin,wav"),NULL,SND_FILENAME|SND_ASYNC);

		return 0;

	case WM_PAINT:

		hdc = BeginPaint(hwnd,&ps);

		GetClientRect(hwnd,&rect);

		DrawText(hdc,TEXT("Hello,Windows 98!"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);

		EndPaint(hwnd,&ps);

		return 0;

	case WM_DESTROY:

		PostQuitMessage(0);

		return 0;

	}

	return DefWindowProc(hwnd,message,wParam,IParam);

}

回答