Jump to content
  • Advertisement
Sign in to follow this  
Android_s

Problem with MFC DDX

This topic is 4766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...
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);
}

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!