The features described in this topic are obsolete
and should not be used in new IDL code.
Working with IDL Procedures
In this next example a project is created that uses multiple IDL procedures. Here the same issues apply as when developing a standard IDL program with a graphical user interface. In addition, managing memory when moving from one procedure to another should be considered. It is important to realize that the ActiveX control interacts with IDL at the main level. Thus, a Visual Basic program passing instructions to IDL is identical to entering the same instructions at the IDL command line. In this example Visual Basic is only used to create the user interface and dispatch events. The data resides in memory controlled by IDL. IDL is used for all data processing and display functions.
The following figure shows the user interface of the example project. The project is part of the IDL distribution and resides in the examples\doc\ActiveX\SecondExample directory.
The user interface consists of two IDLDrawWidget objects. The one on the left will display an image read from a JPEG file. The window on the right displays what the image looks like after processing. Buttons allow the user to scale the image and perform Roberts and Sobel filtering operations on the data.
Creating the Interface
The interface is created as it was in the first example, by drawing the interface components in Visual Basic. Two IDLDrawWidgets are created. Set the path (c:\itt\idlxx where xx is the current IDL version) and graphics level properties (type 1) of both.
Initializing IDL
Although there are two IDLDrawWidget objects, only one instance of the ActiveX control needs to be initialized. Both of the IDLDrawWidget objects do need to be created, however.
This is done with the two statements below:
Compiling the IDL Code
This example uses IDL procedures contained in a .pro file named SecondExample.pro. This file contains IDL procedures. Before these procedures can be called from Visual Basic, SecondExample.pro needs to be compiled. This assumes that the .pro file resides in the same directory as the Visual Basic project. The path method of the App object returns the directory from which the Visual Basic application was launched. Pass this directory to IDL with the statements
The .pro can then be compiled. A conditional statement is used to exit the program if IDL was unable to locate the .pro file.
Dispatching Button Events to IDL
Because Visual Basic is used primarily for the user interface components of the application, IDL's procedures have been created for processing the button events in the application. This is accomplished through the ExecuteStr method of the IDLDrawWidget, as called in the following figure; when you click "Open", the OpenFile procedure is defined as below.
OpenFile is a user procedure that utilizes IDL's DIALOG_PICKFILE function to enable the user to select a file for display within the IDLDrawWidget.
Cleaning Up and Exiting
Like the first example, this program exits when the user clicks "Exit". An additional call has been made to DestroyDrawWidget. This isn't necessary when exiting because the windowing system will destroy the widget. If you want to change the GraphicsLevel property of the IDLDrawWidget during program execution use this method.
