Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UpdateData(FALSE)

Status
Not open for further replies.

BeerFizz

Technical User
Jan 23, 2004
28
0
0
Hi,

When does updatedata actually do the update to a dialog.

For example, if I am sitting in a loop incrementing a counter every second and I want to display the counter to an edit field, it does not appear to work as I would expect.

It appears to wait until the loop is complete and then display the last value...

How does UpdateData work and how can I do what I want?

Thanks for help in adavance
Phil
 
Before you post the code here replace the CEdit in which you want to display the counter by a CStatic and your program will work fine.
Code:
CStatic	m_Label;
void CMyDlg::ShowCounter(int iMax)
{
	CString sTemp;
	for (int i = 0;i<iMax;i++)
	{
	   sTemp.Format("Index is %d",i);
           m_Label.SetWindowText(sTemp);
	   Sleep(1000);
	}

}
-obislavu-
 
>How does UpdateData work

Just to clarify:
The concept of mapping non-control members to dialog controls is primarily used for shuffling data to/from the dialog when the dialog itself doesn't exist.

Example
Code:
{
  CMyDlg d;
  // CMyDlg gets created in the DoModal
  //ie isn't created yet
  d.m_SomeString = "Foo";

  // DoModal: UpdateData in OnInitDialog 
  // will set the control's text
  if (d.DoModal() == IDOK)
  {
     // CDialog::OnOk gets the text from 
     //the control end puts it in the string
     if (d.m_SomeString == "Bar")
     {
         //...
     }
  }
}

You normally don't have to bother with UpdataData as the are done by default in CDialog. And if youre shuffling data about "internally" in the dialog use control members instead (as obislavu showed).

/Per
[sub]
&quot;It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure.&quot;[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top