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?
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
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: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...
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.
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.
Bookmarks