• Advertisement
Sign in to follow this  

Another Windows problem

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

Here is my source code #include <windows.h> int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE PrevInstance, LPSTR lpCmdLine,int nCmdShow) { MSG msg; MyRegisterClass(hInstance); if (!InitInstance (hInstance,nCmdShow)); return FALSE; while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } Here is my error log Compiler: Default compiler Building Makefile: "C:\Dev-Cpp\Makefile.win" Executing make clean rm -f Untitled1.o Project1.exe g++.exe -c Untitled1.cpp -o Untitled1.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" Untitled1.cpp: In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)': Untitled1.cpp:6: error: `MyRegisterClass' undeclared (first use this function) Untitled1.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.) Untitled1.cpp:7: error: `InitInstance' undeclared (first use this function) make.exe: *** [Untitled1.o] Error 1 Execution terminated Whats wrong with it?

Share this post


Link to post
Share on other sites
Advertisement
"Untitled1.cpp:6: error: `MyRegisterClass' undeclared (first use this function)"
Tell me. What do YOU think this error means? What does "undeclared" mean?

Share this post


Link to post
Share on other sites
Quote:
Original post by Gunslinger RR
According to MSDN, the functions are:

myregisterclass
initinstance


Source.


No, those are keywords, not function names. They are all lowercase because keyword lookups on MSDN are not case sensitive, so it doesn't matter.

Sneftel's response should have him on the right track.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave Hunt
Quote:
Original post by Gunslinger RR
According to MSDN, the functions are:

myregisterclass
initinstance


Source.


No, those are keywords, not function names. They are all lowercase because keyword lookups on MSDN are not case sensitive, so it doesn't matter.

Sneftel's response should have him on the right track.


Bleh that's what I get for trying to be helpful [grin]

In that case ignore my post and look at Sneftel's.

Share this post


Link to post
Share on other sites
Well to tell you the truth I have no idea maybe capatilazation?I'am really knew to windows programming.

Share this post


Link to post
Share on other sites
"undeclared" says nothing about capital letters. Look it up in the dictionary if you have to. Better yet, look it up in your book on C++. What does it mean to "declare" a function? Have you "declared" what your compiler has told you is "undeclared"?

Error messages aren't hieroglyphics. Modern compilers go far, far out of their way to give you error messages which are concise and helpful. They're written in English. Read them.

Share this post


Link to post
Share on other sites
are you saying I need to declare it like void registermyclass(HINSTANCE)
and then
{
....what it does...
}
I'am so confusing why can't you just tell me?

Share this post


Link to post
Share on other sites
Quote:
Original post by thugkilla
are you saying I need to declare it like void registermyclass(HINSTANCE)
and then
{
....what it does...
}

Pretty much. However, keep in mind that case sensitivity DOES matter.

Share this post


Link to post
Share on other sites
Quote:
Original post by thugkilla
But This function is a function included in the windows header.


From this article it seems that it isn't.

Quote:
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its use is only necessary if you want
// this code to be compatible with Win32 systems prior to the
// 'RegisterClassEx' function that was added to Windows 95. It is
// important to call this function so that the application will
// get 'well formed' small icons associated with it.



EDIT: But as proven before, I'm not quite sure myself. But that article may help you. If nothing else it defines MyRegisterClass for you.

Share this post


Link to post
Share on other sites
I didn't read it all ,but from the register part ,basically the register part makes the window?and gives it its properties.

Share this post


Link to post
Share on other sites
thugkilla,

The most valuable skill you will ever learn as a programmer is how to learn. We could just "give" you the answer, but you wouldn't have learned anywhere near as much: in the process of learning the solution to one problem, one frequently learns many more interesting and useful things. What's happening here is that people are nudging you toward that exploratory approach so that you can develop the fundamental curiousity and instinctual research that leads to great programming.

Documentation is your friend. Microsoft Windows is a large and complex system, but Microsoft has provided extensive documentation of [most of] its functionality and APIs. You, however, need to read carefully and research the unfamiliar. You know that feeling of frustration you have right now because it seems you're not making progress? It's the first stage; the second is the incredible elation you get from solving the problem and getting your application to compile, then to build, then to run, then to run correctly. And, yes, each of those steps entails a certain amount of learning: learn the language and programming environment, understand the compiler output and errors in particular, learn the linker output and errors, familiarize yourself with the debugger in order to verify logic.

It's a long process. It takes time. But when it's done, you'll have learned so much and will be so far ahead of other beginners precisely because you took the time to lay a strong foundation for yourself.

Good luck, and happy hacking!

Share this post


Link to post
Share on other sites
thanks guys it seams my author ***cough** **cough** Jonathon S harbour did not tell me about this and was waiting to explain it to me next chapter......



p.s. Well said Oluseyi.Truer words couldn't be spoken.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement