CDC::RoundRect

来源于MSDN:https://msdn.microsoft.com/zh-cn/library/b0xe62fb(v=vs.110).aspx


CDC::RoundRect

Visual Studio 2012

Draws a rectangle with rounded corners using the current pen.

使用当前的画笔画一个带圆角的矩形

BOOL RoundRect(
   int x1,
   int y1,
   int x2,
   int y2,
   int x3,
   int y3 
);
BOOL RoundRect(
   LPCRECT lpRect,
   POINT point 
);

x1

Specifies the x-coordinate of the upper-left corner of the rectangle (in logical units).矩形左上角x坐标

y1

Specifies the y-coordinate of the upper-left corner of the rectangle (in logical units).矩形左上角y坐标

x2

Specifies the x-coordinate of the lower-right corner of the rectangle (in logical units).矩形右下角x坐标

y2

Specifies the y-coordinate of the lower-right corner of the rectangle (in logical units).矩形右下角y坐标

x3

Specifies the width of the ellipse used to draw the rounded corners (in logical units).椭圆的宽

y3

Specifies the height of the ellipse used to draw the rounded corners (in logical units).椭圆的高

lpRect

Specifies the bounding rectangle in logical units. You can pass either a CRect object or a pointer to a RECT structure for this parameter.

point

The x-coordinate of point specifies the width of the ellipse to draw the rounded corners (in logical units). The y-coordinate of pointspecifies the height of the ellipse to draw the rounded corners (in logical units). You can pass either a POINT structure or a CPointobject for this parameter.

x为椭圆的宽,y为椭圆的高。可以使用POINT结构体传递圆角的参数。

Nonzero if the function is successful; otherwise 0.执行成功返回值非0,否则为0

The interior of the rectangle is filled using the current brush.矩形内部(颜色)由当前刷子填充

The figure this function draws extends up to but does not include the right and bottom coordinates. This means that the height of the figure is y2 – y1 and the width of the figure is x2 – x1. Both the height and the width of the bounding rectangle must be greater than 2 units and less than 32,767 units.

x1,y1的值必须小于x2,y2。矩形的高是y2-y1,宽是x2-x1,取值范围为2~32767

C++
void CDCView::DrawRoundRect(CDC* pDC)
{
   // create and select a solid blue brush
   CBrush brushBlue(RGB(0, 0, 255));
   CBrush* pOldBrush = pDC->SelectObject(&brushBlue);

   // create and select a thick, black pen
   CPen penBlack;
   penBlack.CreatePen(PS_SOLID, 3, RGB(0, 0, 0));
   CPen* pOldPen = pDC->SelectObject(&penBlack);

   // get our client rectangle
   CRect rect;
   GetClientRect(rect);

   // shrink our rect 20 pixels in each direction
   rect.DeflateRect(20, 20);

   // Draw a thick black rectangle filled with blue
   // corners rounded at a 17-unit radius. Note that
   // a radius of three or less is not noticable because
   // the pen is three units wide.
   pDC->RoundRect(rect, CPoint(17, 17));

   // put back the old objects
   pDC->SelectObject(pOldBrush);
   pDC->SelectObject(pOldPen);
}


Header: afxwin.h


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值