Solved

Entering and recognizing edit box data

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

749 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