Jump to content

  • Log In with Google      Sign In   
  • Create Account

windows problems


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
4 replies to this topic

#1 skitzo_smurf   Members   -  Reputation: 122

Posted 12 January 2000 - 03:58 PM

hi, Well ive finally been beaten down into learning windows programming. I am trying to get something simple to compile but I am getting errors. I am getting them when I try to register the window class...First the code snippet: HWND hwnd; MSG msg; WNDCLASSEX winClass = { sizeof(WNDCLASSEX), CS_DBLCLKS / CS_OWNDC / CS_HREDRAW / CS_VREDRAW, WindowProc, 0, 0, hinstance, LoadIcon(NULL, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW), GetStockObject(BLACK_BRUSH), NULL, WINDOW_CLASS1, LoadIcon(NULL, IDI_APPLICATION) }; Now the errors: error C2440: 'initializing' : cannot convert from 'void *' to 'struct HBRUSH__ *' Conversion from 'void*' to pointer to non-'void' requires an explicit cast error C2440: 'initializing' : cannot convert from 'struct HICON__ *' to 'const char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast thanks in advance for any help, skitzo oh yeah..almost forgot. Im using Microsoft visual c++ 6.0 professional edition if that helps Edited by - skitzo_smurf on 1/12/00 9:59:54 PM

Sponsor:

#2 Aldenar   Members   -  Reputation: 378

Posted 12 January 2000 - 04:15 PM

Hi,
try changing:

(HBRUSH)GetStockObject(BLACK_BRUSH),

the second error may be caused by WINDOW_CLASS1 if it is not defined as a string, but I''m not sure of what''s causing that error.. hope it helps

Aldenar

#3 skitzo_smurf   Members   -  Reputation: 122

Posted 12 January 2000 - 04:18 PM

well I got it to work by myself now. I used a cast on the result from GetStockObject() like this:

(HBRUSH__*)GetStockObject(BLACK_BRUSH)

I was copying code from Tricks of the Windows Game Programming Gurus. Just a question though. Every book ive seen on windows programming does it the way Andre did it. Has anyone else had problems compiling or is it just me?

thanks again,
skitzo

#4 Armitage   Members   -  Reputation: 122

Posted 12 January 2000 - 11:47 PM

If you examine Andrés source code on the cd you''ll see that he does the same conversion. The same thing happened to me - but I found the answer in windowsx.h.
All the type-casting I did in Java should have taught me something, but...


#5 Dave Astle   Senior Staff   -  Reputation: 2307

Posted 13 January 2000 - 03:02 AM

In Visual C++ 5 and earlier, the cast wasn''t necessary, and that line would have compiled without errors, so you''ll still see it in a lot of places. VC++6 uses more strict type-checking, so the same line causes an error now.




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