Re: DoModal()
AFter DoModal call, any dialog contrlos don't exist. This is why MFC gives
you DoDataExchange function and DDX macros.
"hamishd" <Hamish.Dean@gmail.com> wrote in message
news:3dd8d8f6-e023-4629-b140-9c9d27281f65@z6g2000pre.googlegroups.com...
On Jan 11, 5:53 pm, "David Ching" <d...@remove-this.dcsoft.com> wrote:
"hamishd" <Hamish.D...@gmail.com> wrote in message
news:0c554795-1128-4696-bb12-3d0a5b85ddcb@a12g2000pro.googlegroups.com...
Hi, I'm calling a dialog via DoModal()...
OpenDataDlg Dlg;
if(Dlg.DoModal()==IDOK){
//do things here.. for example:
int Value = Dlg.m_Value;
}
My problem is once the Dlg exits I get an error on the line "int Value
= Dlg.m_Value;".
CDialog hWnd=0x00000000.
Why is my Dlg disappearing from memory?
One thing to note is, I accidentally deleted the IDOK button. So I re-
made a new one using the following steps:
1. Added a new button to the dialog
2. Set it to Default Button style
3. Gave it the ID of IDOK
This is normally fine. You should be able to access Dlg.m_Value after the
DoModal() completes. It's normal for CDialog::m_hwnd to be NULL after
DoModal() because the actual window has been destroyed (but the Dlg class
instance still exists, so you can still access Dlg.m_Value). What exactly
is the error?
It is crashing when I try to access a CListBox:
_AFXWIN_INLINE int CListBox::GetCount() const
{ ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd,
LB_GETCOUNT, 0, 0); }
I am fixing now by copying the data i want from the clistbox to
another member variable on exit.