ActiveX 控件接口

除了用于在控件与其客户端之间通信的其他机制外,ActiveX 控件技术还指定用于客户端控制通信的 IOleControlIOleControlSite 接口。 还有用于简单控制容器的 ISimpleFrameSite 接口。

但是,这三个接口特定于控件,在控件上下文之外通常并不有用。 这些接口的定义如下。

interface IOleControl : IUnknown 
  { 
    HRESULT GetControlInfo([out] CONTROLINFO *pCI); 
    HRESULT OnMnemonic([in] LPMSG pMsg); 
    HRESULT OnAmbientPropertyChange([in] DISPID dispID); 
    HRESULT FreezeEvents([in] BOOL bFreeze); 
  } 
 
interface IOleControlSite : IUnknown 
  { 
    HRESULT OnControlInfoChanged(void); 
    HRESULT LockInPlaceActive([in] BOOL fLock); 
    HRESULT GetExtendedControl([out] IDispatch **ppDisp); 
    HRESULT TransformCoords([in-out] POINTL *pptlHimetric, [in-out] POINTF *pptfContainer, [in] DWORD dwFlags); 
    HRESULT TranslateAccelerator([in] LPMSG pMsg, [in] DWORD grfModifiers); 
    HRESULT OnFocus([in] BOOL fGotFocus); 
    HRESULT ShowPropertyFrame(void); 
  } 
 
interface ISimpleFrameSite : IUnknown 
  { 
    HRESULT PreMessageFilter([in] HWND hWnd, [in] UINT msg, [in] WPARAM wp, [in] LPARAM lp, 
        [out] LRESULT *plResult, [out] DWORD *pdwCookie); 
    HRESULT PostMessageFilter([in] HWND hWnd, [in] UINT msg, [in] WPARAM wp, [in] LPARAM lp, 
        [out] LRESULT *plResult, [in] DWORD dwCookie); 
  } 
 

某些控件(如组框)只是其他控件的简单容器。 在这种情况下,称为简单帧的简单控件不必实现所有容器要求。 它可以将大部分接口调用从其包含的控件委托给管理简单帧的容器。 除了接口调用,简单帧还必须处理可能来自其中控件的 Windows 消息。 因此,容器提供 ISimpleFrameSite,以允许此类简单的帧控件将消息传递到容器。 PreMessageFilter 首先处理消息;PostMessageFilter 在简单帧处理消息本身后调用。

ActiveX 控件