Jump to content
  • Advertisement

Archived

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

Ilankt

Got Stucked... What is the problem???

This topic is 5716 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

#include <windows.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInsance, LPSTR lpCmdLine, int nCMDSHOW) { WNDCLASSEX wcex={sizeof(WNDCLASSEX),CS_CLASSDC, WindowProc,0L,0L,hInstance, NULL,NULL,NULL,NULL, "Class",NULL}; return 0; } and the problem is: c:\my documents\c++\test\main.cpp(11) : error C2065: ''WindowProc'' : undeclared identifier c:\my documents\c++\test\main.cpp(11) : error C2440: ''initializing'' : cannot convert from ''int'' to ''long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast c:\my documents\c++\test\main.cpp(11) : error C2440: ''initializing'' : cannot convert from ''struct HINSTANCE__ *'' to ''int'' This conversion requires a reinterpret_cast, a C-style cast or function-style cast c:\my documents\c++\test\main.cpp(13) : error C2440: ''initializing'' : cannot convert from ''char [6]'' to ''struct HBRUSH__ *'' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Share this post


Link to post
Share on other sites
Advertisement
I''m sorry did you type all the code from the book as it was in the book??

Because there seems to be a couple of elements missing.

Share this post


Link to post
Share on other sites
Looks like you don't have a window procedure, but you're passing one to the WNDCLASSEX structure. You need to write a window procedure. All those Primatech\Primier Press Andre LaMothe series books are notoriously bad when it comes to having examples that don't compile, so don't worry about it. Copy the "WindowProc" function (it should be in the book) and the code will compile and run. It will not create a window and it will exit as soon as you run it. You need to Register the class, call CreateWindowEx and write a message loop if you want to do all that. This should be in the book. To get the code you have compiling (it won't actually do anything, but it will build and run) you need to change it to this.



#include <windows.h>

LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, LPARAM lParam, WPARAM wParam)
{
return DefWindowProc(hwnd,msg,lParam,wParam);
}

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInsance,
LPSTR lpCmdLine,
int nCMDSHOW)
{
WNDCLASSEX wcex={sizeof(WNDCLASSEX),CS_CLASSDC,
WindowProc,0L,0L,hInstance,
NULL,NULL,NULL,NULL,
"Class",NULL};
return 0;
}



Neither WindowProc nor WinMain are complete, but if you want that code to compile and do nothing, now it will.

Edit: heh, I see you've realized your mistake. Always copy everything directly and double check it before you post to the forums.

[edited by - impossible on April 21, 2003 6:08:44 AM]

Share this post


Link to post
Share on other sites
Oh, and if you post code in this forum, put it between [ code ] and [ /code ] tags, without the blankspaces. That way, the forum won''t mess up your code.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!