How do I create an array of PictureBoxes? 
Author Message
 How do I create an array of PictureBoxes?

This info has been some of the most helpful I've gotten! I would have never
thought, for example, to put brackets BEHIND the function's param
parenthesis when returning an array!  Thanx again!!! =)

  /== Peteroid ==\



Quote:
> This is the managed arrays topic of the FAQ we are working on:

>       What is the correct syntax for Managed C++ arrays as members,
> arguments, and return values of functions?

> To declare an array variable:

>     Byte    myArray[] = new Byte[ 12 ];    // Byte is a value type
>     Byte    myArray[] = { 12, 23, 32 };

>     String*    myArray[] = new String*[12];
>     String*    myArray[] = { S"onut", S"onutaou" };

> To return an array from a function:

>    Byte    Function() [] {
>         return new Byte[12];
>     }

>     String*    Function() [] {
>         return new String*[12];
>     }

> To pass an 'IN' array argument to a function:

>     void Function( Byte theArray[] ) {
>     }

>     void Function( String* theArray[] ) {
>     }

> To pass a 'REF' array argument to a function:

>    typedef Byte ByteArray[];

>     void Function( /*REF*/ ByteArray& theArray  ) {
>         theArray = new Byte[ 123 ];
>     }

>     void Function( Byte (&theArray) [] ) {
>         theArray = new Byte[ 123 ];

>     }

>     // To be CLS compliant (i.e. usable in C# and VB )

>     void Function( Byte (*theArray) [] ) {
>         *theArray = new Byte[ 123 ];
>     }

>     typedef String* StringArray[];
>     void Function( /*REF*/ StringArray& theArray ) {
>     }

>     void Function( String* (&theArray)[] ) {
>     }

>     // To be CLS compliant (i.e. usable in C# and VB )
>     void Function( String*(*theArray) [] ) {
>         *theArray = new String*[ 123 ];
>     }



> > The following code generates an "invalid for __gc array element" error
at
> > build time:

> > __value struct MyControls
> > {
> >    static PictureBox *My_Matrix ;  // on-screen picturebox matrix
(array)
> > };

> > void Create_MyMatrix( long  element_count )
> > {
> >      MyControls::My_Matrix = new PictureBox[ element_count ] ;  // ***
> error
> > occurs at this line ***
> > }

> > I want to create an arbitrary-length array of PictureBox controls. Help!
> :)

> >   /== Peteroid ==\\

> > PS - Do controls automatically do their own clean-up when the form they
> are
> > on is destroyed? Does a form do its own clean-up when it is destroyed?
> > FYI, I'm developing a Managed C++ Application in VC++ .NET.



Fri, 28 Jan 2005 08:52:07 GMT  
 How do I create an array of PictureBoxes?
This is the logical result of the C/C++ declaration syntax (which is
something we are stuck with). Due to C/C++ having abstract declarators
(typically used to declare function pointers), the brackets must go there to
be able to express the difference between a function pointer to a function
that returns an array of type X and an array of function pointers to a
function that returns a type X.

Ronald


Quote:
> This info has been some of the most helpful I've gotten! I would have
never
> thought, for example, to put brackets BEHIND the function's param
> parenthesis when returning an array!  Thanx again!!! =)

>   /== Peteroid ==\



> > This is the managed arrays topic of the FAQ we are working on:

> >       What is the correct syntax for Managed C++ arrays as members,
> > arguments, and return values of functions?

> > To declare an array variable:

> >     Byte    myArray[] = new Byte[ 12 ];    // Byte is a value type
> >     Byte    myArray[] = { 12, 23, 32 };

> >     String*    myArray[] = new String*[12];
> >     String*    myArray[] = { S"onut", S"onutaou" };

> > To return an array from a function:

> >    Byte    Function() [] {
> >         return new Byte[12];
> >     }

> >     String*    Function() [] {
> >         return new String*[12];
> >     }

> > To pass an 'IN' array argument to a function:

> >     void Function( Byte theArray[] ) {
> >     }

> >     void Function( String* theArray[] ) {
> >     }

> > To pass a 'REF' array argument to a function:

> >    typedef Byte ByteArray[];

> >     void Function( /*REF*/ ByteArray& theArray  ) {
> >         theArray = new Byte[ 123 ];
> >     }

> >     void Function( Byte (&theArray) [] ) {
> >         theArray = new Byte[ 123 ];

> >     }

> >     // To be CLS compliant (i.e. usable in C# and VB )

> >     void Function( Byte (*theArray) [] ) {
> >         *theArray = new Byte[ 123 ];
> >     }

> >     typedef String* StringArray[];
> >     void Function( /*REF*/ StringArray& theArray ) {
> >     }

> >     void Function( String* (&theArray)[] ) {
> >     }

> >     // To be CLS compliant (i.e. usable in C# and VB )
> >     void Function( String*(*theArray) [] ) {
> >         *theArray = new String*[ 123 ];
> >     }



> > > The following code generates an "invalid for __gc array element" error
> at
> > > build time:

> > > __value struct MyControls
> > > {
> > >    static PictureBox *My_Matrix ;  // on-screen picturebox matrix
> (array)
> > > };

> > > void Create_MyMatrix( long  element_count )
> > > {
> > >      MyControls::My_Matrix = new PictureBox[ element_count ] ;  // ***
> > error
> > > occurs at this line ***
> > > }

> > > I want to create an arbitrary-length array of PictureBox controls.
Help!
> > :)

> > >   /== Peteroid ==\\

> > > PS - Do controls automatically do their own clean-up when the form
they
> > are
> > > on is destroyed? Does a form do its own clean-up when it is destroyed?
> > > FYI, I'm developing a Managed C++ Application in VC++ .NET.



Fri, 28 Jan 2005 14:19:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How do I create an array of PictureBoxes?

2. Creating New Cards for Picturebox control?

3. Creating a Virtual directory through a program as done by VS.NET IDE

4. doing this without arrays or recursion

5. C array syntax proposal (was: Why are most HPC done)

6. BC 3.1 arrays >64k.... CAN BE DONE

7. doing a loop with an array - Windows is hating my guts this week

8. HOWTO: Synchronize PictureBox with DataGrid

9. Can I drag an image in a PictureBox

10. Quick Info feature on a PictureBox control

11. WMF files in picturebox

12. Bitmap in PictureBox

 

 
Powered by phpBB® Forum Software