Hello!
There are two windows: Form1 (parent), Form2 (child); It is impossible to get access to the variable \ function of the parent window. Here is the code:
//Main: #include "stdafx.h" #include <iostream> using namespace std; #include "Form2.h" #include "Form3.h" #include "Form1.h" using namespace Server_WFA; [STAThreadAttribute] int main(array<System::String ^> ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Form1()); return 0; } //Form1: #pragma once namespace Server_WFA { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for Form1 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: void opener(){} Form1() { InitializeComponent(); opener(); form2 = gcnew Form2(this); } Form2^ form2; .... //Form2: #pragma once #include <iostream> using namespace std; namespace Server_WFA { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::Runtime::InteropServices; /// <summary> /// Summary for Form2 /// </summary> ref class Form1;//Дообьявляем! public ref class Form2 : public System::Windows::Forms::Form { private: Form1^ owner; public: Form2(Form1^ own) { InitializeComponent(); owner = own; this->Owner->Name=L"";//opener(); this->Text=owner->label1->Text; owner->opener(); // ничего не работает!!! }
Some bugs:
error C2027: use of undefined type 'Server_WFA :: Form1'
error C2227: left of '-> opener' must point to class / struct / union / generic type
How to access the opener function? located in form1
?