Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] OLE based Win32 driver and Swing...


Here is an example showing an AWT Frame with the SWT support for ActiveX controls embedded inside it.
Of course this is entirely experimental and I have not tested beyond seeing that it comes up and you can click on the web links etc.

You need to pass in a java.awt.Canvas as the parent for the SWT widgets.


public static void main(String[] args) {
    /* Create AWT Frame */
    final java.awt.Frame frame = new java.awt.Frame("Outer window is java.awt.Frame");
    frame.setSize(350, 300);
    frame.setVisible(true);

    frame.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent e) {
            e.getWindow().dispose();
        }
        public void windowClosed(java.awt.event.WindowEvent e) {
            System.exit(0);
        }
    });
    java.awt.Panel panel = new java.awt.Panel();
    frame.add(panel);

    final java.awt.Canvas canvas = new java.awt.Canvas();
    panel.add(canvas);


    final Display display = new Display();
    final Shell shell = org.eclipse.swt.internal.awt.win32.SWT_AWT.new_Shell(display, canvas);
    shell.setLayout(new FillLayout());
    org.eclipse.swt.ole.win32.OleFrame oleFrame = new org.eclipse.swt.ole.win32.OleFrame(shell, SWT.NONE);
        org.eclipse.swt.ole.win32.OleControlSite controlSite;
        try {
                controlSite = new org.eclipse.swt.ole.win32.OleControlSite(oleFrame, SWT.NONE, "Shell.Explorer");
        } catch (SWTException ex) {
                System.out.println("Failed to create ActiveX control: " +ex.getMessage());
                return;
        }
        canvas.setSize(350, 300);
       
        controlSite.doVerb(org.eclipse.swt.ole.win32.OLE.OLEIVERB_INPLACEACTIVATE);
        org.eclipse.swt.ole.win32.OleAutomation automation = new org.eclipse.swt.ole.win32.OleAutomation(controlSite);
        int[] rgdispid = automation.getIDsOfNames(new String[]{"GoHome"});
        int dispIdMember = rgdispid[0];
        automation.invoke(dispIdMember);


    // Need to invoke the AWT layout manager or AWT and Swing widgets willnot
    // be visible
    frame.validate();

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

}



Peter.FLYNN@xxxxxxxxxxxx
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

19/12/2001 09:21 AM
Please respond to platform-swt-dev

       
        To:        platform-swt-dev@xxxxxxxxxxx
        cc:        
        Subject:        [platform-swt-dev] OLE based Win32 driver and Swing...


Hello all,

I've only just recently downloaded Eclipse and am slowly looking throughout
all of the features of SWT.  I'm quite interested in the OLE WIN32 Web
Browser and how it integrates in with Java.  

My current application uses a JDesktopPane with JInternalFrames displayed on
it.  

I am sure that SWT is heavyweight components (like AWT) and that they will
not display correctly inside the JDesktopPane.  Is this the case?  Has
anyone else tried to integrate the SWT Web Browser with Swing??

A full implementation of the desktop app in Eclipse is out of the question
for now due to time constraints, but I am still interested in the Web
Browser component.

Regards,
Peter


********************************************************************

This email may contain information which is privileged or confidential. If you are not the intended recipient of this email, please notify the sender immediately and delete it without reading, copying, storing, forwarding or disclosing its contents to any other person
Thank you

Check us out at http://www.syntegra.com

********************************************************************

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top