Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


Help me please!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 ZomeonE   Members   -  Reputation: 122

Like
Likes
Like

Posted 26 October 1999 - 05:57 AM

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!



Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 20 October 1999 - 05:28 AM

wndclass.hbrBackground = GetStockObject((HBRUSH__*)BLACK_BRUSH);

#3 ZomeonE   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 October 1999 - 05:57 AM

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.

???


#4 STG   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 October 1999 - 06:08 AM

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).]


#5 ZomeonE   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 October 1999 - 06:11 AM

yes, of course!

now it works, thanx


#6 Splat   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 October 1999 - 11:50 AM

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


#7 ZomeonE   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 October 1999 - 08:06 AM

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);

???


#8 NuFAN   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 October 1999 - 11:35 AM

This code only works with VC 5.0 and older versions.

CU

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


#9 CJ   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 October 1999 - 11:48 PM

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......


#10 Aldacron   GDNet+   -  Reputation: 3239

Like
Likes
Like

Posted 26 October 1999 - 05:57 AM

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.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS