Click here to Skip to main content
14,669,324 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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
}
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100