带圆角的矩形

如果您觉得上面矩形过于方正,那么可以使用 RoundRect 函数,它可以画出带有圆角边框的矩形,原型为:

BOOL RoundRect(
HDC hdc, //设备环境句柄
int nLeftRect, //矩形左上角x坐标
int nTopRect, //矩形左上角y坐标
int nRightRect, //矩形右下角x坐标
int nBottomRect, //矩形右下角y坐标
int nWidth, //用来画圆角的椭圆的宽度
int nHeight //用来画圆角的椭圆的高度
);
1
2
3
4
5
6
7
8
9
注意:当 nHeight >= nBottomRect 且 nWidth = nRightRect 时,那么绘制出的就是一个圆。

示例代码:

case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
RoundRect(hdc, 20, 20, 150, 150, 25, 25);
EndPaint(hwnd, &ps);
return 0 ;
--------------------- 

原文地址:https://www.cnblogs.com/ly570/p/11304713.html