Solved

Entering and recognizing edit box data

Posted on 2006-06-17
6
172 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now