GDI的一些很方便的代码

这篇博客介绍了如何在GDI中便捷地改变设备上下文(DC)的画笔和画刷颜色。通过GetStockObject函数、SetDCPenColor以及SetDCBrushColor函数,应用可以实现颜色的设定。文章提醒,在调用SetDCPenColor(hdc,RGB(0x00,0xff,0x00))前,需要先调用SelectObject(hdc,GetStockObject(DC_PEN))。" 115076409,8752025,程序员必备书籍全攻略,"['书籍推荐', '编程学习', '算法书籍', 'Linux教程', '前端开发']
摘要由CSDN通过智能技术生成

自己有点孤陋寡闻!!!!!!!!!!!!
改变画笔颜色和画刷颜色很方便
ms-help://MS.MSDNQTR.v90.en/gdi/devcons_34qa.htm


Setting the Pen or Brush Color


The following example shows how an application can change the DC pen color by using theGetStockObject function or SetDCPenColor and the SetDCBrushColor functions.


HGDIOBJ original = NULL;


//Save original object.
original = SelectObject(hdc,GetStockObject(DC_PEN));
//Change the DC pen color
SetDCPenColor(hdc,RGB(0x00,0xff,0x00));
Rectangle(0,0,20,20);
SetDCPenColor(hdc,RGB(0x00,0x00,0xff));
Rectangle(0,0,20,20);


// The brush color can be changed in a similar manner. SetDCPenColor 
// and SetDCBrushColor can be used interchangeably with GetStockObject 
// to change the current color.  
SelectObject(hDC,GetStockObject(DC_BRUSH));
SetDCBrushColor(hDC,RGB(0x00,0x00,0x00)); 


// Provides the same flexibility as:
SelectObject(hDC,GetStockObject(BLACK_BRUSH));
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值