• Advertisement

Archived

This topic is now archived and is closed to further replies.

Simple Win32 App (First Window) Need Help!

This topic is 6214 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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".

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement