trouble here...

Started by
3 comments, last by GameDev.net 24 years, 4 months ago
Not sure why you got this in 6 and not 5, but you should just be able to cast it:

winclass.hbrBackground = reinterpret_cast<HBRUSH *>(GetStockObject(DKGRAY_BRUSH));

Mason McCuskey
Spin Studios
www.spin-studios.com

[This message has been edited by mason (edited December 03, 1999).]

[This message has been edited by mason (edited December 03, 1999).]

Founder, Cuttlefish Industries
The Cuttlefish Engine lets anyone develop great games for iPad, iPhone, Android, WP7, the web, and more!
Advertisement
i don't think you need all that reinterpret_cast<> stuff, all you need to do is

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

GetStockObject just returns a void pointer to some memory, and you need to tell the compiler to cast it into the HBRUSH class for the background of your window

------------------

_________________Gecko___


_________________Gecko___Gecko Design
Actually, reinterpret_cast and (its siblings) is more consistent with proper C++ style.
Hi!

I've converted an old game project from MSVC 5.0 to 6.0....when i try to compile the whole thing i get an error on this line of code:

winclass.hbrBackground = GetStockObject(DKGRAY_BRUSH);

the error is:
cannot convert from 'void *' to 'struct HBRUSH__ *'

what is the problem???

Thanks in advance.

Thats one of the big differences between vs5 and vs6. 5 was more forgiving with mixing types, which didnt really follow standards.

Misuse of the reinterpret_cast operator can easily be unsafe. (and not as easy to read) Unless the desired conversion is inherently low-level, you should use one of the other cast operators.

Just because the church was wrong doesn't mean Galileo wasn't a heretic.It just means he was a heretic who was right.

This topic is closed to new replies.

Advertisement