Jump to content
  • Advertisement


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


MsgHandler: undeclared identifier

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

Hi all, I''m following the "Game Programming Genesis Part I : Beginning Windows Programming" tutorial by Joseph Farrell on this site. I''ve gotten the basics of the code written up and am copiling to clean out any errors I made. I am now getting a C:\Documents and Settings\JS\Desktop\Scripts\C\Win\win.cpp(21) : error C2065: ''MsgHandler'' : undeclared identifier error when compiling. Here is the code I have so far.
#include <windows.h>
#include <windowsx.h>

//#define DEBUG_MODE
//#ifdef DEBUG_MODE

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine, int nCmdShow)

WNDCLASSEX sampleClass_s;

sampleClass_s.cbSize =			sizeof(WNDCLASSEX);
sampleClass_s.style =			CS_DBLCLKS | CS_OWNDC |
sampleClass_s.lpfnWndProc =		MsgHandler;
sampleClass_s.cbClsExtra =		0;
sampleClass_s.cbWndExtra =		0;
sampleClass_s.hInstance =		hinstance;
sampleClass_s.hIcon =			LoadIcon(NULL, IDI_WINLOGO);
sampleClass_s.hCursor =			LoadCursor(NULL, IDC_ARROW);
sampleClass_s.hbrBackground =	(HBRUSH)GetStockObject(BLACK_BRUSH);
sampleClass_s.lpszMenuName =	NULL;
sampleClass_s.lpszClassName =	"Sample Class";
sampleClass_s.hIconSm =			LoadIcon(NULL, IDI_WINLOGO);


HWND hwnd;
if (!(hwnd = CreateWindowEx(NULL,
							"Sample Class",
							"Sample Window",
							0, 0, 320, 240,

Anyone know what might cause this. As you can probably guess I am new to Windows programming (why else would I be going through the tutorial) so I might be missing something obvious. Any help is much appreciated.

Share this post

Link to post
Share on other sites
Not sure why the formatting got screwy on the define/includes but they aren''t run together like that.

Share this post

Link to post
Share on other sites
Yeah, you're missing the actual definition of your window procedure -- MsgHandler. You need the message handler function to register your window class.

[edited by - IndirectX on June 23, 2002 11:38:52 PM]

Share this post

Link to post
Share on other sites
You need a function named MsgHandler. Look up WndProc in the MSDN library. What you do when you write lpfnWndProc = MsgHandler is that you tell Windows that you want the MsgHandler function to be called whenever something happens to your window.

Share this post

Link to post
Share on other sites
Thanks for the responses guys. I was under the impression that the msghandler function was included in one of the windows header files. If I had just been patient I would have noticed that the tutorial covered this a page or two later. I''ll also check out the WndProc documetation. Thanks again.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!