I am trying to write this win32 program using WinApi and I am stuck because I have a problem with the tutorial.
mainwindow.h:
class MainWindow { public: MainWindow(HINSTANCE); ~MainWindow(void); LRESULT CALLBACK WndProcedure(HWND, UINT, WPARAM, LPARAM);
mainwindow.cpp:
MainWindow::MainWindow(HINSTANCE hInstance) : hwnd(0) { WNDCLASSEX WndClsEx; // [...] WndClsEx.lpfnWndProc = &MainWindow::WndProcedure; // [...] } LRESULT CALLBACK MainWindow::WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { // [...] }
I have to refer to MainWindow :: WndProcedure incorrectly because I follow the signature in exactly the same way as the tutorial says, however the line lpfnWndProc in the constructor gives a compile-time error:
error C2440: '=': cannot be converted from 'LRESULT (__stdcall MainWindow :: *) (HWND, UINT, WPARAM, LPARAM)' to 'WNDPROC'
Ozzah
source share