Thread: Obtaining a value from a text box

  1. #1
    Registered User
    Join Date
    Aug 2005

    Obtaining a value from a text box

    I'm working with MSVC++. I have a GUI with button and a text box. When I push the button the function CDLG::OnButtonPush() gets executed. This in turn calls the function SomeFunction(). The text box on my GUI has a value, say, 12.0 "held" in it. How do I get the function SomeFunction(), or CDLG::OnButtonPush() for that matter, to use the value held in the text box?

    Here is some of my code:

    void CDLG::OnButtonPush() 
    void CDLG::OnEnChangeEdit1()
    	// TODO:  If this is a RICHEDIT control, the control will not
    	// send this notification unless you override the CDialog::OnInitDialog()
    	// function and call CRichEditCtrl().SetEventMask()
    	// with the ENM_CHANGE flag ORed into the mask.
    	// TODO:  Add your control notification handler code here

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Is this MFC or does it only look like it?

    In MFC dialogs, you call UpdateData with the right TRUE/FALSE parameter (can never remember) to synchronize the contents of the box with the member representing it. Then you just use the result.

    In non-MFC, you send a WM_GETTEXT message to the box.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Automatically enter text in a dialog box
    By leojose in forum Windows Programming
    Replies: 6
    Last Post: 12-13-2005, 11:59 AM
  3. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  4. Sending text to an edit box
    By ColdFire in forum Windows Programming
    Replies: 1
    Last Post: 09-24-2002, 07:46 PM
  5. Getting my text from edit box
    By Marky_Mark in forum Windows Programming
    Replies: 2
    Last Post: 11-16-2001, 01:06 PM