VC学习,Dialog中文本刷新问题

来源:互联网 发布:苹果手机自带软件 编辑:程序博客网 时间:2024/05/16 11:17

 

1, UpdateData的使用

UpdateData(FALSE)是将变量的值传到控件。
UpdateData(TRUE)是从控件中取值到关联的变量。

 

UpdateData(FALSE)会调用DoDataExchange,这样会刷新整个Dialog。如果要频繁地刷新一个控件,请不要用这个函数。

 

2, 怎样只刷新指定的控件?

a, 直接调用:控件->SetWindowText();  

b,  

  m_strHello   =   "Hello";//这是我定义的一个编辑框,关联变量为CString   m_strHello;  
  CDataExchange   de(this,   FALSE);//因为你是UpdateData(FALSE),所以这里直接用FALSE了  
  DDX_Text(&de,   IDC_EDIT1,   m_strHello);  

 

3, DoDataExchange() function

Called by the framework to exchange and validate dialog data. It is called by the UpdateData member function. Call UpdateData to initialize a dialog box's controls or retrieve data from a dialog box.

 

4, 对话框中的DDX DDV机制

这样可以使变量于Dialog上的显示关联上。

CDataExchange   class

Use this class if you are writing data exchange routines for custom data types or controls, or if you are writing your own data validation routines.

 

Dialog data exchange (DDX) is an easy way to initialize the controls in your dialog box and to gather data input by the user. Dialog data validation (DDV) is an easy way to validate data entry in a dialog box.

 

5, SetWindowText() function

If the target window is owned by the current process, SetWindowText causes a WM_SETTEXT message to be sent to the specified window or control.

 

原创粉丝点击