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.
- Select File → New Project → COM, browse to select
idlitdirectwindowexample__define.profrom theexamples/doc/bridgesdirectory, and click Open. - 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.
- Save the project by selecting File → Save project. Accept the default name and location or make changes as desired.
- 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.
- Build the export object by selecting Build → Build object. The Build log panel shows the results of the build process. For a drawable object, .
tlband .ocxfiles (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.
- Select File → New Project → COM, browse to select
idlgrwindowexample__define.profrom theexamples/doc/bridgesdirectory, and click Open. - 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.
- Save the project by selecting File → Save project. Accept the default name and location or make changes as desired.
- 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.
- Build the export object by selecting Build → Build object. The Build log panel shows the results of the build process. For a drawable object, .
tlband .ocxfiles (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.
- Select File → New Project → COM, browse to select
idlitwindowexample__define.profrom theexamples/doc/bridgesdirectory, and click Open. - 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.
- Save the project by selecting File → Save project. Accept the default name and location or make changes as desired.
- Build the export object by selecting Build → Build object. The Build log panel shows the results of the build process. For a drawable object, .
tlband .ocxfiles (named based on the object name) are created in the Output directory.
Register the Controls and Create the Application
- Register the
.ocxfiles generated by the Export Bridge Assistant usingregsvr32(see COM Registration Requirements for details if needed). If you kept the default names, you will need to registeridlgrwindowexample.ocx,idlitdirectwindowexample.ocx, andidlitwindowexample.ocx. - Create a new Visual Basic .NET Windows Application and add the
idlgrwindowexample Class,idlitdirectwindowexample Class, andidlitwindowexample Classfiles 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. - Add the three controls IDL to your form in the order of
idlgrwindowexample Class,idlitdirectwindowexample Classandidlitwindowexample Classfrom left to right. - Replace the default module code with the text in the file referenced below. See code comments for details.
Example Code
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 files.

