ActiveX controls can provide a number of enhancements to your Windows Foundation Classes (WFC) applications. A number of third-party ActiveX controls are available to add features, such as custom button shapes, telephony technology, charting, graphing, and spreadsheets. You can use Visual J++ to import ActiveX controls using a process similar to importing COM objects.
In this scenario, you import the Microsoft ActiveMovie control that is installed with Microsoft Internet Explorer version 4.0. You will learn:
So that your ActiveX control is available to Visual J++, you must register it in the system registry.
Note In this scenario, you do not need to register the ActiveMovie control because it is registered when Internet Explorer is installed.
To register an ActiveX control
Regsvr32.exe <control path and filename>
where <control path and filename> is the path and file name of your control. For this scenario, type:
Regsvr32 C:\Windows\System\AMOVIE.OCX
If you receive a message that the registration failed, ensure that the path to the control is correct and that the file exists.
When importing an ActiveX control, Visual J++ creates package directories in your project and adds the class wrappers used to access the ActiveX control in those package directories. Therefore, you must have a valid WFC project to import an ActiveX control.
To create a WFC project
A collapsed view of your project appears in Project Explorer. (If Project Explorer is not visible, click Project Explorer on the View menu.)
A file with the default name of Form1.java has been added to your project.
After you have created the project, you can then import the ActiveX control into the project. Use the Customize Toolbox dialog box to select the ActiveX control from a list of ActiveX controls that are installed on your system.
Note Once you have added an ActiveX control to the Toolbox, the control remains in the Toolbox for all other projects until you remove it.
To import an ActiveX control
For this scenario, select ActiveMovieControl Object.
The controls that you selected are added to the Toolbox.
When you add the ActiveX control to a form, Visual J++ creates one or more packages in your project directory and adds class wrappers for the control. The class wrappers are used by Visual J++ to access the classes and members of the ActiveX control. If the ActiveX control you are importing is contained in a file that contains multiple ActiveX controls, Visual J++ will provide class wrappers for all controls in the file but adds only the specified control to the Toolbox.
To add the ActiveX control to a form
For this scenario, double-click the ActiveMovie control. The control is added to the center of the form.
After you have added the ActiveX control to a form, you can use the Properties window to set properties and create event handlers.
To set the properties for the ActiveMovie control
–or–
Click the ellipsis button in the value section of the filename property to display a dialog box to browse for a file on your computer.
After you have added the ActiveX control to a form and set its properties, you build and run the project to test the control's functionality.
To build and run the form
If you receive any compilation errors or messages, correct the errors and rebuild your project.
The movie that you specified in the filename property is displayed.