problem setting text in edit box
-
hi i'm creating a new dialog box when a user clicks a button om my existing dialog, using code: CDialog *cd = new CDialog(IDD_SHOW); cd->DoModal(); //displayed modally delete cd; how do i set text in an edit box in the dialog box IDD_SHOW (the id of editbox id IDC_E_DATA.)
-
hi i'm creating a new dialog box when a user clicks a button om my existing dialog, using code: CDialog *cd = new CDialog(IDD_SHOW); cd->DoModal(); //displayed modally delete cd; how do i set text in an edit box in the dialog box IDD_SHOW (the id of editbox id IDC_E_DATA.)
-
hi i'm creating a new dialog box when a user clicks a button om my existing dialog, using code: CDialog *cd = new CDialog(IDD_SHOW); cd->DoModal(); //displayed modally delete cd; how do i set text in an edit box in the dialog box IDD_SHOW (the id of editbox id IDC_E_DATA.)
You have to make your own class derived from CDialog: when you have your resource editor open, open classWizzard and it will says that IDD_SHOW is a new resource and if you want to create a new class for it. Say yes and specify your class name (CMyDialog for example). Click on the member variable tab and add a member variable for your edit box (IDC_E_DATA) of type CString (says m_MyString). Then you have to add a public member function within your class to set the string:
CMyDialog::SetStringData(CString NewString)
{
m_MyString = NewString;
}Then, in your OnInitDialog function, call UpdateData(FALSE); Thats it, hope this helps Cédric Moonen
-
hi i'm creating a new dialog box when a user clicks a button om my existing dialog, using code: CDialog *cd = new CDialog(IDD_SHOW); cd->DoModal(); //displayed modally delete cd; how do i set text in an edit box in the dialog box IDD_SHOW (the id of editbox id IDC_E_DATA.)
You could try to get a pointer to the edit ctrl or even make a public var that hosts the edit ctrl. But the best method (afaik) would be to create a public function inside the newly created dialog that receive a CString as a parameter. Then from your code you should have to call that function and that would be done. ----------------------------------------------------------------------------- Ways for setting the text (inside the function and in the implementation file of your dialog class): 1. you should create a CString var. related to the edit control using the class wizard, once that is done you can modify it's value in that previously named public function by setting the value and
UpdateData(FALSE);
call. 2. you could create a CEdit var. related to the edit control using the class wizard, once that is done you can modify it's value by usingSetWindowText();
. 3. you could try to search for your control inside the dialog and then set the text directly viaSetWindowText();
hope this helps... -
hi i'm creating a new dialog box when a user clicks a button om my existing dialog, using code: CDialog *cd = new CDialog(IDD_SHOW); cd->DoModal(); //displayed modally delete cd; how do i set text in an edit box in the dialog box IDD_SHOW (the id of editbox id IDC_E_DATA.)
-
hi i'm creating a new dialog box when a user clicks a button om my existing dialog, using code: CDialog *cd = new CDialog(IDD_SHOW); cd->DoModal(); //displayed modally delete cd; how do i set text in an edit box in the dialog box IDD_SHOW (the id of editbox id IDC_E_DATA.)