运行效果:
程序代码:
WndProc函数中的case WM_PAINT:部分:
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
paint(hdc);
EndPaint(hWnd, &ps);
break;
其实就是调用paint函数。
paint函数:
void paint(HDC hdc)
{
HPEN hpen;
wchar_t *str = L"This is a string.";
TextOut(hdc, 10, 10, str, wcslen(str));
hpen = CreatePen(PS_SOLID, 1, RGB(0xff, 0x00, 0x00));
SelectObject(hdc, hpen);
MoveToEx(hdc, 50, 50, NULL);
LineTo(hdc, 150, 100);
}