Click here to Skip to main content
15,893,814 members
Articles / Desktop Programming / ATL

An ATL Component in C++ that fires COM events

Rate me:
Please Sign up or sign in to vote.
4.19/5 (12 votes)
14 Jun 20048 min read 88.4K   3K   38  
A COM component that implements interprocess communication, and illustrates firing events to a COM container such as Visual Basic
// InterProcessComms.idl : IDL source for InterProcessComms
//

// This file will be processed by the MIDL tool to
// produce the type library (InterProcessComms.tlb) and marshalling code.

#include "olectl.h"
import "oaidl.idl";
import "ocidl.idl";

[
	object,
	uuid(1EA7D7FD-5BC5-46D4-819D-BD520E2A1D0E),
	dual,
	nonextensible,
	helpstring("IIPC Interface"),
	pointer_default(unique)
]
interface IIPC : IDispatch{
	[propget, id(1), helpstring("property msghWnd - the hWnd of the hidden msg window")] 
	  HRESULT msghWnd([out, retval] LONG* pVal);

	[id(2), helpstring("method SendData")]
	  HRESULT SendData([in] LONG lData, [in] BSTR sData, [in, optional, defaultvalue(0)] LONG hWnd);	 
};

[
	uuid(22845CAA-F3B2-4F85-B8EF-CAEAA7EBF796),
	version(1.0),
	helpstring("NBDs InterProcessComms 1.0 Type Library")
]
library InterProcessCommsLib
{
	importlib("stdole2.tlb");
	[
		uuid(B11D3BF6-07E2-432E-95FF-BC46E525C04B),
		helpstring("_IIPCEvents Interface")
	]
	dispinterface _IIPCEvents
	{
		properties:
		methods:
		[id(1), helpstring("method MessageReceived Event")] void MessageReceived([in] LONG lData, [in] BSTR sMsg, [in] LONG lLenght);
	};
	[
		uuid(4B0C2DEB-1C04-4BB8-80A4-B7C2CA85BC8E),
		helpstring("IPC Class")
	]
	coclass IPC
	{
		[default] interface IIPC;
		[default, source] dispinterface _IIPCEvents;
	};
};

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 Kingdom United Kingdom
I am a Surgeon by trade, but have been programming since I could reach the keyboard! I run a surgical website and am MD of a company that writes Surgical Software.

Comments and Discussions