Accessing Container Services

A designer can access a service provided by container only if it provides a Services Map, and only if the designer lists that services in the Services Map. See Service Map Macros for details.

For example, to access the ICodeNavigate interface, your designer would include the following service map:

BEGIN_SERVICES_MAP()
   SERVICES_MAP_ENTRY(&SID_SCodeNavigate,&IID_ICodeNavigate)
END_SERVICES_MAP()

If the service is included in the map, your designer can use the GET_SERVICE_INTERFACE() macro in code to get a pointer to an interface that is part of the service. For example, the following gets a pointer to the ICodeNavigate interface:

ICodeNavigate * pICodeNavigate = NULL;
GET_SERVICE_INTERFACE(IID_ICodeNavigate,*pICodeNavigate)

In a base class (not in the most derived class), you can get a pointer to an interface on a service by using the GET_SERVICE_INTERFACE_FROM_DERIVED_CLASS() macro in code. The code that handles toolbox Click & Drag uses this macro to get a pointer to the IDesignerToolboxSite interface, as follows:

if(dwToolboxSupport & ISUPPORT_CLICKDRAG)
{
   GET_SERVICE_INTERFACE_FROM_DERIVED_CLASS(&IID_IDesignerToolboxSite,            (void **)&m_pIDesignerToolboxSite)
   . . .
}