Currently writing a dialog based application in MFC that creates a child dialog when a button on the main dialog is pushed. The child dialog then has 3 edit control boxes and one button. When the button is pressed the information from the three edit control boxes is retrieved and stored as separate CStrings. Those CStrings are passed to a function located in the Main Dlg.cpp. That function takes the those strings and inserts them in a list control. The program builds fine and runs up until the add button(on the child dialog) is pressed. Not sure why the program is crashing I appear to have correct arguments?I'm also not sure if this is the best way to pass data like this between two dialog boxes. Any better ideas with that are also appreciated.
Popup Add Button Function
void Popup::OnBnClickedPopadd()
{
CString str1, str2, str3;
CThermotronDlg dlg;
GetDlgItemText(ID_RampEdit,str1);
GetDlgItemText(ID_DwellEdit,str2);
GetDlgItemText(ID_TempEdit,str3);
dlg.ReciveAndDisplay(str1,str2,str3);
}
Receive and Display Function
void CThermotronDlg::ReciveAndDisplay(CString str1, CString str2,CString str3){
LPCTSTR ramp(str1),dwell(str2),temp(str3);
MyListEx.InsertItem(1,ramp);
MyListEx.SetItemText(0,1,dwell);
MyListEx.SetItemText(0,2,temp);
}
1
but then setting the item text for the item at index0
. Also, theLPCTSTR ramp(str1),dwell(str2),temp(str3);
is unnecessary. Usestr1
,str2
andstr3
directly. – Nik Bougalis