Visual c++ : how to create dinamic number of edit boxes
I've created a simple dialog box program in standard Visual c++ (2005 not .net)
the first Dialog ask : How many Edit Boxes do you want to create ?
the user inserts a number, and in the next dialog the user will have the edit boxes.
So how can i create a random number of Edit Boxes and how can i associate the ID to work with the code ?
Does anyone have an example to create a random number of Edit Boxes, and how can i associate their own random ID ??
Re: Visual c++ : how to create dinamic number of edit boxes
This sounds similar to what my friend needed to create a dynamic menu that can change during run-time.
He used what he called pure virtual functions.
Unfortunately, I'm still just learning, so I don't have the experience to give you an example, or describe it in any greater detail, but I hope this points you in the right direction.
Re: Visual c++ : how to create dinamic number of edit boxes
Are you interested in retrieving the text data from each edit box, or will displaying the edit boxes be enough for your needs?
Re: Visual c++ : how to create dinamic number of edit boxes
Try:
Code:
#define MAX_ED 100
HWND hwnd_ed[MAX_ED];
int x, y, w, h;
x = 10; y = 10; w = 80; h = 20;
for (i_ed = 0; i_ed < nb_ed && i_ed < MAX_ED; i_ed++) {
hwnd_ed[i_ed] = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "",
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_LEFT,
x, y, w, h,
hwnd, (HMENU)(1000 + i_ed),
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
y += h +2;
}
Re: Visual c++ : how to create dinamic number of edit boxes
Yes, i need to retrieve the text data from each edit box...so i'm wondering what is a solution to do this...( can i use an array to store all the values from each edit box ?? )
1. ask how many edit boxes
2. the user insert the number
3. the new window display the exact number of edit boxes
4. the user insert values in the edit boxes
5. the software retrieves all the values and ..go on...
Re: Visual c++ : how to create dinamic number of edit boxes
Last question...
How many of these edit boxes would you like to display?
Re: Visual c++ : how to create dinamic number of edit boxes
I do not think it is an important data, but i think up to 30...it depends on user insert...
Theese will be small edit boxes that must contain only up to six digits
Re: Visual c++ : how to create dinamic number of edit boxes
Why not make a dialog template with all the edits you will ever need. Then programmatically remove the WS_VISIBLE style off from the ones you don't want to see.
1 Attachment(s)
Re: Visual c++ : how to create dinamic number of edit boxes
What I would do is use a virtual List control to display a two column view of a label (in the 1st column) and the data (in the 2nd column).
When the user double clicks on the 2nd column an edit box appears in the selected row of the 2nd column.
The data for each row would be stored in an STL collection which the virtual list control gets bound to.
See the following link for the LVEdit2005.zip attachment for the sample code that does what I described.
http://www.codeguru.com/forum/showthread.php?t=440228
Sample in row edit mode...