Development tools:
1. Visual Studio 2005 for ActiveX component development
2. Microsoft ActiveX control pad is used to generate HTML webpages containing ActiveX control.
Steps:
1. Create an MFC ActiveX Control Project Using Visual Studio 2005. After compilation, find a file XXXX. ocx in the debug/release directory. For detailed steps, refer to msdn.
2. Select File> new HTML in ActiveX control pad to create an HTML page.
3. select edit-> insert ActiveX Control... from the ActiveX control pad menu, and a message box will pop up. Select ActiveX control from the list of message boxes and click OK to insert ActiveX control to the HTML page.
4. Open the generated HTML in the local IE browser to see ActiveX Control displayed on the HTML page.
If you place a webpage on the HTTP server, you need to complete some additional steps to allow other computers to access the webpage through IE and make ActiveX components run properly.
The HTML generated by ActiveX control pad looks like the following script:
<HTML>
<Head>
<Title> new page </title>
</Head>
<Body>
<Object ID = "activexcontroltest11" width = 100 Height = 51
Classid = "CLSID: 96908503-3beb-4e2b-aa87-f44dc1_bc0e">
<Param name = "_ version" value = "65536">
<Param name = "_ extentx" value = "2646">
<Param name = "_ extenty" value = "1323">
<Param name = "_ stockprops" value = "0">
</Object>
</Body>
</Html>
Each ActiveX control has a corresponding CLSID, which is unique. You can use the classid attribute of an object to specify the ActiveX contorl ID to find the corresponding ActiveX control. Each ActiveX control must be registered before use. The preceding example runs properly because vs2005 automatically registers ActiveX control when compiling the ActiveX project. ActiveX contorl registration and anti-registration can also be completed through the utility regsvr32.
For example, if codebase attribute is added to the object in HTML, ie can automatically register ActiveX control. The modified HTML Script is as follows:
<HTML>
<Head>
<Title> new page </title>
</Head>
<Body>
<Object ID = "activexcontroltest11" width = 100 Height = 51
Classid = "CLSID: 96908503-3beb-4e2b-aa87-f44dc1_bc0e"
Codebase = "release/activexcontroltest1.ocx">
<Param name = "_ version" value = "65536">
<Param name = "_ extentx" value = "2646">
<Param name = "_ extenty" value = "1323">
<Param name = "_ stockprops" value = "0">
</Object>
</Body>
</Html>
Related links:
Microsoft ActiveX control pad
Http://msdn2.microsoft.com/en-us/library/ms968493.aspx