Solved

Howto update a single edit-field ?

Posted on 2001-08-08
9
290 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift 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 100 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

726 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