本文介绍了如何在MFC中使用编辑控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个编辑控制框,用户可以在其中输入一些值.所以我将编辑控件拖到对话框中.将变量类型为CString的值添加到此编辑控件.然后将消息类型为EN_CHANGE的事件处理程序添加到此编辑控件.下一步我该怎么做?

i want to make an edit control box in which user can enter some value. so i drag an edit control to my dialog. add a variable "value of type CString to this edit control. then i add an event handler of message type EN_CHANGE to this edit control. what should i do next?

推荐答案



CString m_strEditValue;


* .cpp


*.cpp

DoDataExchange(CDataExchange* pDX)
{
    DDX_Text(pDX, IDC_EDIT, m_strEditValue);
}
SomewhereElse()
{
    UpdateData(TRUE); // Get value from control to variable
      // m_strEditValue now contains the value entered in the edit control

    UpdateDate(FALSE); // Send variable data to control
      // The edit control now contains the value of m_strEditValue
}



UpdateData()最终将调用您的DoDataExchange()方法.使用调试器进入它,看看它如何工作以更好地理解.



UpdateData() will eventually call your DoDataExchange() method. Step into it with a debugger and see how it works to get a better understanding.


这篇关于如何在MFC中使用编辑控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-17 13:47