Displaying MessageBox in OnInitDialog handler

When i try to put a messagebox in the OnInitDialog Handler using VS2005 the dialogs modal property is removed.

BOOL CDlg::OnInitDialog()
{
CDialog::OnInitDialog();
AfxMessageBox("hi"); //This message box removes the dialog's modal property and it default properties.
return TRUE;
}

CMyView::OnShowDialog()
{
CDlg dlg;
dlg.DoModal();
}

Is this a bug or am i wrong somewhere


Answer this question

Displaying MessageBox in OnInitDialog handler

  • Gloria123

    1. The dialogs modal property is missing it became modeless.
    2. The default location of the dialog was set to centerparent but after displaying the messagebox dialog's location is defaulted to windows default location

  • Priya RV

    I dont think you are wrong here. Its the internal implementation of MFC.

    You can use MessageBox instead of AfxMessageBox. This should not cause any problem.

    Regards



  • Kevin Service

    Actually what's happening to your dialog box
    what all are missing and how it's behaving


  • Displaying MessageBox in OnInitDialog handler