Navigation


Frequenctly Asked Questions

My embedded control doesn't activate until I click it with my mouse

The most common cause for this is not activating the Ole Control/Document after having embedding it into your SWT Shell or Composite. Depending on the type of control/document you are using it will need to be activated. Take a look at the ole?????? methods available on the AutomationComposite class. The most likely one to use is oleShow() which instructs the control/document to use the most appropriate method to activate itself.

Here is an extract of code from the Word XML Mail Merge Sample that performs this function.

        DocumentComposite docWin;
        if (docFile == null) {
            tabItem.setText("New Document");
            docWin = new DocumentComposite(tabFolder, SWT.NONE);
        } else {
            tabItem.setText(docFile.getName());
            docWin = new DocumentComposite(tabFolder, SWT.NONE, docFile);
        }
        docWin.getDocumentAutomation().getApplication().setDisplayScrollBars(true);
        docWin.getOleFrame().setFileMenus(fileMenus);
---->   docWin.getOleClientSite().doVerb(OLE.OLEIVERB_SHOW);

org.eclipse.swt.SWTException: Failed to create Ole Client. result = -2147221230

Ole error code -2147221230 (0x80040112) means that an appropriate license for COM component could not be found. The SWT OleControlSite class does support controls that have licenses however some controls have special license requirements that are not supported. For example Microsoft Office comes with a MSFlexGrid control, however if you attempt to use this control outside of VBA you will get this error.

SWTtoCOM did not generate a ????Composite class for my control

SWT only supports embedding controls that have a ProgID. If the control you wish to emebed does not have a ProgID loaded in the registry then you will not get a ????Composite class generated.

org.eclipse.swt.SWTException: Failed to create Ole Client. result = -2147221008

The windows description for Ole Reason code -2147221008 or in hex 0x800401F0 is CoInitialize has not been called. Take a look at the section on Initializing SWTtoCOM for more details on how to overcome this problem.