Bridges > COM Export Bridge > Examples > Tri-Window COM Export Example

# Tri-Window COM Export Example

The `examples/doc/bridges` directory includes three object definition files that inherit from the three types of drawable objects: IDLgrWindow, IDLitDirectWindow and IDLitWindow. The following example uses the Export Bridge Assistant to create ActiveX controls from these object definition files and then creates a Windows application in Visual Basic .NET that includes the three controls.

## Example Code

The object definition files, `idlgrwindowexample__define.pro`, `idlitdirectwindowexample__define.pro`, and `idlitwindowexample__define.pro` are located in the

`examples/doc/bridges` subdirectory of the IDL distribution.

Open the Export Bridge Assistant by entering IDLEXBR_ASSISTANT at the IDL command line and then complete the following steps to export the three drawable objects.

Note: Export Bridge Assistant details are available in Specifying Information for Exporting. Refer to that section if you need more information about the following items.

### Wrap the IDLitDirectWindow Example

The object defined in `idlitdirectwindowexample__define.pro` inherits from IDLitDirectWindow and creates a drawing canvas that you can write on using your mouse.

1. Select File > New Project > COM, browse to select `idlitdirectwindowexample__define.pro` from the `examples/doc/bridges` directory, and click Open.
2. Set export object characteristics as described in the following table. When you select the tree view item, listed in the left column, configure the related properties as noted in the right column.

Tree View Item | Property Configuration
--- | ---
IDL Export Bridge Project | Accept the default value or make changes as desired: Output classname Process name Output directory
idlitdirectwindowexample | Drawable object equals True
WINDOW_INDEX property | You do not need to export the WINDOW_INDEX property as the control will always know it’s own index number. You can leave all fields unchanged.
MAKECURRENT method | Export — False. This is only used within methods in the IDL source object definition file.

3. Save the project by selecting File > Save project. Accept the default name and location or make changes as desired.
4. Verify that the object elements you want to export are listed in the Export log panel. If the expected items are not present, one or more items may still have an UNSPECIFIED field value that must be changed.
5. Build the export object by selecting Build > Build object. The Build log panel shows the results of the build process. For a drawable object, `.tlb` and `.ocx` files (named based on the object name) are created in the Output directory.

### Wrap the IDLgrWindow Example

The object defined in `idlgrwindowexample__define.pro` inherits from IDLgrWindow and displays a globe that can be rotated using your mouse.

1. Select File > New Project > COM, browse to select `idlgrwindowexample__define.pro` from the `examples/doc/bridges` directory, and click Open.
2. Set export object characteristics as described in the following table. When you select the tree view item, listed in the left column, configure the related properties as noted in the right column.

Tree View Item | Property Configuration
--- | ---
IDL Export Bridge Project | Accept the default value or make changes as desired: Output classname Process name Output directory
idlgrwindowexample | Drawable object equals True
CREATEOBJECTS method | Export — False. This method is not called from the COM client.

3. Save the project by selecting File > Save project. Accept the default name and location or make changes as desired.
4. Verify that the object elements you want to export are listed in the Export log panel. If the expected items are not present, one or more items may still have an UNSPECIFIED field value that must be changed.
5. Build the export object by selecting Build > Build object. The Build log panel shows the results of the build process. For a drawable object, `.tlb` and `.ocx` files (named based on the object name) are created in the Output directory.

### Wrap the IDLitWindow Example

The object defined in idlitwindowexample__define.pro inherits from IDLitWindow and displays a surface in a view in which you can pan and zoom.

1. Select File > New Project > COM, browse to select `idlitwindowexample__define.pro` from the `examples/doc/bridges` directory, and click Open.
2. There are no export object characteristics that must be modified, but you can make changes to the default items as described in the following table. When you select the tree view item, listed in the left column, configure the related properties as noted in the right column.

Tree View Item | Property Configuration
--- | ---
IDL Export Bridge Project | Accept the default value or make changes as desired: Output classname Process name Output directory
idlitwindowexample | Drawable object equals True

3. Save the project by selecting File > Save project. Accept the default name and location or make changes as desired.
4. Build the export object by selecting Build > Build object. The Build log panel shows the results of the build process. For a drawable object, `.tlb` and `.ocx` files (named based on the object name) are created in the Output directory.

### Register the Controls and Create the Application

1. Register the `.ocx` files generated by the Export Bridge Assistant using `regsvr32` (see COM Registration Requirements for details if needed). If you kept the default names, you will need to register `idlgrwindowexample.ocx`, `idlitdirectwindowexample.ocx`, and `idlitwindowexample.ocx`.
2. Create a new Visual Basic .NET Windows Application and add the `idlgrwindowexample Class`, `idlitdirectwindowexample Class`, and `idlitwindowexample Class` files to the toolbox. Select View > Toolbox and select the desired tab. Right-click and select Add/Remove Items. Select the COM Components tab, place a checkmark next to the class files, and click OK.
3. Add the three controls IDL to your form in the order of `idlgrwindowexample Class`, `idlitdirectwindowexample Class` and `idlitwindowexample Class` from left to right.

4. Replace the default module code with the text in the file referenced below. See code comments for details.

Note: The text file for this example, `com_export_triwindow_doc.txt`, is located in the `examples/doc/bridges/COM` subdirectory of the IDL distribution. This Visual Basic .NET code can be copied from the text file and adopted for use in your COM environment.

When you build and run the example, the output will appear similar to the following figure.

Left-click and drag in the IDLgrWindow control to rotate the globe and follow the instructions in the IDLitDirectWindow control to draw in the window. In the IDLitWindow, left-click on the surface and drag the mouse cursor to reposition the object, or left-click on one of the view handles and drag up or down to zoom in or out. The bottom label text will change when you move your mouse into or out of the IDLgrWindow- or IDLitDirectWindow-based controls as the label is updated with the NotifyBridge output from the IDL object definition