I am having trouble with the DoModal() function in MFC.
I have two dialog box, a primary one with a button which allow to open the second one I want the second one to be modal but I have not succeeded after spending so much time on such simple issue.

Here is my code:

void CGUI_DisplayDlg:SurprisenBnClickedButton1()
CBtnDspl *m_test = NULL;
m_test = new CBtnDspl;
m_test->DoModal(); //This is where the code display "Debud assertion Failed", if I undo //this line the prog works fine. but I want the dialog to be modal

Can someone help me how to make this work.

Re: Visual C++ General DoModal()


Not sure but did you try this:

m_test = new CBtnDspl();

[Function paranthesis at the end].

Best Regards,


Re: Visual C++ General DoModal()

Andreas Masur

You do not need to call 'Create'...this is done automatically by 'DoModal()'...

Code Snippet

void CGUI_DisplayDlg::OnBnClickedButton1()

CBtnDspl m_test;