可能重复:
c ++ win32:如何设置窗口的颜色?
我不想使用 WNDCLASS 中的 HBRUSH 库存
这是我的 WNDCLASS:
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
我希望 hbrBackground 成员是十六进制值 #cfdf9b
wndclass.hbrBackground = (HBRUSH) GetStockObject (#cfdf9b);
随之而来的错误
错误 C2014:预处理器命令必须作为第一个非空白警告 C4047:“函数”:“int”与“LPCSTR”的间接级别不同 helloworldwinapi.c(21):警告 C4024:“GetStockObject”:正式和实际的不同类型参数 1 错误 C2143:语法错误:在 ';' 之前缺少 ')'