Top
PowerCOBOL V11.0 User's Guide
FUJITSU Software

11.7 The OLE Control

The OLE control allows you to execute OLE methods. It applies to controls in the COM class.

This is a special control that allows you to invoke the full power of OLE. The example discussed below concentrates on the OLE "Create-Object" method to create a PowerCOBOL Form at Run-time.

In order to use this, you must create two separate projects. The first project creates a .DLL file containing one or more forms. You must build this project and register the .DLL file to make the forms available to the second project at run-time.

In the second project, you must add the following line of code to each form's REPOSITORY section of the ENVIRONMENT DIVISION:

	Class COM AS "*COM".

In the second project, every form defined needs the following data items declared in the form's WORKING-STORAGE section:

	01 COM-FORM		OBJECT REFERENCE.
	01 COM-FORM-NAME		PIC X(128).

In the first project, where you create a .DLL with one or more forms within it, you need to look at the properties of each form and then look at the OLE tab. The Program-ID field will contain the OLE name you will use in the second project to refer to the form. Remember the OLE name. You may change it to something else if you like. Note that the actual OLE name you will need to remember will be "programid.1". (.1 indicates the version of OLE control.)

For example, if you create an OLE program id name of "Myprog", the actual OLE name you will reference the form by will be Myprog.1.

This is all you need to do to the first project. You can create forms, place controls on them and edit them in the normal way. When you are finished, build the project as a .DLL and register it.

When you are ready to begin creating the second project that will use the first project's form(s), remember to place the above noted declarations in the REPOSITORY and WORKING-STORAGE sections of your main form.

To invoke one of the first project's forms dynamically from the second project, you code (where "form1.1" is the name of the form in the first project you wish to invoke):

	MOVE "form1.1" To COM-FORM-NAME
	INVOKE COM "CREATE-OBJECT" 
	      USING COM-FORM-NAME
	      RETURNING COM-FORM
	INVOKE COM-FORM "DoModal"