1 / 12

ActiveX Controls

ActiveX Controls. Jim Fawcett CSE775 – Distributed Objects Spring 2007. What is an ActiveX Control? Com Component. A COM component User Interface Has thread affinity, must live in an STA Derives from CComObjectRootEx<CComSingleThread-Model> Creatable class Derives from CComCoClass

jamesheath
Download Presentation

ActiveX Controls

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ActiveX Controls Jim Fawcett CSE775 – Distributed Objects Spring 2007

  2. What is an ActiveX Control?Com Component • A COM component • User Interface • Has thread affinity, must live in an STA • Derives from CComObjectRootEx<CComSingleThread-Model> • Creatable class • Derives from CComCoClass • Provides IClassFactory interface

  3. What is an ActiveX Control?Properties, callbacks, change notifications • Has stock and custom properties and methods • Implements IDispatch interface • Stock and custom event callbacks • Supports connection points • dispinterface, IConnectionPointContainer, IConnectionPoint, IProvideClassInfo2 • Property change notifications • IPropertyNotifySink, connection points

  4. What is an ActiveX Control?Control behavior • On-demand rendering of view • IViewObject, IViewObject2, IViewObjectEx • Standard control behavior • IOleControl • In-place activation • IOleObject, IOleInPlaceActiveObject

  5. What is an ActiveX Control?Persistence and Drag-and-Drop • Persistence support for containers • IPersistStreamInit, IPersistPropertyBag, IPersistStorage • Drag and Drop support • IDataObject, IDropSource, IDropTarget

  6. What is an ActiveX Control?Design-Time Support • Provide property pages • ISpecifyPropertyPages • Property browsing from container • IPerPropertyBrowsing • Arrange properties by category • ICategorizeProperties

  7. Control Types • “Standard” ActiveX control • Composite Control • A container and a control • HTML Control • Uses same webBrowser control as IE

  8. What is a Control Container? • Provides a window • Acts as parent for the child COM control • Provides means for user to communicate with control, e.g., button-click, mouse-move, … • Support a set of COM interfaces that control uses to communicate with container

  9. What is a Control Container?Basic containment • Control creation • CAxHostWindow has the base classes • CComCoClass • CComObjectRootEx<CComSingleThreadModel> • CWindowImpl • IOleClientSite • IOleInPlaceSiteWindowless • IOleControlSite • IOleContainer • IObjectWintSiteImpl • IServiceProvider • IAdviseSink

  10. Container Window • Since the container provides a window for the control, you can do all the usual window things with it by sending windows messages: • Resize and move • Show and hide • CAxWindow provides a QueryControl method to obtain the control’s interface • HRESULT QueryControl(REFIID iid, void** ppUnk);

  11. Sinking a Control’s Events • Connection Pointer interfaces • dispinterface, not dual interface, so container can’t just derive from, and implement those source interfaces • IDispatchImpl<nID, T, pdiid> • Derive once of each control • UsesBEGIN_SINK_MAP, SINK_ENTRY, END_SINK_MAP • Call IConnectionPointContainer, IConnectionPoint, IAdvise to establish link • Uses HRESULT AtlAdviseSinkMap(T* pT, bool bAdvise);

  12. Sinking Control’s Property Notifications • Control defines IPropertyNotify interface • Request permission to change a property • Notify of a property change • IPropertyNotify is a dual interface • Container just inherits and implements • No need for sink map and IDispatchImpl • Implement STDMETHODIMP OnRequestEdit(DISPID dispID){ return S_OK; }STDMETHODIMP OnChanged(DISPID dispID){ m.bDirty = true; return S_OK; }

More Related