Multiple instances of edit control needed
Hello to all. This is a simple question. I'm creating a dialog box in MFC. I need 6 different edit control in the dialog, one of which needs validation. The validation is the same for all: the provided input must be a positive number between 0 and 20. Which one you think is best practice:
a) 6 instances of the edit control class dynamic created and attached to the dialog?
b) drag 6 edit controls from the toolbox?
c) May be something else?
In the case of a) how can achieve that? Is a good idea to create an array of edit controls?
Thanks in advance.
[583 byte] By [
jxpc] at [2007-11-20 7:38:44]

# 1 Re: Multiple instances of edit control needed
I would just drag&drop 6 controls, then use DDX to map them to an array of variables (one elemment for each control) for later processing...
The other part of your post is a little confusing:
I need 6 different edit control in the dialog, one of which needs validation.
The validation is the same for all:
Does only one need validation? Or do they all?
# 2 Re: Multiple instances of edit control needed
I would just drag&drop 6 controls, then use DDX to map them to an array of variables (one elemment for each control) for later processing...
The other part of your post is a little confusing:
Does only one need validation? Or do they all?
All they need validation: the value that typed by the user must be between 0 and 20. That holds true for all 6 controls.
jxpc at 2007-11-10 22:58:58 >

# 3 Re: Multiple instances of edit control needed
In that case I would derive a new class from CEdit, encapsulate the logic inside the class...
[This is just a general observation, exact details of your requirements may influence the decision].