Array of Edit Boxes in VC++ 6

Posted on 2003-04-01
Medium Priority
Last Modified: 2011-09-20

I have a bunch of text boxes in a 4x12 grid that I would like to be able to run a function over.  I'd like to know the easiest way to do this.  I was thinking that I would create an array of doubles (the type I want in the boxes) and then tie them to the boxes using the DDX_Text function.  Then I'd easily be able to loop through them and run a function.  However the Class Wizard doesn't like the declaration of an array in header file.  Is this possible?  What is the easiest approach for processing a grid of edit boxes?


Question by:miko1
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
LVL 48

Accepted Solution

AlexFM earned 100 total points
ID: 8244154
You can add class members for each edit box using Class Wizard:

double m_dEdit1;
double m_dEdit2;

and add array of pointers as class member:

double* m_pArray[N];

Initialize array in OnInitDialog:

m_pArray[0] = &m_dEdit1;
m_pArray[1] = &m_dEdit2;

You can do the same also with CEdit class members:

CEdit m_Edit1;
CEdit m_Edit2;

CEdit* m_pArray[N];

m_pArray[0] = &m_Edit1;
m_pArray[1] = &m_Edit2;

m_pArray maybe also two-dimensional, if this is convenient for you.


// double members
for ( int i = 0; i < n; i++ )
    *(m_pArray[i]) = 0.0;


// CEdit members
for ( int i = 0; i < n; i++ )


Assisted Solution

AnnaNachesa earned 100 total points
ID: 8244736
Create those editboxes dinamically (override OnCreate or do in in OnInitDialog, it does not matter much although you could return false in OnCreate if you get memory problems, so better to do it there) and write the DDX_Text entries yourself (just mimic the way CW does it).It is not prohibited and it is just several extra lines of code. Only do not forget to delete all controls when your class goes out of scope, otherwise you'd get a memory leak.

Alternatively, have you thought about using a DataGrid or how it is called?.. may be it would be better?..
LVL 11

Expert Comment

ID: 9587382
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered: Points split AlexFM and AnnaNachesa

Please leave any comments here within the next seven days. Experts: Silence
means you don't care.


-bcl (bcladd)
EE Cleanup Volunteer


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

764 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