MsgHandler: undeclared identifier

Started by
3 comments, last by petway56 21 years, 9 months ago
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.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);

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.
Advertisement
Not sure why the formatting got screwy on the define/includes but they aren''t run together like that.
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]
---visit #directxdev on afternet <- not just for directx, despite the name
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.
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.

This topic is closed to new replies.

Advertisement