954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to read the contents of a textbox into a std::string

hello every one
i am making a program what requires that the user types in some text in a textbox.
the problem is, how do i get that text from the textbox into the std::string (or a other kind of string)?
i don't know how to do that in Win32, which i am using.

i had already tried to use the GetDlgItemText() function (and similar functions), but i don't know how to use that function, because i am not that good at C++. i don't know where and how to use that function.


i am using Microsoft Visual Studio 2010,
i am not using a windows form.

kirenemook12
Newbie Poster
8 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

Hi, you have to use visual studio?

Because I'm using wxDev-C++, and in this plataform is easy to do what you want, since this is a "delphi" based plataform, making the user interface cool and easy handling.

If you can use wxDev-C++ I could help you.

Bye

jshoot
Junior Poster in Training
52 posts since Jan 2011
Reputation Points: 9
Solved Threads: 0
 

I haven't done much of Win32 Programming. But am a bit familiar with it.
I assume that the text member-variable in the TextBox element stores the text.

System::Sting val=text_box->text;


Now val holds the value of the textbox, but not in the std::string but instead, System::String.

Now to convert this into the std::string, you could use something known as a Marshal,which can be a bit more complicated.

Sky Diploma
Practically a Posting Shark
865 posts since Mar 2008
Reputation Points: 673
Solved Threads: 131
 

but what if i got more than one textbox?
or is text_box the handle to the textbox window?

kirenemook12
Newbie Poster
8 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: