CWnd::UpdateData

本文详细介绍了MFC框架中的UpdateData函数,该函数用于同步控件与成员变量之间的数据。当参数为TRUE时,从控件获取数据并赋值给成员变量;参数为FALSE时,将成员变量的值赋给控件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

UpdateData,是用来刷新数据的。

Remarks

The framework automatically calls UpdateData with bSaveAndValidate set to FALSE when a modal dialog box is created in the default implementation of . The call occurs before the dialog box is visible. The default implementation of calls this member function with bSaveAndValidate set to TRUE to retrieve the data, and if successful, will close the dialog box. (If the Cancel button is clicked in the dialog box, the dialog box is closed without the data being retrieved.)

  UpdateData(TRUE) -- 刷新控件的值到对应的变量
  UpdateData(FALSE) -- 拷贝变量值到控件显示例如,窗口中用 DDX_Text(pDX, IDC_EDIT1, m_usercode); 将IDC_EDIT1编辑框控件与m_usercode变量做了关联,如果修改m_usercode之后要想对应控件显示更改,则需要调用UpdateData(FALSE);反之在IDC_EDIT1的oneditchanged()中需要加入UpdateData(TRUE);

  简单的说,如果Updatedata(TRUE) == 将控件的值赋值给成员变量;

  Updatedata(FALSE) == 将成员变量的值赋值给控件;

//

如果你为控件分配了变量 
UpdateData(true) 
是使用户输入的数据能够反映到变量上 
在函数调用之后变量才被赋值 

UpdateData(false) 
是当你给控件对应的变量赋过值之后,在控件上体现出来 
在函数调用之前,控件的值是不会随变量变化的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值