Services useful for ActiveX designers are defined in the Designer.h header file provided by Microsoft. The following code, taken from Designer.h, defines the SCodeNavigate service, which allows an extended object to display the code module attached to it:
// { 6d5140c4-7436-11ce-8034-00aa006009fa }
DEFINE_GUID(IID_ICodeNavigate, 0x6d5140c4, 0x7436, 0x11ce, 0x80, 0x34, 0x00, 0xaa, 0x00, 0x60, 0x09, 0xfa);
#define SID_SCodeNavigate IID_ICodeNavigate
#undef INTERFACE
#define INTERFACE ICodeNavigate
DECLARE_INTERFACE_(ICodeNavigate, IUnknown)
{
BEGIN_INTERFACE
// *** IUnknown methods ***
STDMETHOD(QueryInterface)(THIS_ REFIID riid,
LPVOID FAR* ppvObj) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// *** ICodeNavigate methods ***
STDMETHOD(DisplayDefaultEventHandler)(
THIS_ /* [in] */ LPCOLESTR lpstrObjectName) PURE;
};
// { 2702ad60-3459-11d1-88fd-00a0c9110049 }
DEFINE_GUID(IID_ICodeNavigate2, 0x2702ad60, 0x3459, 0x11d1, 0x88, 0xfd, 0x00, 0xa0, 0xc9, 0x11, 0x00, 0x49);
#undef INTERFACE
#define INTERFACE ICodeNavigate2
DECLARE_INTERFACE_(ICodeNavigate2, ICodeNavigate)
{
BEGIN_INTERFACE
// *** IUnknown methods ***
STDMETHOD(QueryInterface)(THIS_ REFIID riid,
LPVOID FAR* ppvObj) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// *** ICodeNavigate methods ***
STDMETHOD(DisplayDefaultEventHandler)(
THIS_ /* [in] */ LPCOLESTR lpstrObjectName) PURE;
// *** ICodeNavigate2 methods ***
STDMETHOD(DisplayEventHandler)(
THIS_ /* [in] */ LPCOLESTR lpstrObjectName,
LPCOLESTR lpstrEventName) PURE;
};
Every service is associated with a GUID and an SID, and contains IUnknown and at least one other interface, as shown in the example. Components that need to use a service pass the SID to IServiceProvider::QueryService. In the example, the SID for SCodeNavigate is SID_SCodeNavigate. Often, the SID is the same as the IID for one of the interfaces that belongs to the service. Here, SID_SCodeNavigate is defined to equal IID_ICodeNavigate.
The service includes the standard IUnknown interface and one or more additional interfaces. In the example, two additional interfaces, ICodeNavigate and ICodeNavigate2, are defined. The ICodeNavigate interface contains one method, DisplayDefaultEventHandler. The ICodeNavigate2 interface contains DisplayDefaultEventHandler (inherited from ICodeNavigate) and DisplayEventHandler.