🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

WNDCLASS object

Started by
1 comment, last by Wild9eR 24 years, 7 months ago
You've got to cast the stock object to an HBRUSH like so:

winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);

Advertisement
I am tyring to compile the Prog4_1.cpp in "Windows Game Programming for Dummies" and
I keep getting a error.

source code below
-------------------------------------

// first fill in the window class stucture
winclass.style = CS_DBLCLKS | CS_OWNDC |
CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
---------------------------------------
This error occurs on the hrbBackGround line
"error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast"

I looked in the MSDN docs and could not find anything that would explain the error. It looks right to me, but it obviously isn't. Someone please help.

Job description : Duct Tape
Thanks You, that worked.
Job description : Duct Tape

This topic is closed to new replies.

Advertisement