To Use A Global Variable
Add it to our ap-main.h file – this is automatically included in all files (see creating a project if this file is not in your project)
You can’t make strings global – only normal variable types
However you can just pass a handle to a string or come other object so the form can read/write it.
To Pass Parameters Or Handles To A Form When Its Opened
In the form constructor change the (void) to be whatever you wannt to pass just like any other function and then in the
frmMyForm ^TheForm = gcnew frmMyForm(MyVariableName);
Or, you can add propereties to the form class code that allow you to give information or get information back:-
public:
property String ^PassedValue1;
To Allow A Main Form To Send Information To An Open Sub Form
Instead of the typical way to open a form
frmConfiguration ^ConfigForm = gcnew frmConfiguration ();
Do this to create the form as a normal object
In the declaraion area of main form define the object:
private:
frmConfiguration ^ConfigForm;
In the mains forms constructor create the object as global to the form:
//Create sub form objects ready for use
ConfigForm = gcnew frmConfiguration();
Then in the sub form declarations area create variables you want to be able to write to:
public:
unsigned char DibbaReaderIdentifyReceived;
Then when you want to open the sub form:
ConfigForm->ShowDialog();
Now in the main form you can write to these variables and the sub form can get the values while its running.