Settings | Sign in | Sign up

The author has 1 post.

【案例】Win32程序GDI绘图案例

Floor 1 巨大八爪鱼 12/2/15 0:07
运行效果:


程序代码:
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);
}

Content converter:

Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.