Step 2: Choose a Visual or Nonvisual Run-Time Object

Whether the run-time object is visual or not, it must have a window and it must implement a default event interface.

Visual Run-Time Object

You have a couple of choices in implementing a visual run-time object:

Because CComDesignerToolbox provides design-time features only, a run-time instance should not inherit from it.

Nonvisual Run-Time Object

To implement a run-time object that does not have a visual user interface, use CComDesignerInvisAtRun, which provides dynamic registration features and provides an IOleObject interface for object siting.

A nonvisual run-time object also requires the interfaces listed below. You can use the ATL Object Wizard to generate an ATL Simple object with these interfaces. A nonvisual run-time object need not derive from CComControl.

Interface Implementation
IPersistStreamInit IPersistStreamInitImpl
IDispatch IDispatchImpl
IConnectionPointContainer IConnectionPointContainerImpl

The following example shows an object that is derived from CComDesignerInvisAtRun:

class ATL_NO_VTABLE CShapesInstCtl : 
   public CComObjectRootEx<CComSingleThreadModel>,
   public CComCoClass<CShapesInstCtl, &CLSID_ShapesInstCtl>,
   public IProvideClassInfo2Impl<&CLSID_ShapesInstCtl,
       &DIID_DShapesEvents, &LIBID_SHAPESINSTLib>,
   public IDispatchImpl<IShapesInstCtl,
      &IID_IShapesInstCtl, &LIBID_SHAPESINSTLib>,
   public CProxyDShapesEvents<CShapesInstCtl>,
   public IConnectionPointContainerImpl<CShapesInstCtl>
   public CComDesignerInvisAtRun<CShapesInstCtl,RegEntryArray>,
{
   . . .
}