在对话框中显示局部变量值 [英] Displaying local variable values in dialog box

查看:81
本文介绍了在对话框中显示局部变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我有一个SDI游戏应用程序,它可以正常工作.我需要在最后显示游戏结果,我需要使用对话框.该对话框当然有它自己的.h和.cpp,我从我的Doc.cpp文件中调用它.

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();



因此,我将此对话框调用放入MyProjectDoc.cpp文件中,因为这是我拥有所有结果数据的位置.

问题:如何在对话框中显示MyProjectDoc.cpp中的本地数据变量?


谢谢!



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!

推荐答案

假设您的MyProjectDoc.cpp中有l_DailogData.假设它的类型是CString.现在您要做的是
1.将成员变量添加到您的CresultDlg类CString m_DailogData
2.编写CresultDlg类的成员函数
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.在MyProjectDoc.cpp中调用此函数


3.call this function in your MyProjectDoc.cpp

CresultDlg ResDlg;
  ResDlg.SetData(l_DailogData);
  ResDlg.DoModal();


4.编写CresultDlg类的OnInitDialog()函数


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);
:
}


这篇关于在对话框中显示局部变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆