如何在MFC中使用半透明笔刷填充矩形区域? [英] How to fill a rectangle region with Semi-transparent brush in MFC?
本文介绍了如何在MFC中使用半透明笔刷填充矩形区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在mfc中用半透明的颜色/画笔填充矩形区域.我该如何实现?
I need to fill a rectangular region with semi-transparent color/brush in mfc. How can I achieve that?
推荐答案
I found the solution. To fill the rectangle region with semi-transparent brush, we need to use GdiPlus
objects.
这是示例代码:
void FillSemiTransparentRegion(CDC *pDC, CRect rc)
{
if (pDC == NULL || rc.IsRectEmpty() || rc.IsRectNull())
return;
Graphics gr(pDC->GetSafeHdc());
SolidBrush br(Color(100, 0, 0, 0)); // Alpha, Red, Blue, Green
gr.FillRectangle(&br, rc.left, rc.right, rc.Width(), rc.Height());
}
这篇关于如何在MFC中使用半透明笔刷填充矩形区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文