Advertisement

Compiling Error - please help.

Started by October 10, 2000 01:55 PM
4 comments, last by 1kevgriff 24 years, 2 months ago
Hi. I''ve been reading TWGPG by LaMothe and I been using it to start out a game I''ve been planning to do in DirectX. Well, I''ve all the code out of the book to get the main idea of how to do it and form it too my game. But at build time (I use VC 6.0) I get this error: c:\testament\testament\main.cpp(86) : error C2440: ''='' : cannot convert from ''void *'' to ''struct HBRUSH__ *'' Here is the code it comes from
    
winclass.cbSize		= sizeof(WNDCLASSEX);	
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); // ERROR(86)
winclass.lpszMenuName	= NULL;
winclass.lpszClassName	= WINDOW_CLASS_NAME;
winclass.hIconSm	= LoadIcon(NULL, DI_APPLICATION);
    
Any ideas would be appreciated. Thanks
You need to go

winclass.hbrBackground=(HBRUSH)GetStockObject(ect...
Advertisement
You need to go

winclass.hbrBackground=(HBRUSH)GetStockObject(ect...
You need to go

winclass.hbrBackground=(HBRUSH)GetStockObject(ect...
Or you could try
winclass.hbrBackground = GetStockBrush(BLACK_BRUSH);
its because VC6 no longer performs implicit casts on some types, as anon said, you need to use
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);

to convert it to a HBRUSH

hope this helps

This topic is closed to new replies.

Advertisement