?
Solved

Howto update a single edit-field ?

Posted on 2001-08-08
9
Medium Priority
?
294 Views
Last Modified: 2013-11-20
is it possible to make a UpdateData( false ) to a single edit-field ? Cause i wanna update the value of a edit-field every second by a timer. But every time the time makes UpdateData( false ) all changes a user made in an other edit-field are lost.
0
Comment
Question by:DennisWood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 4

Expert Comment

by:captainkirk
ID: 6365805
Just capture the text of the other edit control(s) and call SetWindowText() to restore them...

I don't think you can UpdateData() to just affect one control.
0
 

Author Comment

by:DennisWood
ID: 6365838
How do i capture ? UpdateData( true ) ?
And is SetWindowText pending on single EditField like the following ? So i wouldn't need UpdateData( true ) ?

OnTimer
{
UpdateData();
m_fEditTemp = getTemperature();    // Reads aktual Temperature
((CEdit *)GetDlgItem( IDC_EDIT_TEMP ))->SetWindowText();
}
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 6365887
Use GetWindowText() for each control after you call UpdateData(TRUE), then call SetWindowText() for each control to restore the text.

BTW, UpdateData() should not interfere with the contents of edit controls -- something else must be destroying your data...
0
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 

Author Comment

by:DennisWood
ID: 6365928
How do i capture ? UpdateData( true ) ?
And is SetWindowText pending on single EditField like the following ? So i wouldn't need UpdateData( true ) ?

OnTimer
{
UpdateData();
m_fEditTemp = getTemperature();    // Reads aktual Temperature
((CEdit *)GetDlgItem( IDC_EDIT_TEMP ))->SetWindowText();
}
0
 

Author Comment

by:DennisWood
ID: 6365942
ooops
0
 

Author Comment

by:DennisWood
ID: 6365990
the UpdateData( true ) doesn't, the UpdateData( false ) destroys.
The problem is, while a user is typing something into an edit-field, the timer-event occurs, and UpdateData( false ) writes the empy membervaiable into the edit-fields.
for example i have an edit-field IDC_EDIT_KOMMENT connect with the membervariable CString m_sEditKomment. Cause, while the user is editing this field, the membervariable is empty.
I looked into the code and saw that i don't call UpdateData() on Timer intro.
Is it right that GetWindowText() makes the same transfer from EditField to MemberVariable of a specific Control like UpdateData ?
So it would be enough :
OnTimer
{
  // float m_fEditTemp
  m_fEditTemp = getTemperature(); // Sets Temperature
  ((CEdit *)GetDlgItem( IDC_EDIT_TEMP ))->SetWindowText();
   GetDlgItem( IDC_EDIT_TEMP )->RedrawWindow();
}

Sorry i can't test it here. So i have to undestand it.
}
0
 
LVL 4

Accepted Solution

by:
captainkirk earned 400 total points
ID: 6366027
If all you want to do is update text in a specific edit control, then UpdateData(FALSE) is definitely not what you want to do while a user is typing.

The code you provided (with mods) might do the trick:

void CYourClass::OnTimer(UINT nIDEvent)
{
  // float m_fEditTemp
  m_fEditTemp = getTemperature(); // Sets Temperature

  // convert temp to string here...
  CString csTemperature = _T("");
  csTemperature .Format(_T("%.2f"), m_fEditTemp);

  ((CEdit *)GetDlgItem(IDC_EDIT_TEMP))->SetWindowText(csTemperature);
  GetDlgItem( IDC_EDIT_TEMP )->RedrawWindow(); // this might not be needed...
}



0
 

Author Comment

by:DennisWood
ID: 6366055
Thanx a lot for your well nerves ;-) It would be great if you coulld answer nearly so quick the question with html-printing ( question 20165474 ).
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 6366086
thanks....
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question