CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    9

    Why doesn't this code work?

    In an ordinary MFC modal Dialog based application I'm doing this.
    InitInstance()
    {
    CMyDlg dlg;
    int nResponse = dlg.DoModal();
    if(nResponse == ID_OK)
    do_something;
    nResponse = dlg.DoModal();
    }
    When I call DoModal for the second time, the dialog will not appear at all. Why is this?
    Please help.
    Thanks,
    Shyam

    ghanashyambrramakrishnabsshakuntalabr@404

  2. #2
    Join Date
    Apr 1999
    Posts
    12

    Re: Why doesn't this code work?

    Hi,

    if you do not want the dialog to reappear after pressing OK do you handling in OnOK in the dialog and let not destroy it.

    OR

    {
    CMyDlg *pMyDlg;

    pMyDlg = new CMyDlg;

    while (pMyDlg->DoModal() == ID_OK)
    {
    // DoSomething

    delete pMyDlg;
    pMyDlg = new CMyDlg;
    }

    delete pMyDlg;
    }

    Regards,

    Bernd




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured