Windows API学习-GDI绘图基础与轻量进阶(3)


绘制椭圆

Ellipse() 函数可以用来绘制椭圆,它的原型为:

BOOL Ellipse(
    HDC hdc,  //设备环境句柄
    int nLeftRect,  //左上角x坐标
    int nTopRect,  //左上角y坐标
    int nRightRect,  //右下角x坐标
    int nBottomRect  //右下角y坐标
);

注意:当 nRightRect - nLeftRect = nBottomRect - nRightRect 时绘制出的是一个圆

case WM_PAINT:
    hdc = BeginPaint(hwnd, &ps);
    Ellipse(hdc, 20, 20, 180,90);
    EndPaint(hwnd, &ps);
    return 0 ;

运行效果:
2.png