CString, class problem
-
hello, I have a database program and i'm trying to get a CString variable from one class to work in another but i am getting strange results. It's dialog based and i made a new dialog class. I included the header files and it copiles with no errors but it spawns the main dialog when i try to use the string. (the string name is Value1 and its from the CChange class.)
CChange change; m_edit1.SetWindowText(change.Value1);
for some reason this launches the main dialog and does not work as a string. Any help would be much appreciated.
-
hello, I have a database program and i'm trying to get a CString variable from one class to work in another but i am getting strange results. It's dialog based and i made a new dialog class. I included the header files and it copiles with no errors but it spawns the main dialog when i try to use the string. (the string name is Value1 and its from the CChange class.)
CChange change; m_edit1.SetWindowText(change.Value1);
for some reason this launches the main dialog and does not work as a string. Any help would be much appreciated.
Actually what you want, You need a CString Value from child dialog to fill an edit control in parent dialog? Assume CChildDlg is your child and CParentDlg is your parent dialog clasess Let m_EditValue is the name of the Edit control variable in your parent Dlg, m_csChildStringVariable is the CString variable in your child dialog declared as public then in parent dialog: void CParentDlg ::OnOk() { CChildDlg oChild; oChild.DoModal(); /*from that dialog you get some value for csChildStringVariable */ // set parent edit control CString csTemp = oChild.m_csChildStringVariable; m_EditValue.SetWindowText(csTemp ); } try that.. I want to change Myself..Can u help me? :)
-
Actually what you want, You need a CString Value from child dialog to fill an edit control in parent dialog? Assume CChildDlg is your child and CParentDlg is your parent dialog clasess Let m_EditValue is the name of the Edit control variable in your parent Dlg, m_csChildStringVariable is the CString variable in your child dialog declared as public then in parent dialog: void CParentDlg ::OnOk() { CChildDlg oChild; oChild.DoModal(); /*from that dialog you get some value for csChildStringVariable */ // set parent edit control CString csTemp = oChild.m_csChildStringVariable; m_EditValue.SetWindowText(csTemp ); } try that.. I want to change Myself..Can u help me? :)
Well, actually im trying to get a string from the parent dialog to fill a child dialog edit box. I took your suggestion, but for some reason when i hit the button, it opens the main dialog. In the parent dialog i have:
Value1="test"; CChange change; change.DoModal();
then in the child i did:
CMainDlg maindlg; m_edit1.SetWindowText(maindlg.Value1); m_edit1.UpdateWindow();
when i hit the button, it launches the main dialog window as if it were opening the program again ! ? The reason i want this function is so that i can double click an entry in the listctrl and have it open with the strings in edit boxes, so that you can edit them and make changes.
-
Well, actually im trying to get a string from the parent dialog to fill a child dialog edit box. I took your suggestion, but for some reason when i hit the button, it opens the main dialog. In the parent dialog i have:
Value1="test"; CChange change; change.DoModal();
then in the child i did:
CMainDlg maindlg; m_edit1.SetWindowText(maindlg.Value1); m_edit1.UpdateWindow();
when i hit the button, it launches the main dialog window as if it were opening the program again ! ? The reason i want this function is so that i can double click an entry in the listctrl and have it open with the strings in edit boxes, so that you can edit them and make changes.
no_life wrote: The reason i want this function is so that i can double click an entry in the listctrl and have it open with the strings in edit boxes, so that you can edit them and make changes. ok..thats your problem is'nt. you can solve that in a better way like this. in your CChange , create a public member variable as m_csEditString and when you double click the list control in the parent dialog, get the currently selected String and call CChange change; change.m_csEditString = "String from parent list"; change.DoModal(); in the CChange class create a control variable for your edit control via ClassWizard let m_edit1 and in the OnInitDialog() function of your CChange class, just call m_edit1.SetWindowText(csEditString ); That will work..!! if you have anymore doubt...feel free to ask me.. I want to change Myself..Can u help me? :)