Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Implementing IID_IDispatch from within Eclipse

I'd like to propose a small change to the SWT/OLE APIs that facilitates
more sophisticated interactions with COM servers embedded in an SWT
application.

The setting is this: I'm building a plugin for Eclipse that needs to
interact with an embedded instance of Internet Explorer in a rather deep
way.  For example, I need to install DHTML event handlers and
"behaviors" into elements of the IE DOM.  To do this, I need to
generate, in Java, an implementation of IID_IDispatch, stuff it into a
Variant, and pass the variant into IE by way of OleAutomation.

I searched the newsgroups and couldn't find a way to do this using SWT.
However, after browsing the source, I found there was a way if the
following OleAutomation.java constructor were made public:

public OleAutomation(int address)

This allows me to create my own IID_IDispatch implementation using
COMObject.java

mydisp = new COMObject(new int[]{2, 0, 0,1,3,5,8}) {
   ...

   // GetTypeInfoCount
   public int method3(int[] args) {...}

   // GetTypeInfo
   public int method4(int[] args) {...}

   // GetIDsOfNames
   public int method5(int[] args) {...}

  // Invoke
  public int method6(int[] args) {...}
};

I can then send this IID_IDispatch to IE's DHTML model by saying:

oleAutoForIE.setProperty(
     dispIDOnMouseMove,
     new Variant(
        new OleAutomation( mydisp.getAddress() )
     )
);





Back to the top