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:-

	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:

		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:

		unsigned char DibbaReaderIdentifyReceived;

Then when you want to open the sub form:


Now in the main form you can write to these variables and the sub form can get the values while its running.

We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.