Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Help me please!

4: Adsense

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   

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!



#2 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

Posted 20 October 1999 - 05:28 AM

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

#3 ZomeonE   Members   

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   

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   

122
Like
Likes
Like

Posted 20 October 1999 - 06:11 AM

yes, of course!

now it works, thanx


#6 Splat   Members   

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   

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   

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   

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+   

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