Windows下几个常用的边框绘制函数:
RectTangle() 绘制长方形
Ellipse() 绘制椭圆
RoundRect() 绘制圆角矩形
Arc() 绘制圆弧
Chord()
Pie() 绘制饼图
长方形的绘制:
BOOL Rectangle(
_In_ HDC hdc,
_In_ int nLeftRect, //左上角坐标
_In_ int nTopRect,
_In_ int nRightRect, //右下角坐标
_In_ int nBottomRect
);
使用案例:
Rectangle(hdc, 100, 100, 300, 400);
曲边长方形绘制:
RoundRect(hdc, 100, 100, 300, 400,100,100); //后两个参数,一个是曲边长 一个是曲边的宽
Ellipse(hdc, 100, 100, 300, 400);
圆弧的绘制Arc()函数:
BOOL Arc(
_In_ HDC hdc,
_In_ int nLeftRect,
_In_ int nTopRect,
_In_ int nRightRect,
_In_ int nBottomRect,
_In_ int nXStartArc, //截断线段1的起点坐标
_In_ int nYStartArc,
_In_ int nXEndArc, //截断线段2的起点坐标
_In_ int nYEndArc
);
圆弧的绘制有点特殊,函数先绘制一个椭圆,然后利用截断线段把椭圆截成一个弧
截断线段:设置线段的起点坐标,然后和圆心相连,与椭圆的相交点即为截断点
使用方法如下:
Arc(hdc, 100, 100, 300, 400, 250, 10, 20, 300);
效果:
饼图:
与圆弧函数的使用方法一致,只不过把截断线段显示出来了
Pie(hdc, 100, 100, 300, 400, 250, 10, 20, 300);