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
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

616 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