In order to explain the code generated by the ActiveX wizard, we first have to have an example control to examine. In the following sections...
In order to explain the code generated by the ActiveX wizard, we first have to have an example control to examine. In the following sections, I'll use TButton as a simple example. Applying the above steps for creating an ActiveX control to the TButton control yields the following steps:
1. Make sure TButton is installed on the palette. This is easy since it's the way Delphi comes installed.
2. Choose File|New, select the ActiveX page and choose ActiveX Control. Press OK. In the wizard dialog, choose TButton as the VCL class name. The wizard automatically fills in the ActiveX name as ButtonX, the implementation unit as ButtonImpl1.pas, and the project name as ButtonXControl.dpr. The control options are all unchecked. Accept these defaults and press the OK button.
3. The wizard informs you that since the current project is not an ActiveX project, it needs to create a new project. Answer OK. Now the wizard generates all the code for your project and control.
4. Build the project. There is now a file called "ButtonXControl.ocx" on your machine.
5. Register the control in the system, using the Run|Register ActiveX Server command. If successful, Delphi pops up a message saying "Successfully registered ActiveX server, 'c:\delphi3\ButtonXControl.ocx.'"
1. Make sure TButton is installed on the palette. This is easy since it's the way Delphi comes installed.
2. Choose File|New, select the ActiveX page and choose ActiveX Control. Press OK. In the wizard dialog, choose TButton as the VCL class name. The wizard automatically fills in the ActiveX name as ButtonX, the implementation unit as ButtonImpl1.pas, and the project name as ButtonXControl.dpr. The control options are all unchecked. Accept these defaults and press the OK button.
3. The wizard informs you that since the current project is not an ActiveX project, it needs to create a new project. Answer OK. Now the wizard generates all the code for your project and control.
4. Build the project. There is now a file called "ButtonXControl.ocx" on your machine.
5. Register the control in the system, using the Run|Register ActiveX Server command. If successful, Delphi pops up a message saying "Successfully registered ActiveX server, 'c:\delphi3\ButtonXControl.ocx.'"