many controls 
Author Message
 many controls

 Is it possible to create an array of controls in Visual C++, as can
be done in Visual Basic? Suppose I have 24 text boxes for numeric
input and I want their values to be put into an array, Value[x], is
there any way to put the values in in a loop, rather than one by one?

--
john



Wed, 14 Sep 2005 18:01:25 GMT  
 many controls

Quote:

>  Is it possible to create an array of controls in visual c++, as can
> be done in visual basic? Suppose I have 24 text boxes for numeric
> input and I want their values to be put into an array, Value[x], is
> there any way to put the values in in a loop, rather than one by one?

> --
> john

Sure!  Here is an array of controls (in class declaration in h file):

CEdit m_edits[24];

If the controls are created automatically from a dialog template, make
sure they have sequential ID's (in resource.h) and then connect them to
the CEdit's like this in DoDataExchange:

for (int r = 0; r < 24; r++)
{  DDX_Control(pDX, IDC_EDIT_FIRST + r,  m_edits[r]);
   m_edits[r].SetWindowText(Value[r]);

Quote:
}

To receive notification messages from the controls use ON_CONTROL_RANGE
in your message map.

--
Scott McPhillips [VC++ MVP]



Wed, 14 Sep 2005 19:02:49 GMT  
 many controls
On Sat, 29 Mar 2003 13:02:49 -0500, Scott McPhillips

Quote:


>>  Is it possible to create an array of controls in visual c++, as can
>> be done in visual basic? Suppose I have 24 text boxes for numeric
>> input and I want their values to be put into an array, Value[x], is
>> there any way to put the values in in a loop, rather than one by one?

>> --
>> john

>Sure!  Here is an array of controls (in class declaration in h file):

>CEdit m_edits[24];

>If the controls are created automatically from a dialog template, make
>sure they have sequential ID's (in resource.h) and then connect them to
>the CEdit's like this in DoDataExchange:

>for (int r = 0; r < 24; r++)
>{  DDX_Control(pDX, IDC_EDIT_FIRST + r,  m_edits[r]);
>   m_edits[r].SetWindowText(Value[r]);
>}

>To receive notification messages from the controls use ON_CONTROL_RANGE
>in your message map.

Thanks, Scott. That did make a control array, and I can change the
text boxes ok, but it creates a problem for doing any further work on
the dialog box- the control wizard refuses to work on it, saying it
got a parsing error because it expected a semicolon after the
declaration in the control file, before the left brace:
CEdit m_edits[24];
Is there any way around this?

--
john



Thu, 15 Sep 2005 01:12:52 GMT  
 many controls

Quote:

> Thanks, Scott. That did make a control array, and I can change the
> text boxes ok, but it creates a problem for doing any further work on
> the dialog box- the control wizard refuses to work on it, saying it
> got a parsing error because it expected a semicolon after the
> declaration in the control file, before the left brace:
> CEdit m_edits[24];
> Is there any way around this?

> --
> john

Sounds like you put something between the wizard's marks.  Do not
manually put things or change things between them - they are the only
parts the wizard looks at and parses.

//{{
...do not change in here
//}}

Just stick your manual additions before or after such zones.

--
Scott McPhillips [VC++ MVP]



Thu, 15 Sep 2005 04:10:24 GMT  
 many controls
On Sat, 29 Mar 2003 22:10:24 -0500, Scott McPhillips

Quote:


>> Thanks, Scott. That did make a control array, and I can change the
>> text boxes ok, but it creates a problem for doing any further work on
>> the dialog box- the control wizard refuses to work on it, saying it
>> got a parsing error because it expected a semicolon after the
>> declaration in the control file, before the left brace:
>> CEdit m_edits[24];
>> Is there any way around this?

>> --
>> john

>Sounds like you put something between the wizard's marks.  Do not
>manually put things or change things between them - they are the only
>parts the wizard looks at and parses.

>//{{
>...do not change in here
>//}}

>Just stick your manual additions before or after such zones.

You're right. Thanks a lot. :)
--
john


Thu, 15 Sep 2005 05:00:22 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Control webbrowser ActiveX control in composit ActiveX control

2. Using Rich Edit Control or ip address control in a composite control

3. WebBrowser Control/Explorer Control/HTML Control

4. Accessing control array controls using the controls collection

5. Web Browser Control/Explorer Control/HTML Control

6. Edit Control...Edit Control...Edit Control...Edit Control...Edit Control...

7. Using controls in a DataGrid control

8. Source-Code Control / Document Control...

9. C# Focus Issues - Touch Screen - User Controls - Button Control - TextBox

10. Problem removing a control from the controls collection

11. Basics of Tree Control and Tree view control

12. Controls Created Under Common Control Manifest

 

 
Powered by phpBB® Forum Software