Original Post
Im int the middle of adjusting some code, and ive come across the following error, to which i dont know whats wrong. Can anyone help out. here is the declaration of that function , (ive removed most of the uneeded stuff) here is the definition and here is where the window is setup
Error 1 error C2440: '=' : cannot convert from 'LRESULT (__stdcall winApp::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC' d:\programming\my game\winapp.cpp 59
class winApp
{
public:
winApp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP);
virtual ~winApp();
virtual void initMainWindow();
virtual void initDirect3D();
virtual int run();
LRESULT CALLBACK msgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
};
LRESULT CALLBACK winApp::msgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
//removed code
}
void winApp::initMainWindow()
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = &winApp::msgProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = mhAppInst;
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = TEXT("D3DWndClassName");
if( !RegisterClass(&wc) )
{
MessageBox(0, TEXT("RegisterClass FAILED"), 0, 0);
PostQuitMessage(0);
}
mhMainWnd = CreateWindow(TEXT("D3DWndClassName"), TEXT("Guns and blood 'n' stuff"),
WS_POPUP | WS_BORDER | WS_VISIBLE ,
(int)this->CentreOfScreen.x - (int)(this->GameWindowSize.x/2), //position x
(int)this->CentreOfScreen.y - (int)(this->GameWindowSize.y/2), //position y
(int)this->GameWindowSize.x, //size x
(int)this->GameWindowSize.y, //size y
NULL, NULL, mhAppInst, 0);
if( !mhMainWnd )
{
MessageBox(0, TEXT("CreateWindow FAILED"), 0, 0);
PostQuitMessage(0);
}
ShowWindow(mhMainWnd, SW_SHOW);
UpdateWindow(mhMainWnd);
}