The project has two forms. Form2 is called by pressing a button in Form1 using Form2->ShowDialog(); ( #include <Form2.h> was Form1.h registered in Form1.h ) Question: How can I pass several pointers of type Test ^Name to Form2 ? Test - structure:

 public ref class Form1 : public System::Windows::Forms::Form { public: ref struct Test { System::String ^test1; int test2; }; ... 
  • Put the CLI tag, or whatever it is ... System::String ^ is not C ++. - AnT

2 answers 2

  1. To write on C ++ managed code is a perversion. Better take C #
  2. There are several ways to ensure inter-module communication.
    • Global variable Get all the cons of global objects.
    • Local variable for Form2 class. Initialize through the Form2 constructor.
    • Local variable for Form2 class. Initialize through a separate function. For example, Form2->Init(blablabla) or Form2->setmyinternalvariables(blablablah)
    • Local variable for the Form2 class with public access. Khm Probably not the best way to go.

    Add to the Form2 class a pointer to Test, when creating an object of the Form2 class, initialize this pointer through the constructor or through a getter. Test description is removed from Form1. Next Form2 -> ShowDialog.

    • How to render Test description correctly? If I try to describe structures outside the class, the constructor begins to swear "Either VCProject or VCCodeModel is not ready yet. Please close designer and try again." Restarting does not help. - AlexIke