Advertisement

VC++ trouble...

Started by October 28, 2000 05:48 PM
3 comments, last by Mazen 24 years, 2 months ago
This weekend, I started learning how to code in Visual C++ 6.0, but I've already got stuck because the compiler refuse to accept the following line of code: ( WNDCLASS window_class; ) window_class.hbrBackground = GetStockObject(BLACK_BRUSH); This is the error message: error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *' Conversion from 'void*' to pointer to non-'void' requires an explicit cast I hope someone can come up with a good solution! // Mazen Edited by - Mazen on 10/28/00 5:50:05 PM
"We paint the sky with blood tonight, setting free the damned to fight"
The only thing you have to do is cast it as an HBRUSH

window_class.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
Advertisement
Also, the reason is because GetStockObject() returns an HGDIOBJ, which is a handle to a GDI object. This object can be a brush, a bitmap, a font, a region, or a pen.
Thanks!
"We paint the sky with blood tonight, setting free the damned to fight"
You can disable all of this ''struct HBRUSH__ *'' crap.
Just add NO_STRICT to the "Preprocessor definitions".

This topic is closed to new replies.

Advertisement