用vc画三角形并填充

很久没用MFC了,都忘没了,想画个三角形,开始用LineTo画,后来发现还有个CDC::Polygon函数,还可以填充,神奇,很简便,记录一下。下面是vs帮助上的代码:void CDCView::DrawPolygon(CDC* pDC){   // find the client area   CRect rect;   GetClientRect(rect);
摘要由CSDN通过智能技术生成

很久没用MFC了,都忘没了,想画个三角形,开始用LineTo画,后来发现还有个CDC::Polygon函数,还可以填充,神奇,很简便,记录一下。

下面是vs帮助上的代码:

void CDCView::DrawPolygon(CDC* pDC)
{
   // find the client area
   CRect rect;
   GetClientRect(rect);

   // draw with a thick blue pen
   CPen penBlue(PS_SOLID, 5, RGB(0, 0, 255));
   CPen* pOldPen = pDC->SelectObject(&penBlue);

   // and a solid red brush
   CBrush brushRed(RGB(255, 0, 0));
   CBrush* pOldBrush = pDC->SelectObject(&brushRed);

   // Find the midpoints of the top, right, left, and bottom
   // of the client area. They will be the vertices of our polygon.
   CPoint pts[4];
   pts[0].x = rect.left + rect.Width()/2;
   pts[0].y = rect.top;

   pts[1].x = rect.right;
   pts[1].y = rect.top + rect.Height()/2;

   p

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值