Dialog Data Exchange
-
Hi, I am calling a Dialog box from a propery page. The dialog box contains an edit box which takes in numbers as user inputs. I then want these numbers to be used on the property page. However, as I "OK" the dialog box and go back to it, the numbers have changed back to what the constructor contains. I have used UpdataData(TRUE); but it continues to revert back to the original numbers.
void CMyPropPage::OnCallMyDlgButton() { UpdateData(TRUE); CMyDlg ViewData; ViewData.DoModal(); UpdateData(FALSE); }
Have I missed something out? kash -
Hi, I am calling a Dialog box from a propery page. The dialog box contains an edit box which takes in numbers as user inputs. I then want these numbers to be used on the property page. However, as I "OK" the dialog box and go back to it, the numbers have changed back to what the constructor contains. I have used UpdataData(TRUE); but it continues to revert back to the original numbers.
void CMyPropPage::OnCallMyDlgButton() { UpdateData(TRUE); CMyDlg ViewData; ViewData.DoModal(); UpdateData(FALSE); }
Have I missed something out? kashKash wrote: Have I missed something out? Yep! MSDN[^]says:
The framework automatically calls UpdateData
with bSaveAndValidate set to FALSE when a modal
dialog box is created in the default implementation
of CDialog::OnInitDialog. The call occurs before
the dialog box is visible. The default
implementation of CDialog::OnOK calls this member
function with bSaveAndValidate set to TRUE to
retrieve the data, and if successful, will close
the dialog box.So you Do not have to call UpdataData() yourself:
void CMyPropPage::OnCallMyDlgButton()
{
CMyDlg ViewData;
if (ViewData.DoModal()==IDOK)
m_Number = ViewData.m_Number;
}
My opinions may have changed, but not the fact that I am right.
-
Hi, I am calling a Dialog box from a propery page. The dialog box contains an edit box which takes in numbers as user inputs. I then want these numbers to be used on the property page. However, as I "OK" the dialog box and go back to it, the numbers have changed back to what the constructor contains. I have used UpdataData(TRUE); but it continues to revert back to the original numbers.
void CMyPropPage::OnCallMyDlgButton() { UpdateData(TRUE); CMyDlg ViewData; ViewData.DoModal(); UpdateData(FALSE); }
Have I missed something out? kash -
Kash wrote: Have I missed something out? Yep! MSDN[^]says:
The framework automatically calls UpdateData
with bSaveAndValidate set to FALSE when a modal
dialog box is created in the default implementation
of CDialog::OnInitDialog. The call occurs before
the dialog box is visible. The default
implementation of CDialog::OnOK calls this member
function with bSaveAndValidate set to TRUE to
retrieve the data, and if successful, will close
the dialog box.So you Do not have to call UpdataData() yourself:
void CMyPropPage::OnCallMyDlgButton()
{
CMyDlg ViewData;
if (ViewData.DoModal()==IDOK)
m_Number = ViewData.m_Number;
}
My opinions may have changed, but not the fact that I am right.
-
yep that works, but when I re-open the dialog box, the changes have been lost. I want to keep the changes fixed and not for it to revert to the constructor values of the dlg box. kash
Kash wrote: I want to keep the changes Then you can set the desired value before the
DoModal()
, as palbano suggested.
My opinions may have changed, but not the fact that I am right.
-
CMyDlg ViewData; ViewData.m_number = 10; // set data to previous value ViewData.DoModal(); m_viewdatanumber = ViewData.m_number; // capture data from dialog
"No matter where you go, there your are..." - Buckaoo Banzi
-pete