在hbrBackground的颜色窗口

时间:2013-03-27 12:03:43

标签: c++ windows

WNDCLASS wc;
...
wc.hbrBackground = (HBRUSH)GetStockObject(COLOR_WINDOW+1);

我无法理解+1是什么,HBRUSH是什么?

3 个答案:

答案 0 :(得分:3)

你的意思不是吗?

wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);

GetStockObject获取其中一个库存笔,笔,字体或调色板。你不应该使用COLOR_WINDOW。

使用其中一个库存刷子,因此对于白色背景,您可以使用...

wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);

无论什么有效,请使用它!

答案 1 :(得分:1)

Winuser.h

中定义的系统颜色
#define CTLCOLOR_MSGBOX 0

#define CTLCOLOR_EDIT 1

#define CTLCOLOR_LISTBOX 2

#define CTLCOLOR_BTN 3

#define CTLCOLOR_DLG 4

#define CTLCOLOR_SCROLLBAR 5

#define CTLCOLOR_STATIC 6

#define CTLCOLOR_MAX 7

#define COLOR_SCROLLBAR 0

#define COLOR_BACKGROUND 1

#define COLOR_ACTIVECAPTION 2

#define COLOR_INACTIVECAPTION 3

#define COLOR_MENU 4

#define COLOR_WINDOW 5

#define COLOR_WINDOWFRAME 6

#define COLOR_MENUTEXT 7

#define COLOR_WINDOWTEXT 8

#define COLOR_CAPTIONTEXT 9

#define COLOR_ACTIVEBORDER 10

#define COLOR_INACTIVEBORDER 11

#define COLOR_APPWORKSPACE 12

#define COLOR_HIGHLIGHT 13

#define COLOR_HIGHLIGHTTEXT 14

#define COLOR_BTNFACE 15

#define COLOR_BTNSHADOW 16

#define COLOR_GRAYTEXT 17

#define COLOR_BTNTEXT 18

#define COLOR_INACTIVECAPTIONTEXT 19

#define COLOR_BTNHIGHLIGHT 20

#if(WINVER >= 0x0400)

#define COLOR_3DDKSHADOW 21

#define COLOR_3DLIGHT 22

#define COLOR_INFOTEXT 23

#define COLOR_INFOBK 24

#endif /* WINVER >= 0x0400 */

#if(WINVER >= 0x0500)

#define COLOR_HOTLIGHT 26

#define COLOR_GRADIENTACTIVECAPTION 27

#define COLOR_GRADIENTINACTIVECAPTION 28

#if(WINVER >= 0x0501)

#define COLOR_MENUHILIGHT 29

#define COLOR_MENUBAR 30

#endif /* WINVER >= 0x0501 */

#endif /* WINVER >= 0x0500 */

#if(WINVER >= 0x0400)

#define COLOR_DESKTOP COLOR_BACKGROUND

#define COLOR_3DFACE COLOR_BTNFACE

#define COLOR_3DSHADOW COLOR_BTNSHADOW

#define COLOR_3DHIGHLIGHT COLOR_BTNHIGHLIGHT

#define COLOR_3DHILIGHT COLOR_BTNHIGHLIGHT

#define COLOR_BTNHILIGHT COLOR_BTNHIGHLIGHT

#endif /* WINVER >= 0x0400 */

因此,正如@CodyGray定义的那样,添加1以区分COLOR_SCROLLBAR和NULL HBRUSH。 并且,(引用@ CodyGray的评论和核心我的解决方案)“HBRUSH是一个C风格的演员,你应该使用static_cast<HBRUSH>而不是C风格的演员。”

答案 2 :(得分:0)

COLOR_WINDOW 是一个数字。当你加 1 时,你会增加这个数字。 (HBRUSH) 可以将数字转换为颜色代码。

相关问题