为什么我们需要给背景画笔颜色加 1?

Why we need add 1 to background brush color?

WNDCLASS 结构的成员之一是 class 背景画笔的句柄。

来自描述:

This member can be a handle to the physical brush to be used for painting the background, or it can be a color value. A color value must be one of the following standard system colors (the value 1 must be added to the chosen color).

问题:

为什么一定要给这个值加1?

可能是因为 hbrBackground 字段接受 NULL 值。

RegisterClass()函数用来区分COLOR_SCROLLBAR0NULL是一个可接受的值。