Youkoulele

Hello,

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->Create(IDD_PARAMETER);
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
m_test->ShowWindow(SW_SHOW);
}


Can someone help me how to make this work.





Re: Visual C++ General DoModal()

rp_suman

Not sure but did you try this:

m_test = new CBtnDspl();

[Function paranthesis at the end].

Best Regards,

Suman





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;
m_test.DoModal();

}