Help Please.
I am working on my first game engine (just started). I am having problems w/ registering my windows class. I have tryed so many thing i cant understand why. I am running on XP and can only think that could be the problem. I will post the code below and if you could tell me where my error lies that would be great. Thanx for the help!
==========================
code starts below
==========================
WNDCLASSEX windowC;
windowC.style = CS_HREDRAW |CS_VREDRAW | CS_OWNDC;
windowC.lpfnWndProc = (WNDPROC)::WndProc;
windowC.cbClsExtra = 0;
windowC.cbWndExtra = 0;
windowC.hInstance = hInstance;
windowC.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowC.hCursor = LoadCursor(NULL, IDC_ARROW);
windowC.hbrBackground = (HBRUSH)(COLOR_WINDOW+3);
windowC.lpszMenuName = NULL;
windowC.lpszClassName = WIN_NAME;
windowC.cbSize = sizeof(WNDCLASSEX);
windowC.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
if(!RegisterClassEx(&windowC))
{
MessageBox(NULL,"Failed to Register Class!","ERROR", MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
if(!(hWnd = CreateWindowEx( NULL, WIN_NAME,
title, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0, width, height,
NULL, NULL, hInstance, NULL)))
{
appKillGLWindow();
MessageBox(NULL,"Failed Window Creation","ERROR",MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
=========================
code ends
=========================
Thanx again. : )
Just a guess ...
Is it a problem with the Windows Procedure? Maybe the function isn''t called WndProc, or there''s no prototype for it?
windowC.lpfnWndProc = (WNDPROC)::WndProc;
should be
windowC.lpfnWndProc = (WNDPROC) WndProc;
Is it a problem with the Windows Procedure? Maybe the function isn''t called WndProc, or there''s no prototype for it?
windowC.lpfnWndProc = (WNDPROC)::WndProc;
should be
windowC.lpfnWndProc = (WNDPROC) WndProc;
ok i take the :: between the WndProc and (WNDPROC) and i get an error: C:\Program Files\Microsoft Visual Studio\MyProjects\MercuryTree\Ren_0001\CWindowApp.cpp(34) : error C2440: ''type cast'' : cannot convert from '''' to ''long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)''
None of the functions with this name in scope match the target type
HELP
None of the functions with this name in scope match the target type
HELP
I would say it is probably a problem with your hInstance.
What value are you giving it?
You either have to pass it the value given to your program when it is started (the WinMain hInstance value), or you have to get a handle.
What value are you giving it?
You either have to pass it the value given to your program when it is started (the WinMain hInstance value), or you have to get a handle.
The prototype of your message handler should like like:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
You need the CALLBACK part. Then, all you need to do when registering the windows class is
...
windowC.lpfnWndProc = WndProc;
...
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
You need the CALLBACK part. Then, all you need to do when registering the windows class is
...
windowC.lpfnWndProc = WndProc;
...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement