So I am in the process of creating a WNDCLASSEX within a method contained in D3DApp class which I am going to be deriving from with another class e.g. Engine, Game, etc... called InitMainWindow (which is also protected in the base class):
bool D3DApp::InitMainWindow() {
WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc; // This is where the error is!
wc.hInstance = mAppInst;
wc.hCursor = LoadCursor(mAppInst, IDC_ARROW);
wc.lpszClassName = L"MainWindow";
RegisterClassEx(&wc);
RECT rect = { 0,0,SCREEN_WIDTH,SCREEN_HEIGHT };
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
mMainWnd = CreateWindowEx(NULL, L"MainWindow", L"Test", WS_OVERLAPPEDWINDOW, 300, 300, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, mAppInst, NULL);
ShowWindow(mMainWnd, NULL);
return true;
}
My WNDPROC Callback declaration and definition is within the same D3DApp base class where InitMainWindow() is located, defined as such:
virtual LRESULT WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
When I am filling out the lpfnWndProc variable within the WNDCLASSEX struct I receive a C2440 error stating the following
'=': cannot convert from 'LRESULT (__cdecl D3DApp::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'
Do I have to create a definition of my WNDPROC Callback in the class deriving from D3DApp? Or do I have to completely remove this callback from the base class and derived class and place it outside and above the scope of my WinMain function? I've been researching for about 2 days on how to fix this error and have had no luck on finding any possible fixes... I think my C++ skills just may not be as excellent as I think they are. But if anyone can help me understand where my problem is that would be amazing!
p.s and yes I know I have some error checking to do but I just want to make sure it works for my compiler first :)