Click here to Skip to main content
15,884,388 members
Articles / Programming Languages / C++

Understanding COM Event Handling

Rate me:
Please Sign up or sign in to vote.
4.91/5 (96 votes)
9 Dec 2004CPOL19 min read 576.2K   7.4K   219  
Learn the fundamental principles of COM Event Handling via a C++ template class that allows for generic handling of dispinterface COM events.
// EventFiringObject_Impl.cpp : Implementation of CEventFiringObject
#include "stdafx.h"
#include "EventFiringObject.h"
#include "EventFiringObject_Impl.h"

/////////////////////////////////////////////////////////////////////////////
// CEventFiringObject

STDMETHODIMP CEventFiringObject::InterfaceSupportsErrorInfo(REFIID riid)
{
	static const IID* arr[] = 
	{
		&IID_IEventFiringObject
	};
	for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
	{
		if (InlineIsEqualGUID(*arr[i],riid))
			return S_OK;
	}
	return S_FALSE;
}

STDMETHODIMP CEventFiringObject::TestFunction(long lValue)
{
	// TODO: Add your implementation code here
	Fire_Event1(lValue);

	return S_OK;
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems Engineer NEC
Singapore Singapore
Lim Bio Liong is a Specialist at a leading Software House in Singapore.

Bio has been in software development for over 10 years. He specialises in C/C++ programming and Windows software development.

Bio has also done device-driver development and enjoys low-level programming. Bio has recently picked up C# programming and has been researching in this area.

Comments and Discussions