C++ Edit Box in Windows

How do I get the contents of an Edit Box? VC++ 6.0

Page 1 of 1

2 Replies - 7819 Views - Last Post: 25 October 2008 - 06:57 PM Rate Topic: -----

#1 Tiron  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 26
  • Joined: 03-October 08

C++ Edit Box in Windows

Post icon  Posted 20 October 2008 - 08:11 PM

I am using C++ 6.0 and have looked all over for how to get the contents of an edit box.
It seems like it should be a very simple thing, but i cant find anything on it...
Found all kinds of stuff on buttons, listboxes, and how to change static text...
Is This A Good Question/Topic? 1

#5 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4421
  • View blog
  • Posts: 12,286
  • Joined: 18-April 07

Re: C++ Edit Box in Windows

Posted 20 October 2008 - 10:57 PM

1) Create the editbox on your project
2) Right click it and choose "classWizard"
3) Go to the "Member variables" tab
4) Select the ID of your edit box. It will look like IDC_EDIT1
5) Click the "add variable" button
6) Provide a variable name, leave it as "Value" for the category, and variable type of "CString". Then click ok. Now you have created a variable for your form that represents the editbox.
7) Create a button and double click it to create an event. In the example below we created a button and left it as OnButton1 click
8) Manipulate the box by manipulating the variable. The trick will be to use UpdateData(true) to read from the controls and UpdateData(false) to write to the controls.

// On Button1 click event
void CTest2Dlg::OnButton1() 
{
	// We set our editbox control to "Hello" by manipulating m_EditTextBox
	// That is the variable we attached to the edit box using classWizard
	m_EditTextBox = "Hello";

	// Update the control on the form
	UpdateData(false);	
}



Hopefully these steps are pretty straight forward for you. I am not sure why you are using VC++ 6 when the .NET Framework is much sleeker and easier to use. I must admit that VC++ 6 was a complete mess in my opinion. You are going to have problems finding documentation on it, the compiler is pretty old now (At least 7 years ago when it was last used heavily... Pre .NET)

But do whatever you like with this info. Enjoy!

"At DIC we be VC++ 6.0 coding ninjas... ok we don't use VC++ 6.0, I lied." :snap:
Was This Post Helpful? 1

#6 Tiron  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 26
  • Joined: 03-October 08

Re: C++ Edit Box in Windows

Posted 25 October 2008 - 06:57 PM

I Know how to assign a variable to the box... But i want to put the value in a Message Box..
How Would i Do That with my m_EditBox member?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1