I think you can simply your call to DialogBoxParam() like this:
DialogBoxParam(hInstance, "DIALOG1", NULL, (DLGPROC)MainDialogProc, 0);
Try it and if it doesn't work, use the MAKEINTRESOURCE.
Also, your dialog procedure should be a CALLBACK function. Plus, each button needs to be processed:
Code:
BOOL CALLBACK MainDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch( uMsg ) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch( wParam ) {
//case IDOK:
// EndDialog( hDlg, TRUE );
// return TRUE;
case 106:
EndDialog( hDlg, TRUE );
return TRUE;
case 107:
EndDialog( hDlg, TRUE );
return TRUE;
case IDCANCEL:
EndDialog( hDlg, TRUE );
return TRUE;
}
break;
}
return FALSE;
}
Also there are predefined names for OK and CANCEL buttons. To use these, change your .rc, and change 106 to IDOK and 107 to IDCANCEL. Then you can remove the cases for 106 and 107 in the dialog procedure, and uncomment the one for IDOK. If you had a third button, add code to process it:
Code:
BOOL CALLBACK MainDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch( uMsg ) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch( wParam ) {
case IDOK:
EndDialog( hDlg, TRUE );
return TRUE;
case IDCANCEL:
EndDialog( hDlg, TRUE );
return TRUE;
case BUTTON3:
...
return TRUE;
}
break;
}
return FALSE;
}