-
October 3rd, 2011, 08:09 AM
#1
UpdateData ???
I have a timer that updated read angles from a turn table. It does update each 200ms using UpdataData(FALSE)
Now I also have an EditBox where I enter some commands. But the timer overrun the commands I have entered before I have time to run UpdateData(TRUE).
Is there no way to update each EditBox by itself or any other way to avoid the problem?
-
October 3rd, 2011, 08:14 AM
#2
Re: UpdateData ???
...or any other way to avoid the problem?
Stop using updatedata and assign a member variable so you can do the read/write actions yourself.
-
October 3rd, 2011, 08:21 AM
#3
Re: UpdateData ???
By member variable I suppose you talk about a variable that is not connected in any way to the control. I did use the Control variable of category Value. Suppose that was wrong.
I will try what you suggest.
But....
What about GetDlgItem(IDC_EDIT1)->SetWindowTextW(CString) ?
Is that recommended or not?
-
October 3rd, 2011, 08:31 AM
#4
Re: UpdateData ???
Is that recommended or not?
Good question. I think it's what you prefer. I never use it, but I see a lot of posts using it. I prefer to assing a member variable. The only thing I know is that the UpdateData construction isn't one of MS best inventions
-
October 3rd, 2011, 08:36 AM
#5
Re: UpdateData ???
Originally Posted by jangus
By member variable I suppose you talk about a variable that is not connected in any way to the control. I did use the Control variable of category Value. Suppose that was wrong.
I will try what you suggest.
But....
What about GetDlgItem(IDC_EDIT1)->SetWindowTextW(CString) ?
Is that recommended or not?
If you have a member variable of “control” type, like CEdit for edit box, you can simply call its member function SetWindowText() directly.
Alternatively, you could call SetDlgItemText (), which is pretty much the same ad your GetDlgItem(IDC_EDIT1)->SetWindowTextW(CString).
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
October 3rd, 2011, 08:42 AM
#6
Re: UpdateData ???
Originally Posted by Skizmo
... The only thing I know is that the UpdateData construction isn't one of MS best inventions
I agree. It can makes sense only once in OnInitDialog and then in OnOK.
Avoiding UpdateData
Victor Nijegorodov
-
October 3rd, 2011, 09:31 AM
#7
Re: UpdateData ???
Originally Posted by VictorN
It makes sense whenever you need to get data to or from all the controls at once. For just populating a single control, SetWindowText is more efficient.
The article you quoted is written by somebody who doesn't understand how it's supposed to work. I've pointed out the many flaws in his thinking before. He's even addressed some of them himself in reply to comments. I'll do it again, if you're interested, but for not I'll just say it's a load of nonsense.
Last edited by GCDEF; October 3rd, 2011 at 09:34 AM.
-
October 3rd, 2011, 11:33 AM
#8
Re: UpdateData ???
Thanks everyone for all the help. I think I understand now
-
October 4th, 2011, 12:04 AM
#9
Re: UpdateData ???
Originally Posted by jangus
What about GetDlgItem(IDC_EDIT1)->SetWindowTextW(CString) ?
A lot of old timers like to program that way. For the folks that have discovered C++ and understand MFC, they prefer to create a control variable once during the life of the dialog and prefer to reuse it.
Btw, what you definitely shouldn't do is call the 'W' version of an api and pass it a CString variable. Just leave off the 'A' or 'W' and let the pre-processor use the build settings to figure out the correct api to use.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|