Class OleControlSite

  • All Implemented Interfaces:
    Drawable

    public class OleControlSite
    extends OleClientSite
    OleControlSite provides a site to manage an embedded ActiveX Control within a container.

    In addition to the behaviour provided by OleClientSite, this object provides the following:

    • events from the ActiveX control
    • notification of property changes from the ActiveX control
    • simplified access to well known properties of the ActiveX Control (e.g. font, background color)
    • expose ambient properties of the container to the ActiveX Control

    This object implements the OLE Interfaces IOleControlSite, IDispatch, and IPropertyNotifySink.

    Note that although this class is a subclass of Composite, it does not make sense to add Control children to it, or set a layout on it.

    Styles
    BORDER
    Events
    Dispose, Move, Resize
    See Also:
    OLE and ActiveX snippets, SWT Examples: OLEExample, OleWebBrowser
    • Constructor Detail

      • OleControlSite

        public OleControlSite​(Composite parent,
                              int style,
                              File file)
        Create an OleControlSite child widget using the OLE Document type associated with the specified file. The OLE Document type is determined either through header information in the file or through a Registry entry for the file extension. Use style bits to select a particular look or set of properties.
        Parameters:
        parent - a composite widget; must be an OleFrame
        style - the bitwise OR'ing of widget styles
        file - the file that is to be opened in this OLE Document
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when the parent is null
        • ERROR_INVALID_ARGUMENT when the parent is not an OleFrame
        SWTException -
        • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
        • ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
        • ERROR_CANNOT_OPEN_FILE when failed to open file
        • ERROR_INTERFACE_NOT_FOUND when unable to create callbacks for OLE Interfaces
        • ERROR_INVALID_CLASSID
        Since:
        3.5
      • OleControlSite

        public OleControlSite​(Composite parent,
                              int style,
                              String progId)
        Create an OleControlSite child widget using style bits to select a particular look or set of properties.
        Parameters:
        parent - a composite widget; must be an OleFrame
        style - the bitwise OR'ing of widget styles
        progId - the unique program identifier which has been registered for this ActiveX Control; the value of the ProgID key or the value of the VersionIndependentProgID key specified in the registry for this Control (for example, the VersionIndependentProgID for Internet Explorer is Shell.Explorer)
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when the parent is null
        SWTException -
        • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
        • ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
        • ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
        • ERROR_CANNOT_ACCESS_CLASSFACTORY when Class Factory could not be found
        • ERROR_CANNOT_CREATE_LICENSED_OBJECT when failed to create a licensed OLE Object
      • OleControlSite

        public OleControlSite​(Composite parent,
                              int style,
                              String progId,
                              File file)
        Create an OleClientSite child widget to edit the specified file using the specified OLE Document application. Use style bits to select a particular look or set of properties.

        IMPORTANT: This method is not part of the public API for OleClientSite. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.

        Parameters:
        parent - a composite widget; must be an OleFrame
        style - the bitwise OR'ing of widget styles
        progId - the unique program identifier of am OLE Document application; the value of the ProgID key or the value of the VersionIndependentProgID key specified in the registry for the desired OLE Document (for example, the VersionIndependentProgID for Word is Word.Document)
        file - the file that is to be opened in this OLE Document
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when the parent is null
        • ERROR_INVALID_ARGUMENT when the parent is not an OleFrame
        SWTException -
        • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
        • ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
        • ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
        • ERROR_CANNOT_OPEN_FILE when failed to open file
        Since:
        3.5
        Restriction:
        This method is not intended to be referenced by clients.
    • Method Detail

      • addEventListener

        public void addEventListener​(int eventID,
                                     OleListener listener)
        Adds the listener to receive events.
        Parameters:
        eventID - the id of the event
        listener - the listener
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when listener is null
      • addEventListener

        public void addEventListener​(OleAutomation automation,
                                     int eventID,
                                     OleListener listener)
        Adds the listener to receive events.
        Parameters:
        automation - the automation object that provides the event notification
        eventID - the id of the event
        listener - the listener
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when listener is null
        Since:
        2.0
      • addEventListener

        public void addEventListener​(OleAutomation automation,
                                     String eventSinkId,
                                     int eventID,
                                     OleListener listener)
        Adds the listener to receive events.
        Parameters:
        automation - the automation object that provides the event notification
        eventSinkId - the GUID of the event sink
        eventID - the id of the event
        listener - the listener
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when listener is null
        Since:
        3.2
      • addPropertyListener

        public void addPropertyListener​(int propertyID,
                                        OleListener listener)
        Adds the listener to receive events.
        Parameters:
        propertyID - the identifier of the property
        listener - the listener
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when listener is null
      • getBackground

        public Color getBackground()
        Description copied from class: Control
        Returns the receiver's background color.

        Note: This operation is a hint and may be overridden by the platform. For example, on some versions of Windows the background of a TabFolder, is a gradient rather than a solid color.

        Overrides:
        getBackground in class Control
        Returns:
        the background color
      • getFont

        public Font getFont()
        Description copied from class: Control
        Returns the font that the receiver will use to paint textual information.
        Overrides:
        getFont in class Control
        Returns:
        the receiver's font
      • getForeground

        public Color getForeground()
        Description copied from class: Control
        Returns the foreground color that the receiver will use to draw.
        Overrides:
        getForeground in class Control
        Returns:
        the receiver's foreground color
      • getLicenseInfo

        protected long getLicenseInfo​(org.eclipse.swt.internal.ole.win32.GUID clsid)
      • getSiteProperty

        public Variant getSiteProperty​(int dispId)
        Get the control site property specified by the dispIdMember, or null if the dispId is not recognised.
        Parameters:
        dispId - the dispId
        Returns:
        the property value or null
        Since:
        2.1
      • OnUIDeactivate

        protected int OnUIDeactivate​(int fUndoable)
      • removeEventListener

        public void removeEventListener​(int eventID,
                                        OleListener listener)
        Removes the listener.
        Parameters:
        eventID - the event identifier
        listener - the listener which should no longer be notified
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when listener is null
      • removeEventListener

        @Deprecated
        public void removeEventListener​(OleAutomation automation,
                                        org.eclipse.swt.internal.ole.win32.GUID guid,
                                        int eventID,
                                        OleListener listener)
        Deprecated.
        - use OleControlSite.removeEventListener(OleAutomation, int, OleListener)
        Removes the listener.
        Parameters:
        automation - the automation object that provides the event notification
        guid - the identifier of the events COM interface
        eventID - the event identifier
        listener - the listener
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when listener is null
        Since:
        2.0
      • removeEventListener

        public void removeEventListener​(OleAutomation automation,
                                        int eventID,
                                        OleListener listener)
        Removes the listener.
        Parameters:
        automation - the automation object that provides the event notification
        eventID - the event identifier
        listener - the listener which should no longer be notified
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when listener is null
        Since:
        2.0
      • removePropertyListener

        public void removePropertyListener​(int propertyID,
                                           OleListener listener)
        Removes the listener.
        Parameters:
        propertyID - the identifier of the property
        listener - the listener which should no longer be notified
        Throws:
        IllegalArgumentException -
        • ERROR_NULL_ARGUMENT when listener is null
      • setBackground

        public void setBackground​(Color color)
        Description copied from class: Control
        Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.

        Note: This operation is a hint and may be overridden by the platform.

        Overrides:
        setBackground in class Control
        Parameters:
        color - the new color (or null)
      • setFont

        public void setFont​(Font font)
        Description copied from class: Control
        Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
        Overrides:
        setFont in class Control
        Parameters:
        font - the new font (or null)
      • setForeground

        public void setForeground​(Color color)
        Description copied from class: Control
        Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

        Note: This operation is a hint and may be overridden by the platform.

        Overrides:
        setForeground in class Control
        Parameters:
        color - the new color (or null)
      • setSiteProperty

        public void setSiteProperty​(int dispId,
                                    Variant value)
        Sets the control site property specified by the dispIdMember to a new value. The value will be disposed by the control site when it is no longer required using Variant.dispose. Passing a value of null will clear the dispId value.
        Parameters:
        dispId - the ID of the property as specified by the IDL of the ActiveX Control
        value - The new value for the property as expressed in a Variant.
        Since:
        2.1