Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have a SDI game application all set and working. I need to display the results of the game at the end and i'm using a dialog. The dialog has it's own .h and .cpp of course and I call it from my Doc.cpp file.

CresultDlg ResDlg;<br />
	ResDlg.DoModal();


So I put this dialog call inside my MyProjectDoc.cpp file as that is where i have all the result data.

QUESTION: How do I display the local data variables i have in MyProjectDoc.cpp into the dialog box??


Thanks!
Posted

1 solution

suppose you have l_DailogData in your MyProjectDoc.cpp. suppose Its type is CString.Now what you have to do is
1.Add a member variable to your CresultDlg class, CString m_DailogData
2.write a member function of your CresultDlg class
void SetData(CString str)
  {
    m_DailogData = str;
  }

3.call this function in your MyProjectDoc.cpp
CresultDlg ResDlg;
  ResDlg.SetData(l_DailogData);
  ResDlg.DoModal();

4.write an OnInitDialog()function of your CresultDlg class
BOOL CresultDlg::OnInitDialog()
{
:
:
// code to set text to the control
// Eg:to set to editbox m_EditCntrl
// m_EditCntrl.SetWindowText(m_DailogData);
:
}
 
Share this answer
 
Comments
Narinearraul 7-Jun-11 23:49pm    
oh ok, that sounds reasonable. I don't need any DDX_CONTROL right?
Thanks so much I'm gonna try this!
Resmi Anna 8-Jun-11 2:14am    
not needed..
u can set value to that using control id.like GetDlgItem(ID)->SetWindowText()
Narinearraul 10-Jun-11 1:06am    
Yup! it worked Thanks so much! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900