CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2006
    Location
    beyond the pillars of hercules
    Posts
    295

    [RESOLVED] [MFC] Modal Dialog Question

    im making a simple "Input Dialog" that will return the value of an Edit Box back to the calling Dialog

    Code:
    	CInputDlg InputDlg(this);
    
    	if(InputDlg.DoModal() == IDOK)
    	{
    		CString res= InputDlg.ReturnName();
    	}
    Code:
    CString CInputDlg::ReturnName()
    {
    	//wchar_t test[260]={0};
    	CString res;
    	GetDlgItemText(IDC_Rename,res);
    return res;
    }
    but application crashes on GetDlgItemText() with "Debug Assertion Failed"

    any ideas why?
    thanks

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: [MFC] Modal Dialog Question

    After DoModal the controls don't exist any more. If you use the standard DDX mechanism, you get the value from the member variable, not the control.

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: [MFC] Modal Dialog Question

    Control's don't exist before you call DoModal() and no longer exists after DoModal() returns. To get the values from the controls, you must store them in class fields (variables) before the window is destroyed and read them from the parent window.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    May 2006
    Location
    beyond the pillars of hercules
    Posts
    295

    Re: [MFC] Modal Dialog Question

    thank you both... now i understand , and problem fixed

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