#### Archived

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

# MsgHandler: undeclared identifier

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

## 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.

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>

//#define DEBUG_MODE
//#ifdef DEBUG_MODE
//#endif

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 |
CS_HREDRAW | CS_VREDRAW;
sampleClass_s.lpfnWndProc =		MsgHandler;
sampleClass_s.cbClsExtra =		0;
sampleClass_s.cbWndExtra =		0;
sampleClass_s.hInstance =		hinstance;
sampleClass_s.hbrBackground =	(HBRUSH)GetStockObject(BLACK_BRUSH);
sampleClass_s.lpszClassName =	"Sample Class";

RegisterClassEx(&sampleClass_s);

HWND hwnd;
if (!(hwnd = CreateWindowEx(NULL,
"Sample Class",
"Sample Window",
WS_POPUP | WS_VISIBLE,
0, 0, 320, 240,
NULL,
NULL,
hinstance,
NULL)))
return(0);

}

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 on other sites
Not sure why the formatting got screwy on the define/includes but they aren''t run together like that.

##### 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 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 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.

1. 1
2. 2
JoeJ
20
3. 3
frob
16
4. 4
5. 5

• 10
• 10
• 11
• 13
• 9
• ### Forum Statistics

• Total Topics
632195
• Total Posts
3004717

×