-
July 7th, 2010, 02:29 PM
#1
[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
-
July 7th, 2010, 02:31 PM
#2
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.
-
July 7th, 2010, 03:38 PM
#3
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.
-
July 7th, 2010, 04:01 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|