I'm not sure how to put a callback inside a class. What I have right now doesn't work.
Code:
class Listbox
{
private:
void Create();
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
};
/////////////////////////////////////////////////////////////////////
///// Create /////
/////////////////////////////////////////////////////////////////////
void Listbox::Create()
{
winc.hInstance = NULL;
winc.hInstance = NULL;
winc.lpszClassName = "Listbox";
winc.lpfnWndProc = WindowProcedure;
winc.style = CS_DBLCLKS;
winc.cbSize = sizeof(WNDCLASSEX);
winc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
winc.hCursor = LoadCursor(NULL, IDC_ARROW);
winc.lpszMenuName = NULL;
winc.cbClsExtra = 0;
winc.cbWndExtra = 0;
winc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
}
/////////////////////////////////////////////////////////////////////
///// Windows Proc Callback /////
/////////////////////////////////////////////////////////////////////
LRESULT CALLBACK Listbox::WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_COMMAND:
break;
case WM_DESTROY:
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
The errors I get are:
error C3867: 'Listbox::WindowProcedure': function call missing argument list; use '&Listbox::WindowProcedure' to create a pointer to member
error C2440: '=' : cannot convert from 'LRESULT (__stdcall Listbox::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'
I am not too worried about the first error cause if I do what it says I get the second error and the first one disapears.
Without classes (like a ragular windows app) it works fine, but if it is in a class like this it gives those errors.