MFC基本帮助。 [英] MFC basic help.

查看:66
本文介绍了MFC基本帮助。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我是MFC&我希望得到一些基本控件的帮助。


我想将静态文本设置为与我的编辑控件相同。


我有OnEnUpdateEdit1(),但我不确定要放入什么代码。

解决方案

假设你正在使用对话框(即CDialog / CDialogEx)并使用资源编辑器向对话框添加了编辑控件和静态控件。


首先,您可以使用类向导" ;添加变量"为对话框类中的两个控件创建CEdit和CStatic成员变量。 我们假设它们被称为m_Edit和m_Stat。 使用类向导定义控件成员
变量也将确保它们正确连接到对话框中的Windows控件。


然后,在您的OnEnUpdateEdit1处理程序中,您可以包含 -

 CString strEdit; 
m_Edit.GetWindowText(strEdit);
m_Stat.SetWindowText(strEdit);


这将检索编辑控件的文本并使用它来设置静态控件的文本。


Okay so i'm new to MFC & I want to get some help with a basic control.

I want to set a static text to be the same as my edit control.

I have OnEnUpdateEdit1() but i'm not sure what code to put inside.

解决方案

Assuming that you are working with a dialog box (i.e., CDialog/CDialogEx) and have added an edit control and a static control to the dialog with the resource editor.

First, you can use Class Wizard "Add Variable" to create CEdit and a CStatic member variables for the two controls in the dialog class.  Let's assume that they are called m_Edit and m_Stat.  Using Class Wizard to define the control member variables will also make sure that they are properly connected to the Windows controls in the dialog.

Then, in your OnEnUpdateEdit1 handler you can include -

CString strEdit;
m_Edit.GetWindowText(strEdit);
m_Stat.SetWindowText(strEdit);

This will retrieve the text of the edit control and use it to set the text of the static control.


这篇关于MFC基本帮助。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆