Click here to Skip to main content
15,886,030 members
Articles / Programming Languages / C++

A Complete ActiveX Web Control Tutorial

Rate me:
Please Sign up or sign in to vote.
4.92/5 (125 votes)
21 Jun 200617 min read 2M   20.8K   423  
This article is intended to help you get up to speed quickly with developing an ActiveX control. It will show you the basic concepts you need to know about ActiveX, such as methods, properties, and events, and how to communicate between an ActiveX control and a web page.
// MyActiveX.idl : type library source for ActiveX Control project.

// This file will be processed by the MIDL compiler tool to
// produce the type library (MyActiveX.tlb) that will become a resource in
// MyActiveX.ocx.

#include <olectl.h>
#include <idispids.h>

[ uuid(CBE9E0B0-95DB-4495-8BE8-E4CB416EF07D), version(1.0),
  helpfile("MyActiveX.hlp"),
  helpstring("MyActiveX ActiveX Control module"),
  control ]
library MyActiveXLib
{
	importlib(STDOLE_TLB);

	//  Primary dispatch interface for CMyActiveXCtrl

	[ uuid(98AF8A06-7DFE-472D-A713-A0C6F22FDC3D),
	  helpstring("Dispatch interface for MyActiveX Control")]
	dispinterface _DMyActiveX
	{
		properties:
			[id(1) , helpstring("property InputParameter")] BSTR InputParameter;
			[id(2) , helpstring("property OutputParameter")] BSTR OutputParameter;
	methods:
		[id(3), helpstring("method LoadParameter")] void LoadParameter(void);
	};

	//  Event dispatch interface for CMyActiveXCtrl

	[ uuid(78099343-A8FF-4867-A537-06F31034F22B),
	  helpstring("Event interface for MyActiveX Control") ]
	dispinterface _DMyActiveXEvents
	{
		properties:
			//  Event interface has no properties

		methods:
			[id(1)] void ParameterLoaded(void);
	};

	//  Class information for CMyActiveXCtrl

	[ uuid(36299202-09EF-4ABF-ADB9-47C599DBE778),
	  helpstring("MyActiveX Control"), control ]
	coclass MyActiveX
	{
		[default] dispinterface _DMyActiveX;
		[default, source] dispinterface _DMyActiveXEvents;
	};

};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions