Simple Win32 App (First Window) Need Help!

Started by
6 comments, last by CGameNewbie 23 years, 2 months ago
Ok, I''m sturrrrrrrrrrrressed! Grrrr! I''ve been stuck on this problem for about a day now, I''m fairly new all round to C++, but I''ve got myself loads of books and stuff and I''ve got to grasp of the fundementals. Now after messing about with a few console apps, I''ve decided to try and make my first win32 app - y''remember your first one ever don''t you? Anyway, using several tutorials (inc. Game Programming Genesis Part I), I''ve writted up the code, but EVERY time I compile I get the Same DAMN error and I REALLY can''t work out what the prob is. C:\Windows\Temp\Starfield.cpp(131) : error C2440: ''='' : cannot convert from ''int'' to ''struct HWND__ *'' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast I get the distinct impression this is a REALLY simple problem, like missing out a header file, as it occurs when I try to compile even the Microsoft Generated "Hello World" code!! Please hewwp!! (ms c++ 6)
------ Help -----
Advertisement
You need to give us the line of code that is causing this problem and the types of the variables involved in that line of code. Briefly your error message means that you are trying assign an integer to a window handle (HWND). You can only assign a window to a HWND. If you show the code that is causing the problem, we can have a better look at it.
Post a message once... it''s just not nice!
Agh!!!! Sorry about the multiple posts, that was a pure accident, this message board is SO slow on my 56k, takes about a minute to browse through each new topic, so I didn''t realise that I had posted and so I reposted ( three times as I am sure you see... Anyway, it''s your basic create window func: if (!


(hwnd = CreateWindowEx(NULL, WIN_CLASS_NAME, "Learning Windows GDI", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, nWidth, nHeight, NULL, NULL, hinstance, NULL)))

return(0);

Again, sorry for the multiple spams

That function call looks alright, although I usually use CreateWindow rather than CreateWindowEx:

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

Try using CreateWindow (remember to register your window class too). Also note that in the above code, hWnd is of type HWND. Make sure the variable being assigned the return value of CreateWindowEx is of type "HWND".
just an obvious point id like to suggest make sure that you have declared hwnd as HWND hwnd not int hwnd (as i have just realised Mr DirectX said lol) bu also make sure hwnd isnt supposed to be hWnd (because I think La Mothe uses hWnd so i thought maybe that is the problem) as I said this is an obvious point and is probably no help but just in case i thought I should post it

Just my thoughts take them as you will.

"People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
just an obvious point id like to suggest make sure that you have declared hwnd as HWND hwnd not int hwnd (as i have just realised Mr DirectX said lol) bu also make sure hwnd isnt supposed to be hWnd (because I think La Mothe uses hWnd so i thought maybe that is the problem) as I said this is an obvious point and is probably no help but just in case i thought I should post it

Just my thoughts take them as you will.

"People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
The problem definitely is not CreateWindowEx. I believe Zeke is on the money here (about the spelling part). Whenever you try to assign a value to a variable that has not been declared (either through forgetfulness or a typo) you''ll get that kind of error.

GamesToGO: The Console Gamer''s Paradise

This topic is closed to new replies.

Advertisement