MFC中编辑框的更新问题~

wei_pei_li 2013-01-15 10:30:31
我想让编辑框内容做到实时显示,但是我试过了很多种方法,都不行,加入UpdateData(false);和不加没区别,都是最后才显示,,哪位大虾可以给出出建议~
...全文
365 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ppsharp 2013-01-15
  • 打赏
  • 举报
回复
好久没玩MFC了。
漫步者、 2013-01-15
  • 打赏
  • 举报
回复
UpdateData(false)改成UpdateData(true)
漫步者、 2013-01-15
  • 打赏
  • 举报
回复
UpdateData(false)->UpdateData(true)
未注销 2013-01-15
  • 打赏
  • 举报
回复
发消息...
wei_pei_li 2013-01-15
  • 打赏
  • 举报
回复
我弄明白了,是先用UpdateData(TRUE) , 改变变量之后UpdateData(FALSE) 将关联变量的值传给控件窗口 最后要进行更新,UpdateWindow(); 最后实现了实时显示!
wen981512 2013-01-15
  • 打赏
  • 举报
回复
简单的使用方法 拖两个edit控件进来 分别给这两个控件命名为 int m_a; int m_b; //////////////////////////////////////////// CMyTestMfcDlg::CMyTestMfcDlg(CWnd* pParent /*=NULL*/) : CDialog(CMyTestMfcDlg::IDD, pParent) , m_a(0) , m_b(0) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CMyTestMfcDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX, IDC_EDIT1, m_a); DDX_Text(pDX, IDC_EDIT2, m_b); } ///////////////////////////////////////////////// 这些步骤,你在控件上面点右键选择添加变量就可以完成,变量类型选择(value),当然选择control也可以完成。 加一个按钮 当点击按钮 void CMyTestMfcDlg::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 //OnOK(); UpdateData(TRUE); m_b = m_a; UpdateData(FALSE); } 就得到你的结果,希望能对你有帮助;
wuxupu 2013-01-15
  • 打赏
  • 举报
回复
UpdateData(TRUE) 将控件窗口的值传给关联变量 UpdateData(FALSE) 将关联变量的值传给控件窗口 第二步是显示,但是需要先执行第一步刷新控件关联变量的值。
赵4老师 2013-01-15
  • 打赏
  • 举报
回复
CEdit的基类是CWnd CWnd::Invalidate void Invalidate( BOOL bErase = TRUE ); Parameters bErase Specifies whether the background within the update region is to be erased. Remarks Invalidates the entire client area of CWnd. The client area is marked for painting when the next WM_PAINT message occurs. The region can also be validated before a WM_PAINT message occurs by the ValidateRect or ValidateRgn member function. The bErase parameter specifies whether the background within the update area is to be erased when the update region is processed. If bErase is TRUE, the background is erased when the BeginPaint member function is called; if bErase is FALSE, the background remains unchanged. If bErase is TRUE for any part of the update region, the background in the entire region, not just in the given part, is erased. Windows sends a WM_PAINT message whenever the CWnd update region is not empty and there are no other messages in the application queue for that window. CWnd Overview | Class Members | Hierarchy Chart See Also CWnd::BeginPaint, CWnd::ValidateRect, CWnd::ValidateRgn,::InvalidateRect CWnd::UpdateWindow void UpdateWindow( ); Remarks Updates the client area by sending aWM_PAINT message if the update region is not empty. The UpdateWindow member function sends a WM_PAINT message directly, bypassing the application queue. If the update region is empty, WM_PAINT is not sent. CWnd Overview | Class Members | Hierarchy Chart See Also ::UpdateWindow, CWnd::RedrawWindow

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧