CEntityDlg entDlg;
if(entDlg.DoModal() == IDOK)
{
this->currSel = entDlg.entSelList.GetCurSel();
}
// and DoDataEchange...
void CEntityDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ENTITY_SELECT, entSelList);
}
Problem with MFC DDX
I'm trying to retrive a member from a CDialogue, but the program crashes when trying to access entDlg after DoModal(). When debugging i see that the adress entDlg is NULL.
Isn't this supposed to work, and if so, any idea what i'm doing wrong? Have i missed something? I'm using MVC++ 7.1...
After DoModal the HWND of the dialog is destroyed, you're only left with the member variables. You cannot access controls of the dialog anymore.
In the dialogs OnClose copy the controls values into member variables which you can access after DoModal.
In the dialogs OnClose copy the controls values into member variables which you can access after DoModal.
You mean copy to variables in my parent window/class?
I suppose that's a way to do it.
It's strange though...i've seen many examples that looks the same way as my does, and they is said to work, but my doesn't...
I suppose that's a way to do it.
It's strange though...i've seen many examples that looks the same way as my does, and they is said to work, but my doesn't...
The call to GetCurSel will try to send a message to the list box which, after DoModal, has been destroyed. You need to store the currently selected index in the class in the OnOK method.
It's not strange, it's completely necessary.
It's not strange, it's completely necessary.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement