Framework Support: IViewObjectExImpl

 < Free Open Study > 



Framework Support: IViewObjectExImpl<>

When you configure your control based on options from the Miscellaneous tab, you are indirectly configuring which items from the VIEWSTATUS enumeration will be present in your control. Recall that one of the standard COM interfaces required by an ActiveX control is IViewObjectEx, which defines a single method named GetViewStatus(). The purpose of this interface is to report to the control container if the control is opaque, and if so, if it has a solid background. VIEWSTATUS is defined in <ocidl.idl> as so:

// Members of the VIEWSTATUS enumeration are used by // IViewObjectEx::GetViewStatus(). typedef /* [v1_enum] */ enum tagVIEWSTATUS {      VIEWSTATUS_OPAQUE                  = 1,      VIEWSTATUS_SOLIDBKGND              = 2,      VIEWSTATUS_DVASPECTOPAQUE          = 4,      VIEWSTATUS_DVASPECTTRANSPARENT     = 8,      VIEWSTATUS_SURFACE                 = 16,      VIEWSTATUS_3DSURFACE               = 32 }     VIEWSTATUS; 

The IViewObjectEx interface is in fact derived from IViewObject2, which is in turn derived from IViewObject. This set of interfaces works towards the common goal of rendering your object on the container. Each interface is fully defined in online help; however, to give you a feeling of the behaviors provided by these three interfaces, here is a list of methods for each:

// IViewObject is used to provide core rendering support to a coclass. // <oleidl.idl> [ object, uuid(0000010d-0000-0000-C000-000000000046) ] interface IViewObject : IUnknown {      HRESULT Draw( ...);      HRESULT GetColorSet (...);      HRESULT Freeze (...);      HRESULT Unfreeze(...);      HRESULT SetAdvise (...);      HRESULT GetAdvise ( ...); }; // Extends IViewObject by providing a way to obtain the size of the object. // <oleidl.idl> [ object, uuid(00000127-0000-0000-C000-000000000046) ] interface IViewObject2 : IViewObject {      HRESULT GetExtent(...); }; // Extends IViewObject2 by providing support for flicker-free drawing, non-rectangular // regions and hit testing of these objects. // <ocidl.idl> [ object, uuid(3AF24292-0C96-11CE-A0CF-00AA00600AB8) ] interface IViewObjectEx : IViewObject2 {      HRESULT GetRect(...);      HRESULT GetViewStatus(...);      HRESULT QueryHitPoint(...);      HRESULT QueryHitRect(...);      HRESULT GetNaturalExtent (...); };

ATL provides a default implementation of IViewObjectEx (and therefore IViewObject2 and IViewObject) using the IViewObjectExImpl<> template. While we will not discuss the details of each method here, one insight is that IViewObject::Draw() ultimately calls CComControlBase::OnDraw(), giving you the chance to use any GDI logic necessary to render your control. The full definition of IViewObjectExImpl<> is in <atlctl.h>.



 < Free Open Study > 



Developer's Workshop to COM and ATL 3.0
Developers Workshop to COM and ATL 3.0
ISBN: 1556227043
EAN: 2147483647
Year: 2000
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net