Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
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
}

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.
Posted
Updated 14-Apr-11 18:56pm
v2

1 solution

Hi if m_text is the DDX_Text attached to text box then call UpdateData(TRUE) in OnBtn_Click() like this,
C#
dlg::OnBtn_Click()
{
 //CDialog::OnOk();
 UpdateData(TRUE);
 Messagebox(m_text);  //m_text is variable of textbox
}
 
Share this answer
 
v2
Comments
virus131 15-Apr-11 1:44am    
Hey, It's working.........
Very much thanks for your answer........

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900