windows problems

Started by
3 comments, last by skitzo_smurf 24 years, 3 months ago
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
"Innocent is just a nice way to say ignorant, and stupidity is ignorance with its clothes off."words of,skitzo_smurf
Advertisement
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
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
"Innocent is just a nice way to say ignorant, and stupidity is ignorance with its clothes off."words of,skitzo_smurf
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...
A polar bear is a rectangular bear after a coordinate transform.
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.

This topic is closed to new replies.

Advertisement