Example usage for org.eclipse.swt.ole.win32 OleFrame OleFrame

List of usage examples for org.eclipse.swt.ole.win32 OleFrame OleFrame

Introduction

In this page you can find the example usage for org.eclipse.swt.ole.win32 OleFrame OleFrame.

Prototype

public OleFrame(Composite parent, int style) 

Source Link

Document

Create an OleFrame child widget using style bits to select a particular look or set of properties.

Usage

From source file:Main.java

public static void main(String[] args) {
    if (args.length == 0) {
        System.out.println("Usage: java Main <program id>");
        return;//ww w .  j  a v  a  2  s.c  om
    }

    String progID = args[0];

    Shell shell = new Shell();

    OleFrame frame = new OleFrame(shell, SWT.NONE);
    OleControlSite site = null;
    OleAutomation auto = null;
    try {
        site = new OleControlSite(frame, SWT.NONE, progID);
        auto = new OleAutomation(site);
    } catch (SWTException ex) {
        System.out.println("Unable to open type library for " + progID);
        return;
    }

    TYPEATTR typeattr = auto.getTypeInfoAttributes();
    if (typeattr != null) {
        if (typeattr.cFuncs > 0)
            System.out.println("Functions for " + progID + " :\n");
        for (int i = 0; i < typeattr.cFuncs; i++) {
            OleFunctionDescription data = auto.getFunctionDescription(i);
            String argList = "";
            int firstOptionalArgIndex = data.args.length - data.optionalArgCount;
            for (int j = 0; j < data.args.length; j++) {
                argList += "[";
                if (j >= firstOptionalArgIndex)
                    argList += "optional, ";
                argList += getDirection(data.args[j].flags) + "] " + getTypeName(data.args[j].type) + " "
                        + data.args[j].name;
                if (j < data.args.length - 1)
                    argList += ", ";
            }
            System.out.println(getInvokeKind(data.invokeKind) + " (id = " + data.id + ") : "
                    + "\n\tSignature   : " + getTypeName(data.returnType) + " " + data.name + "(" + argList
                    + ")" + "\n\tDescription : " + data.documentation + "\n\tHelp File   : " + data.helpFile
                    + "\n");
        }

        if (typeattr.cVars > 0)
            System.out.println("\n\nVariables for " + progID + " :\n");
        for (int i = 0; i < typeattr.cVars; i++) {
            OlePropertyDescription data = auto.getPropertyDescription(i);
            System.out.println("PROPERTY (id = " + data.id + ") :" + "\n\tName : " + data.name + "\n\tType : "
                    + getTypeName(data.type) + "\n");
        }
    }

    auto.dispose();
    shell.dispose();
}

From source file:org.eclipse.swt.snippets.Snippet305.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Excel Sheet Selection Example");
    shell.setLayout(new FillLayout());
    OleAutomation application;//from  w  w w .  ja  v a  2 s.co m
    try {
        OleFrame frame = new OleFrame(shell, SWT.NONE);
        OleControlSite controlSite = new OleControlSite(frame, SWT.NONE, "Excel.Sheet");
        controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);

        OleAutomation excelSheet = new OleAutomation(controlSite);
        int[] dispIDs = excelSheet.getIDsOfNames(new String[] { "Application" });
        Variant pVarResult = excelSheet.getProperty(dispIDs[0]);
        application = pVarResult.getAutomation();
        pVarResult.dispose();
        excelSheet.dispose();

        OleListener listener = new OleListener() {
            @Override
            public void handleEvent(OleEvent e) {
                // SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
                Variant[] args = e.arguments;
                // OleAutomation sheet = args[1].getAutomation(); // Excel.Sheet
                OleAutomation range = args[0].getAutomation(); // Excel.Range
                int[] dispIDs = range.getIDsOfNames(new String[] { "Row" });
                Variant pVarResult = range.getProperty(dispIDs[0]);
                int row = pVarResult.getInt();
                dispIDs = range.getIDsOfNames(new String[] { "Column" });
                pVarResult = range.getProperty(dispIDs[0]);
                int column = pVarResult.getInt();
                range.dispose();
                System.out.println("row=" + row + " column=" + column);
            }
        };
        controlSite.addEventListener(application, IID_AppEvents, SheetSelectionChange, listener);
    } catch (SWTError e) {
        System.out.println("Unable to open activeX control");
        display.dispose();
        return;
    }
    shell.setSize(800, 600);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    if (application != null)
        application.dispose();
    display.dispose();
}

From source file:Snippet123.java

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    OleControlSite controlSite;/*from w  ww .  j  a va  2  s. co m*/
    try {
        OleFrame frame = new OleFrame(shell, SWT.NONE);
        controlSite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer");
        controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
    } catch (SWTError e) {
        System.out.println("Unable to open activeX control");
        return;
    }
    shell.open();

    // IWebBrowser
    final OleAutomation webBrowser = new OleAutomation(controlSite);

    // When a new document is loaded, access the document object for the new
    // page.
    int DownloadComplete = 104;
    controlSite.addEventListener(DownloadComplete, new OleListener() {
        public void handleEvent(OleEvent event) {
            int[] htmlDocumentID = webBrowser.getIDsOfNames(new String[] { "Document" });
            if (htmlDocumentID == null)
                return;
            Variant pVarResult = webBrowser.getProperty(htmlDocumentID[0]);
            if (pVarResult == null || pVarResult.getType() == 0)
                return;
            // IHTMLDocument2
            OleAutomation htmlDocument = pVarResult.getAutomation();

            // Request to be notified of click, double click and key down
            // events
            EventDispatch myDispatch = new EventDispatch(EventDispatch.onclick);
            IDispatch idispatch = new IDispatch(myDispatch.getAddress());
            Variant dispatch = new Variant(idispatch);
            htmlDocument.setProperty(EventDispatch.onclick, dispatch);

            myDispatch = new EventDispatch(EventDispatch.ondblclick);
            idispatch = new IDispatch(myDispatch.getAddress());
            dispatch = new Variant(idispatch);
            htmlDocument.setProperty(EventDispatch.ondblclick, dispatch);

            myDispatch = new EventDispatch(EventDispatch.onkeydown);
            idispatch = new IDispatch(myDispatch.getAddress());
            dispatch = new Variant(idispatch);
            htmlDocument.setProperty(EventDispatch.onkeydown, dispatch);

            // Remember to release OleAutomation Object
            htmlDocument.dispose();
        }
    });

    // Navigate to a web site
    int[] ids = webBrowser.getIDsOfNames(new String[] { "Navigate", "URL" });
    Variant[] rgvarg = new Variant[] { new Variant("http://www.google.com") };
    int[] rgdispidNamedArgs = new int[] { ids[1] };
    webBrowser.invoke(ids[0], rgvarg, rgdispidNamedArgs);

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    // Remember to release OleAutomation Object
    webBrowser.dispose();
    display.dispose();

}

From source file:org.eclipse.swt.snippets.Snippet81.java

public static void main(String[] args) {

    if (args.length == 0) {
        System.out.println("Usage: java Main <program id>");
        return;//  w w w.ja  v a  2 s.c o m
    }

    String progID = args[0];

    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 81");

    OleFrame frame = new OleFrame(shell, SWT.NONE);
    OleControlSite site = null;
    OleAutomation auto = null;
    try {
        site = new OleControlSite(frame, SWT.NONE, progID);
        auto = new OleAutomation(site);
    } catch (SWTException ex) {
        System.out.println("Unable to open type library for " + progID);
        display.dispose();
        return;
    }

    printTypeInfo(auto);

    auto.dispose();
    shell.dispose();
    display.dispose();

}

From source file:Snippet186.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(2, false));

    final Text text = new Text(shell, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Button go = new Button(shell, SWT.PUSH);
    go.setText("Go");
    OleFrame oleFrame = new OleFrame(shell, SWT.NONE);
    oleFrame.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    OleControlSite controlSite;/*from   w  ww .  j  a v a 2  s .c o m*/
    OleAutomation automation;
    try {
        controlSite = new OleControlSite(oleFrame, SWT.NONE, "Shell.Explorer");
        automation = new OleAutomation(controlSite);
        controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
    } catch (SWTException ex) {
        return;
    }

    final OleAutomation auto = automation;
    go.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            String url = text.getText();
            int[] rgdispid = auto.getIDsOfNames(new String[] { "Navigate", "URL" });
            int dispIdMember = rgdispid[0];
            Variant[] rgvarg = new Variant[1];
            rgvarg[0] = new Variant(url);
            int[] rgdispidNamedArgs = new int[1];
            rgdispidNamedArgs[0] = rgdispid[1];
            auto.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
        }
    });

    // Read PostData whenever we navigate to a site that uses it
    int BeforeNavigate2 = 0xfa;
    controlSite.addEventListener(BeforeNavigate2, new OleListener() {
        public void handleEvent(OleEvent event) {
            Variant url = event.arguments[1];
            Variant postData = event.arguments[4];
            if (postData != null) {
                System.out.println("PostData = " + readSafeArray(postData) + ", URL = " + url.getString());
            }
        }
    });

    // Navigate to this web site which uses post data to fill in the text
    // field
    // and put the string "hello world" into the text box
    text.setText("file://" + Snippet186.class.getResource("Snippet186.html").getFile());
    int[] rgdispid = automation.getIDsOfNames(new String[] { "Navigate", "URL", "PostData" });
    int dispIdMember = rgdispid[0];
    Variant[] rgvarg = new Variant[2];
    rgvarg[0] = new Variant(text.getText());
    rgvarg[1] = writeSafeArray("hello world");
    int[] rgdispidNamedArgs = new int[2];
    rgdispidNamedArgs[0] = rgdispid[1];
    rgdispidNamedArgs[1] = rgdispid[2];
    automation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:OLEActiveXTypeLib.java

public static void main(String[] args) {

    if (args.length == 0) {
        System.out.println("Usage: java Main <program id>");
        return;//ww w  . j a v a2s.  c  o m
    }

    String progID = args[0];

    Display display = new Display();
    Shell shell = new Shell(display);

    OleFrame frame = new OleFrame(shell, SWT.NONE);
    OleControlSite site = null;
    OleAutomation auto = null;
    try {
        site = new OleControlSite(frame, SWT.NONE, progID);
        auto = new OleAutomation(site);
    } catch (SWTException ex) {
        System.out.println("Unable to open type library for " + progID);
        return;
    }

    printTypeInfo(auto);

    auto.dispose();
    shell.dispose();
    display.dispose();

}

From source file:org.eclipse.swt.snippets.Snippet186.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 186");
    shell.setLayout(new GridLayout(2, false));

    final Text text = new Text(shell, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Button go = new Button(shell, SWT.PUSH);
    go.setText("Go");
    OleFrame oleFrame = new OleFrame(shell, SWT.NONE);
    oleFrame.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    OleControlSite controlSite;//from   w  w  w . ja v a  2 s .  com
    OleAutomation automation;
    try {
        controlSite = new OleControlSite(oleFrame, SWT.NONE, "Shell.Explorer");
        automation = new OleAutomation(controlSite);
        controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
    } catch (SWTException ex) {
        System.out.println("Unable to open activeX control");
        display.dispose();
        return;
    }

    final OleAutomation auto = automation;
    go.addListener(SWT.Selection, new Listener() {
        @Override
        public void handleEvent(Event e) {
            String url = text.getText();
            int[] rgdispid = auto.getIDsOfNames(new String[] { "Navigate", "URL" });
            int dispIdMember = rgdispid[0];
            Variant[] rgvarg = new Variant[1];
            rgvarg[0] = new Variant(url);
            int[] rgdispidNamedArgs = new int[1];
            rgdispidNamedArgs[0] = rgdispid[1];
            auto.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
        }
    });

    // Read PostData whenever we navigate to a site that uses it
    int BeforeNavigate2 = 0xfa;
    controlSite.addEventListener(BeforeNavigate2, new OleListener() {
        @Override
        public void handleEvent(OleEvent event) {
            Variant url = event.arguments[1];
            Variant postData = event.arguments[4];
            if (postData != null) {
                System.out.println("PostData = " + readSafeArray(postData) + ", URL = " + url.getString());
            }
        }
    });

    // Navigate to this web site which uses post data to fill in the text field
    // and put the string "hello world" into the text box
    text.setText("file://" + Snippet186.class.getResource("Snippet186.html").getFile());
    int[] rgdispid = automation.getIDsOfNames(new String[] { "Navigate", "URL", "PostData" });
    int dispIdMember = rgdispid[0];
    Variant[] rgvarg = new Variant[2];
    rgvarg[0] = new Variant(text.getText());
    rgvarg[1] = writeSafeArray("hello world");
    int[] rgdispidNamedArgs = new int[2];
    rgdispidNamedArgs[0] = rgdispid[1];
    rgdispidNamedArgs[1] = rgdispid[2];
    automation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:org.eclipse.swt.snippets.Snippet123.java

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 123");
    shell.setLayout(new FillLayout());
    OleControlSite controlSite;/* w  w  w.  j  av a  2 s  .c om*/
    try {
        OleFrame frame = new OleFrame(shell, SWT.NONE);
        controlSite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer");
        controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
    } catch (SWTError e) {
        System.out.println("Unable to open activeX control");
        display.dispose();
        return;
    }
    shell.open();

    // IWebBrowser
    final OleAutomation webBrowser = new OleAutomation(controlSite);

    // When a new document is loaded, access the document object for the new page.
    int DownloadComplete = 104;
    controlSite.addEventListener(DownloadComplete, new OleListener() {
        @Override
        public void handleEvent(OleEvent event) {
            int[] htmlDocumentID = webBrowser.getIDsOfNames(new String[] { "Document" });
            if (htmlDocumentID == null)
                return;
            Variant pVarResult = webBrowser.getProperty(htmlDocumentID[0]);
            if (pVarResult == null || pVarResult.getType() == 0)
                return;
            //IHTMLDocument2
            OleAutomation htmlDocument = pVarResult.getAutomation();

            // Request to be notified of click, double click and key down events
            EventDispatch myDispatch = new EventDispatch(EventDispatch.onclick);
            IDispatch idispatch = new IDispatch(myDispatch.getAddress());
            Variant dispatch = new Variant(idispatch);
            htmlDocument.setProperty(EventDispatch.onclick, dispatch);

            myDispatch = new EventDispatch(EventDispatch.ondblclick);
            idispatch = new IDispatch(myDispatch.getAddress());
            dispatch = new Variant(idispatch);
            htmlDocument.setProperty(EventDispatch.ondblclick, dispatch);

            myDispatch = new EventDispatch(EventDispatch.onkeydown);
            idispatch = new IDispatch(myDispatch.getAddress());
            dispatch = new Variant(idispatch);
            htmlDocument.setProperty(EventDispatch.onkeydown, dispatch);

            //Remember to release OleAutomation Object
            htmlDocument.dispose();
        }
    });

    // Navigate to a web site
    int[] ids = webBrowser.getIDsOfNames(new String[] { "Navigate", "URL" });
    Variant[] rgvarg = new Variant[] { new Variant("http://www.google.com") };
    int[] rgdispidNamedArgs = new int[] { ids[1] };
    webBrowser.invoke(ids[0], rgvarg, rgdispidNamedArgs);

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    //Remember to release OleAutomation Object
    webBrowser.dispose();
    display.dispose();

}

From source file:GetEventsFromIE.java

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    OleControlSite controlSite;/* ww  w .ja  v  a 2 s.  c o  m*/
    try {
        OleFrame frame = new OleFrame(shell, SWT.NONE);
        controlSite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer");
        controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
    } catch (SWTError e) {
        System.out.println("Unable to open activeX control");
        return;
    }
    shell.open();

    // IWebBrowser
    final OleAutomation webBrowser = new OleAutomation(controlSite);

    // When a new document is loaded, access the document object for the new
    // page.
    int DownloadComplete = 104;
    controlSite.addEventListener(DownloadComplete, new OleListener() {
        public void handleEvent(OleEvent event) {
            int[] htmlDocumentID = webBrowser.getIDsOfNames(new String[] { "Document" });
            if (htmlDocumentID == null)
                return;
            Variant pVarResult = webBrowser.getProperty(htmlDocumentID[0]);
            if (pVarResult == null || pVarResult.getType() == 0)
                return;
            // IHTMLDocument2
            OleAutomation htmlDocument = pVarResult.getAutomation();

            // Request to be notified of click, double click and key down events
            EventDispatch myDispatch = new EventDispatch(EventDispatch.onclick);
            IDispatch idispatch = new IDispatch(myDispatch.getAddress());
            Variant dispatch = new Variant(idispatch);
            htmlDocument.setProperty(EventDispatch.onclick, dispatch);

            myDispatch = new EventDispatch(EventDispatch.ondblclick);
            idispatch = new IDispatch(myDispatch.getAddress());
            dispatch = new Variant(idispatch);
            htmlDocument.setProperty(EventDispatch.ondblclick, dispatch);

            myDispatch = new EventDispatch(EventDispatch.onkeydown);
            idispatch = new IDispatch(myDispatch.getAddress());
            dispatch = new Variant(idispatch);
            htmlDocument.setProperty(EventDispatch.onkeydown, dispatch);

            // Remember to release OleAutomation Object
            htmlDocument.dispose();
        }
    });

    // Navigate to a web site
    int[] ids = webBrowser.getIDsOfNames(new String[] { "Navigate", "URL" });
    Variant[] rgvarg = new Variant[] { new Variant("http://www.google.com") };
    int[] rgdispidNamedArgs = new int[] { ids[1] };
    webBrowser.invoke(ids[0], rgvarg, rgdispidNamedArgs);

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    // Remember to release OleAutomation Object
    webBrowser.dispose();
    display.dispose();

}

From source file:org.eclipse.swt.snippets.Snippet199.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 199");
    shell.setLayout(new FillLayout());
    OleControlSite controlSite;//from   w  w w .  j  a  v  a2 s.  c o m
    try {
        OleFrame frame = new OleFrame(shell, SWT.NONE);
        controlSite = new OleControlSite(frame, SWT.NONE, "Excel.Sheet");
        controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
    } catch (SWTError e) {
        System.out.println("Unable to open activeX control");
        display.dispose();
        return;
    }
    shell.open();

    OleAutomation excelSheet = new OleAutomation(controlSite);
    int[] dispIDs = excelSheet.getIDsOfNames(new String[] { "Application" });
    Variant pVarResult = excelSheet.getProperty(dispIDs[0]);
    OleAutomation application = pVarResult.getAutomation();
    pVarResult.dispose();
    excelSheet.dispose();

    int eventID = SheetSelectionChange;
    OleListener listener = new OleListener() {
        @Override
        public void handleEvent(OleEvent e) {
            System.out.println("selection has changed");
            Variant[] args = e.arguments;
            for (int i = 0; i < args.length; i++) {
                System.out.println(args[i]);
            }
        }
    };
    controlSite.addEventListener(application, IID_AppEvents, eventID, listener);

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    application.dispose();
    display.dispose();
}