Well, after many failed attempts (yet learning a ton!) and finally getting a laptop so I can work at uni, I am attempting to write a game (engine)that doesn't suck.
So I am reusing some of my old code, and something that used to work is no longer working for me. So without further ado, here is the code:
class ParvusKernel
{
public:
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
bool initialize(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow);
...
private:
...
//main handle
HWND main_window_handle;
//window instance
HINSTANCE main_instance;
WNDCLASSEX winclass; // this will hold the class we create
HWND hwnd; // generic window handle
MSG msg; // generic message
};
bool ParvusKernel::initialize(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow)
{
main_window_handle = NULL;
main_instance = NULL;
// first fill in the window class structure
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = &ParvusKernel::WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
switch(windowType)
{
case 0:
{
// register the window class
RegisterClassEx(&winclass);
// create the window
hwnd = CreateWindowEx(NULL, // extended style
WINDOW_CLASS_NAME, // class
"Parvus Alpha 1", // title
WS_POPUP | WS_VISIBLE,
0,0, // initial x,y
400,400, // initial width, height
NULL, // handle to parent
NULL, // handle to menu
hinstance,// instance of this application
NULL);// extra creation params
//save the handle and instance
main_window_handle = hwnd;
main_instance = hinstance;
break;
}
case 1:
{
//TODO: Add full screen creation code here.
break;
}
}
}
with
winclass.lpfnWndProc = &ParvusKernel::WindowProc; erroring with the error:
1>\parvus_kernel.cpp(18) : error C2440: '=' : cannot convert from 'LRESULT (__stdcall ParvusKernel::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'
1> There is no context in which this conversion is possible
This used to work...any ideas? Visual studio 2005 pro is my IDE..
Cheers