Advertisement

Help me please!

Started by October 26, 1999 11:57 AM
8 comments, last by ZomeonE 25 years, 1 month ago
wndclass.hbrBackground = GetStockObject((HBRUSH__*)BLACK_BRUSH);
ok, thanx but now i get the following problem:

Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/OpenWindow.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

???

Advertisement
I'm probably well wrong but it sounds like you may have your project trying to build a Console app. Main is the entry point used by DOS apps. I think VC++ uses this as default if you just loaded the c,cpp file and then let it create the project for you.

try creating a new blank Win32 project and add your existing file to that and then try again.

[This message has been edited by STG (edited October 20, 1999).]

yes, of course!

now it works, thanx

Just for code readability, you might want to use the more standard cast below:

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

In fact, I don't see how the other code even works. BLACK_BRUSH is an integer, and doesn't need to be cast, since GetStockObject takes an integer as its only parameter . The fact that GetStockObject returns fonts, brushs, pens, etc. is the reason why it has to be cast.

- Splat

Your right about that

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

is the only thing that works, but why does every piece of code that I look at write:

wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);

???

Advertisement
This code only works with VC 5.0 and older versions.

CU

------------------
Skullpture Entertainment
#40842461

Graphix Coding @Skullpture Entertainmenthttp://www.skullpture.de
NuFAN: I don't think so, the code works in every version. In either version 4 I used to use, and in version 6 I use at the moment.

------------------
Dance with me......

When i try to make a window in Visual C++ 6 i get a error using the following line:

wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);

The error:

error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast

please help me solve this problem!

Here's what I get without casting:


c:\pware\arcgfx\arctest\mainwin.cpp(55) : error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast

VC 6 does not automagically cast things like this for you. 5 and under do.

This topic is closed to new replies.

Advertisement