Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Howto update a single edit-field ?

Posted on 2001-08-08
9
Medium Priority
?
299 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
Industry Leaders: 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 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

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!

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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 a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 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