Solved

Entering and recognizing edit box data

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
method notes when mouse over in eclipse 5 68
lucky13 challenge 11 112
Use of condition with 'serial' in ansible 2 36
Change to event 1 74
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 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

19 Experts available now in Live!

Get 1:1 Help Now