⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_50996.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:50996 发表者:鹏程 发表日期:2003-08-28 11:24:11
<br>主题:一个很简单的问题解决不了,请教了
<br>内容:我在“About”对话框中放置了两个编辑框EDIT1和EDIT2,我想在运行时,在EDIT1中输入文字,当在打字时,要求在EDIT2中显示出在EDIT1中敲入的文字。<BR>&nbsp;&nbsp; 请教该怎样添加消息及函数?&nbsp;&nbsp;&nbsp;&nbsp; “About”对话框的代码下:<BR><BR><BR><BR>/////////////////////////////////////////////////////////////////////////////<BR>// CAboutDlg dialog used for App About<BR><BR>class CAboutDlg : public CDialog<BR>{<BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CAboutDlg();<BR><BR>// Dialog Data<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_DATA(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;enum { IDD = IDD_ABOUTBOX };<BR>&nbsp;&nbsp;&nbsp;&nbsp;CString&nbsp;&nbsp;&nbsp;&nbsp;m_edit1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;CString&nbsp;&nbsp;&nbsp;&nbsp;m_edit2;<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_DATA<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// ClassWizard generated virtual function overrides<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_VIRTUAL(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;protected:<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual void DoDataExchange(CDataExchange* pDX);&nbsp;&nbsp;&nbsp;&nbsp;// DDX/DDV support<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_VIRTUAL<BR><BR>// Implementation<BR>protected:<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_MSG(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_MSG<BR>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_MESSAGE_MAP()<BR>};<BR><BR>CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_DATA_INIT(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_edit1 = _T(&#34;&#34;);<BR>&nbsp;&nbsp;&nbsp;&nbsp;m_edit2 = _T(&#34;&#34;);<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_DATA_INIT<BR>}<BR><BR>void CAboutDlg::DoDataExchange(CDataExchange* pDX)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CDialog::DoDataExchange(pDX);<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_DATA_MAP(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;DDX_Text(pDX, IDC_EDIT1, m_edit1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;DDX_Text(pDX, IDC_EDIT2, m_edit2);<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_DATA_MAP<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>}<BR><BR>BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_MSG_MAP(CAboutDlg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;//}}AFX_MSG_MAP<BR>END_MESSAGE_MAP()<BR><BR>// App command to run the dialog<BR>void CXApp::OnAppAbout()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CAboutDlg aboutDlg;<BR>&nbsp;&nbsp;&nbsp;&nbsp;aboutDlg.DoModal();<BR>}
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:ax 回复日期:2003-08-28 11:43:24
<br>内容:CEdit的EN_CHANGE事件<BR>void CAboutDlg::OnChangeEdit1() <BR>{<BR>&nbsp;&nbsp; CString str;<BR><BR>&nbsp;&nbsp; GetDlagItemText(IDC_EDIT1,str);<BR>&nbsp;&nbsp; SetDlgItemText(IDC_EDIT2,str);&nbsp;&nbsp;&nbsp;&nbsp;<BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:鹏程 回复日期:2003-08-28 12:04:43
<br>内容:谢谢!<BR>另外,我的书上没有“GetDlagItemText(IDC_EDIT1,str);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetDlgItemText(IDC_EDIT2,str); ”函数,<BR><BR>如果遇到类似的问题,又怎么知道该用哪个函数呢?请指教谢谢。<BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -