单击按钮时显示文本框值 [英] Displaying textbox value on button click

查看:66
本文介绍了单击按钮时显示文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有1个文本框& 1个按钮(这不是默认的确定"按钮).在View :: OnDraw()方法中显示我的对话框.现在,我想在单击按钮时在消息框中显示我的文本框值.为此,我尝试了此操作-

Hi,
I have 1 textbox & 1 button (it''s not a default OK button). Am showing my dialog in View::OnDraw() method. Now I want to display my textbox value in the messagebox on button click. For this purpose, I tried this-

myappview::OnDraw()
{
  dlg d;
  d.DoModal();
}
//on button click of dialogbox my code is-
dlg::OnBtn_Click()
{
 CDialog::OnOk();
 Messagebox(m_text);  //m_text is variable of textbox
}


通过使用上面的代码,我在messagebox中获取了textbox的值,但是它退出了我不想要的对话框.
如果我将代码编写为:


By using above code, am getting the value of textbox in messagebox, but it exits the dialog box, which i don''t want.
if i write the code as:

dlg::OnBtn_Click()
{
 //CDialog::OnOk();
 Messagebox(m_text);  //m_text is variable of textbox
}


那么对话框将保持原样,但无法从文本框中获取价值.这段代码显示了一个空的消息框.
我想显示文本框值,而不退出对话框.
请帮帮我.

谢谢.


then dialogbox remains as it is, but not able to get value from textbox. this code shows me an empty messagebox.
I want to display textbox value, without exiting the dialogbox.
Please help me.

Thanks.

推荐答案

如果m_text是附加到文本框的DDX_Text,则像这样在OnBtn_Click()中调用UpdateData(TRUE),
Hi if m_text is the DDX_Text attached to text box then call UpdateData(TRUE) in OnBtn_Click() like this,
dlg::OnBtn_Click()
{
 //CDialog::OnOk();
 UpdateData(TRUE);
 Messagebox(m_text);  //m_text is variable of textbox
}


这篇关于单击按钮时显示文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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