Hi all,
I want to create a separate class in my C++ application which creates a dialog from a resource, similar to extending CDialog in MFC, however I would like to avoid using MFC.
For example, I would like to be able to run the following code in my WinMain function:
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE h0, LPSTR lpCmdLine, int nCmdShow)
{
MainWindow(this);
}
and have it display my dialog. I have tried using the following code in my MainWindow class:
MainWindow::MainWindow(HWND hWnd)
{
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_MAINDLG), NULL, MainWindow::MainDlgProc);
}
BOOL CALLBACK MainWindow::MainDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
return TRUE;
default:
return FALSE;
}
return TRUE;
}
But am getting errors regarding the MainWindow::MainDlgProc
argument in the DialogBox()
call. I have tried a variety of options like reinterpret_cast<DLGPROC>(MainDlgProc)
, (DLGPROC) MainDlgProc
, both with and without MainWindow::
prepended, however as you may guess this was just me guessing as I have got in over my head!
Any help someone could give me would be greatly appriciated - even if it is in the form of a tutorial, although sample code would be preferable :)
Thanks in advance.