Discussion:
Problem finding out how to code a connection between text box & bu
(too old to reply)
keith
2010-03-28 00:35:01 UTC
Permalink
Hello

I have a VC++ Express program with a form that has a text box and a button

When the button is clicked, I want to take the text box information and do
something with it. But what coding steps are necessary to get the data out
of the text box when the button has an onclick event? I’ve looked in the
documentation, read my VC++ book, and either I’m missing something or these
resources just don’t talk about that. Can anyone offer an idea or point me
in the direction of a solution?

Thank you.

Keith
David Lowndes
2010-03-28 12:57:26 UTC
Permalink
Post by keith
I have a VC++ Express program with a form that has a text box and a button
When the button is clicked, I want to take the text box information and do
something with it. But what coding steps are necessary to get the data out
of the text box when the button has an onclick event?
Keith,

Essentially all you have to do is access the control's text property
in the button click handler.

Dave
keith
2010-03-28 17:22:01 UTC
Permalink
Hi Dave,
Thanks very much. That's what is puzzling me. Where can I take a look at
some sample code that does that?
keith
Post by David Lowndes
Post by keith
I have a VC++ Express program with a form that has a text box and a button
When the button is clicked, I want to take the text box information and do
something with it. But what coding steps are necessary to get the data out
of the text box when the button has an onclick event?
Keith,
Essentially all you have to do is access the control's text property
in the button click handler.
Dave
.
David Lowndes
2010-03-28 18:11:13 UTC
Permalink
Post by keith
Thanks very much. That's what is puzzling me. Where can I take a look at
some sample code that does that?
Almost anywhere I'd have thought.

What type of project are you working on?

I'd assume that since you mention it's the Express edition and you say
"form" that it's a Windows forms project, in which case it's usually
just something like this:

private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
String ^ str = textBox1->Text;
...
}

Dave
keith
2010-03-29 01:31:01 UTC
Permalink
Hi Dave,
thanks very much i inserted that text and it compiled without errors... now
I have to figure out where to go from there. I'm discovering for the second
time that I have much to learn about c++
Keith
Post by David Lowndes
Post by keith
Thanks very much. That's what is puzzling me. Where can I take a look at
some sample code that does that?
Almost anywhere I'd have thought.
What type of project are you working on?
I'd assume that since you mention it's the Express edition and you say
"form" that it's a Windows forms project, in which case it's usually
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
String ^ str = textBox1->Text;
...
}
Dave
.
Ulrich Eckhardt
2010-03-29 08:41:14 UTC
Permalink
I'm discovering for the second time that I have much to learn about c++
[...]
Post by David Lowndes
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
String ^ str = textBox1->Text;
...
}
This actually is not plain C++, but an MS dialect thereof. Also, this is not
just about using that language but also about using the APIs that some
libraries provide.

Uli
--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
Tim Roberts
2010-03-28 23:39:17 UTC
Permalink
Post by keith
I have a VC++ Express program with a form that has a text box and a button
When the button is clicked, I want to take the text box information and do
something with it. But what coding steps are necessary to get the data out
of the text box when the button has an onclick event? I’ve looked in the
documentation, read my VC++ book, and either I’m missing something or these
resources just don’t talk about that. Can anyone offer an idea or point me
in the direction of a solution?
At the very lowest level, this is done by sending a WM_GETTEXT message to
the edit control. However, there are lots of wrappers for this. At the
raw API leve, there's GetDlgItemText. In ATL and MFC, there are wrappers
that return the contents in a CString.

So, as always, "it depends".
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
keith
2010-03-29 01:31:02 UTC
Permalink
Hi Tim,
thanks very much. That is helpful information. As i said in my note to
Dave, I am discovering how much I have to learn about c++. It has so much
great potential.
Keith
Post by Tim Roberts
Post by keith
I have a VC++ Express program with a form that has a text box and a button
When the button is clicked, I want to take the text box information and do
something with it. But what coding steps are necessary to get the data out
of the text box when the button has an onclick event? I’ve looked in the
documentation, read my VC++ book, and either I’m missing something or these
resources just don’t talk about that. Can anyone offer an idea or point me
in the direction of a solution?
At the very lowest level, this is done by sending a WM_GETTEXT message to
the edit control. However, there are lots of wrappers for this. At the
raw API leve, there's GetDlgItemText. In ATL and MFC, there are wrappers
that return the contents in a CString.
So, as always, "it depends".
--
Providenza & Boekelheide, Inc.
.
Loading...