Click to See Complete Forum and Search --> : Easy question!
Yoh-hei
August 8th, 1999, 10:51 PM
Hello:
I use vc++6.0 MFC.Built A Dialog class .
Now I add a CEdit.I want change the value
in CEdit .Which function can do it?
Welcome any advice!
Thanks!
ChrisD
August 8th, 1999, 11:40 PM
There are a couple of ways to accomplish this.
1) Add a member variable of type CString to your dialog for the CEdit you just added. (with Classwizard). Then just set the text you want and call UpdateData(FALSE); FALSE - updates the controls TRUE get values from controls
2) Add a member variable of type CEdit with Classwizrd and use m_myEdit.SetWindowText("TEXT");
3) use GetDlgItem(IDC_YOUREDIT_ID)->SetWindowText("TEXT");
HTH,
Chris
Yoh-hei
August 9th, 1999, 01:10 AM
Thank you:
Like your advice.(I created Dialog-base application)
(1)I added a member variable of CString is m_name.(Use it change value)
(2)I Add CEdit m_Edit.Add m_Edit.SetWindowText("TEXT")
and GetdlgItem(IDC_my)->SetWindowText("TEXT") in OnInitDialog()
When I run the result:First display "TEXT" in CEdit.
But When I change the value use m_name.But the display
not change.I add UpdataData(TRUE);The run is error(UpdataData no define);
Could you help me?
Thanks!
Burlacu Ovidiu
August 9th, 1999, 01:20 AM
If you defined a variable associated with your edit is not necessary to use GetDlgItem or a variable of type CEdit.
If you need to take text from edit ctrl and put hem in your variable do this:
UpdateData();
If you need to take text from your variable and put him in your edit ctrl do this:
m_name = "New value you want";
UpdateData( FALSE );
That's all.
Let me know if this help u
Regards,
Ovidiu
Yoh-hei
August 9th, 1999, 08:06 PM
Thank you very much!
That's very good like you advice!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.