Solved

Entering and recognizing edit box data

Posted on 2006-06-17
6
173 Views
Last Modified: 2013-11-20
When data is entered into an edit box on a dialog, during program execution, how do I get a variable or parameter to recognize and store that data and make a member variable recognize the new data as the current data residing in the edit box whether the data is characters or integers, and pass on the data in the member variable to other program functions?
0
Comment
Question by:Roderick2006
  • 3
6 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 16926690
Using MFC Class Wizard, you can associate member variable with edit box. If edit box should contain integer data, use int variable. Let's say that this variable is called m_data1 and has int type.
To set data to dialog box control (this is usually done in OnInitDialog function):

m_data1 = n;    // n is some number
UpdateData(FALSE);     // now edit box shows new value

To read data from control to variable (this is usually done in OnOK function):

if ( ! UpdateData(TRUE) )   // if control contains incorrect input, UpdateData shows message and returns FALSE
    return;

// m_data1 has now new value

UpdateData(TRUE) can fail if some of dialog boxes has incorrect data. For example, "abc" string for int variable. You can define also allowed interval for int variable.

If you associalte CString varibale with  edit box. In this case any data is allowed.

Another way to work with dialog controls is using SetWindowText/GetWindowText. In this case data validation is your responsibility.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16926716
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17293842
I think my answer is OK.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 182
Strange date stored 22 123
Smart Camera scanning and reading information 3 106
Use of condition with 'serial' in ansible 2 62
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question