Solved

Entering and recognizing edit box data

Posted on 2006-06-17
6
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

635 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