hbrBackground = (HBRUSH)(COLOR_WINDOW+1), what is +1 for ???

The first COLOR_* value defined is COLOR_SCROLLBAR with the value 0 (see Winuser.h). If you didn't add one you wouldn't be able to differentiate between COLOR_SCROLLBAR and a NULL HBRUSH.

If you remove the +1 and only specify COLOR_WINDOW (5) you effectively get the same as COLOR_MENU (4) + 1, i.e. the menu color. Maybe they're both defined to be white.

使用颜色的时候,必须把每个颜色宏+1,才能得到正确的颜色,这是用法,没有特别的含义。

因为滚动条颜色宏被定义成 #define COLOR_SCROLLBAR 0,如果不进行+1的话,使用这个颜色就是意外的变成NULL,为了避免这种情况,所以把所有的颜色值+1处理。

原文地址1:http://topic.csdn.net/u/20080129/15/289b1b29-18f9-4721-bdfe-be1d2758e874.html

原文地址2:http://social.msdn.microsoft.com/Forums/zh-SG/vcgeneral/thread/e4fd1c4b-4407-4743-a74f-7d78338c17d2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值