You can also add the word "static" for the CALLBACK.
For example, here is a solution to include Dialog CALLBACK in a class:
class CDialog
{
public:
VOID Create();
private:
HWND hMainDlg;
static BOOL CALLBACK DialogProcStatic(HWND, UINT, WPARAM, LPARAM);
virtual BOOL DialogProc(HWND, UINT, WPARAM, LPARAM);
};
//----------------------------------------------------------------------------------------
VOID CDialog::Create()
{
hMainDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), hWndParent, DialogProcStatic, (LPARAM)this);
}
//----------------------------------------------------------------------------------------
BOOL CALLBACK CDialog::DialogProcStatic(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
if (message == WM_INITDIALOG)
{
SetWindowLongPtr(hDlg, GWL_USERDATA, (LONG) lParam);
}
LPARAM pThis = GetWindowLongPtr(hDlg, GWL_USERDATA);
if (!pThis) return FALSE;
return (((CDialog*)pThis)->DialogProc(hDlg, message, wParam, lParam));
}
//----------------------------------------------------------------------------------------
BOOL CDialog::DialogProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
break;
default:
return FALSE;
}
return TRUE;
}