Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » OLE events without id
OLE events without id [message #451186] Thu, 24 February 2005 13:02 Go to next message
Elmar Bartowitsch is currently offline Elmar BartowitschFriend
Messages: 10
Registered: July 2009
Junior Member
Hi all.

I need to embed an ActiveX control in my SWT app. Displaying and
controlling it works fine, but I didn't work out a way to receive events
from the control. As far as I know, this should be done by adding an
OleListener to the OleControlSite. I have to provide the event's id to
OleControlSite.addEventListener, and here's my problem: It seems the
events of this control don't have dispatch ids. Calling
OleAutomation.getIDsOfNames didn't bring any results; looking into the
IDL of the component, I found that the events don't have an id tag.

Is there a way of receiving these events using the OLE framework of SWT?

Regards,
eb
Re: OLE events without id [message #451202 is a reply to message #451186] Thu, 24 February 2005 15:01 Go to previous messageGo to next message
Tiberiu Caprita is currently offline Tiberiu CapritaFriend
Messages: 68
Registered: July 2009
Member
Hi Elmar,
I don't know if I got your problem or not, but if you don't know which
Event you want to listen to then you can't do something.

Normally when you set a Listener to a OleControlSite you use
addEventListener(int eventID, OleListener listener) or
addEventListener(OleAutomation automation, int eventID, OleListener
listener) (if you listen other interface than that of OleControlSite).
As you see, eventID (event that can be listen) is mandatory to be known.

But for some Applications, getDefaultEventSinkGUID() returns null (by
example Outlook) and you have to find a fix yourself.
The solution is based on the code that follow the
getDefaultEventSinkGUID() in addEventListener():
you have to find the GUID you want to listen to and call
void addEventListener(int iunknown, GUID guid, int eventID, OleListener
listener)

As summary if you see that getDefaultEventSinkGUID() returns null (make a
debug) you have to:
1. find the UUID of Event Interface you want to listen
2. Transform it in GUID
3. hack the swt in order to can call addEventListener(int iunknown, GUID
guid, int eventID, OleListener listener), and call it with your params.

Hope it helped.

Tiberiu




Elmar Bartowitsch wrote:

> Hi all.

> I need to embed an ActiveX control in my SWT app. Displaying and
> controlling it works fine, but I didn't work out a way to receive events
> from the control. As far as I know, this should be done by adding an
> OleListener to the OleControlSite. I have to provide the event's id to
> OleControlSite.addEventListener, and here's my problem: It seems the
> events of this control don't have dispatch ids. Calling
> OleAutomation.getIDsOfNames didn't bring any results; looking into the
> IDL of the component, I found that the events don't have an id tag.

> Is there a way of receiving these events using the OLE framework of SWT?

> Regards,
> eb
Re: OLE events without id [message #451212 is a reply to message #451202] Thu, 24 February 2005 15:19 Go to previous messageGo to next message
Elmar Bartowitsch is currently offline Elmar BartowitschFriend
Messages: 10
Registered: July 2009
Junior Member
Thanks a lot for your reply. I'll try this approach as soon as I have
some more time. For now, I found a way to 'simulate' the event I need.

thx,
eb

Tiberiu Caprita wrote:
> Hi Elmar,
> I don't know if I got your problem or not, but if you don't know which
> Event you want to listen to then you can't do something.
>
> Normally when you set a Listener to a OleControlSite you use
> addEventListener(int eventID, OleListener listener) or
> addEventListener(OleAutomation automation, int eventID, OleListener
> listener) (if you listen other interface than that of OleControlSite).
> As you see, eventID (event that can be listen) is mandatory to be known.
>
> But for some Applications, getDefaultEventSinkGUID() returns null (by
> example Outlook) and you have to find a fix yourself.
> The solution is based on the code that follow the
> getDefaultEventSinkGUID() in addEventListener():
> you have to find the GUID you want to listen to and call void
> addEventListener(int iunknown, GUID guid, int eventID, OleListener
> listener)
>
> As summary if you see that getDefaultEventSinkGUID() returns null (make
> a debug) you have to:
> 1. find the UUID of Event Interface you want to listen
> 2. Transform it in GUID
> 3. hack the swt in order to can call addEventListener(int iunknown, GUID
> guid, int eventID, OleListener listener), and call it with your params.
>
> Hope it helped.
>
> Tiberiu
>
>
>
>
> Elmar Bartowitsch wrote:
>
>> Hi all.
>
>
>> I need to embed an ActiveX control in my SWT app. Displaying and
>> controlling it works fine, but I didn't work out a way to receive
>> events from the control. As far as I know, this should be done by
>> adding an OleListener to the OleControlSite. I have to provide the
>> event's id to OleControlSite.addEventListener, and here's my problem:
>> It seems the events of this control don't have dispatch ids. Calling
>> OleAutomation.getIDsOfNames didn't bring any results; looking into the
>> IDL of the component, I found that the events don't have an id tag.
>
>
>> Is there a way of receiving these events using the OLE framework of SWT?
>
>
>> Regards,
>> eb
>
>
>
Re: OLE events without id [message #451283 is a reply to message #451202] Thu, 24 February 2005 15:25 Go to previous messageGo to next message
Tiberiu Caprita is currently offline Tiberiu CapritaFriend
Messages: 68
Registered: July 2009
Member
again me:
if the owner of ActiveX doesn't publish its Methods (by IDispatch), is
quasi impossible to use the ActiveX (including Events); the solution is to
ask the creator of ActiveX for info, if that one isn't contained in idl
(such as [id(0x0000f001)] void ItemAdd(...)).

Tiberiu
Re: OLE events without id [message #451291 is a reply to message #451202] Thu, 24 February 2005 17:08 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Sometimes, the events are not directly on the activeX control you created
but on one of the inner automation objects. You may need to get something
like the "Document" automation object first before you can query for the
event ids.

Also, for some events active X controls don't use the ConnectionPoint/Advise
mechanism but instead require that you pass in an IDispatch object as a
property to be notified of changes. For example in IE, onkeydown is sent to
an IDispatch object registered against that property.

For an example see:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet123.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup

Particularly, look at :

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

and the implementation of EventDispatch (also in the snippet).

If all else fails, post some of the IDL to these newsgroup and maybe we can
figure out how you need to call the thing.


IDL from IHTMLDocument2 for onkeydown:

dispinterface IHTMLDocument2 {
properties:
methods:
....
[id(0x80011775), propput, bindable, displaybind]
void onkeydown([in] VARIANT rhs);
....
Re: OLE events without id [message #451294 is a reply to message #451291] Thu, 24 February 2005 18:59 Go to previous message
Tiberiu Caprita is currently offline Tiberiu CapritaFriend
Messages: 68
Registered: July 2009
Member
Veronika Irvine wrote:

> Also, for some events active X controls don't use the ConnectionPoint/Advise
> mechanism but instead require that you pass in an IDispatch object as a
> property to be notified of changes. For example in IE, onkeydown is sent to
> an IDispatch object registered against that property.

Interesant, in my case I wasn't able to listen Outlook for ItemAdd Event
(Set myOlItems =
myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Items)
without what I wrote in previous message (I think there isn't a
ConnectionPoint/Advise).
I'll see if I can get a EventDispatch style, but I am not too confident.

Thanks,
Tiberiu
Previous Topic:How to get byte array from OpenGL framebuffer
Next Topic:Safe to call layout() out of controllistener#controlResized()?
Goto Forum:
  


Current Time: Fri Apr 19 04:06:08 GMT 2024

Powered by FUDForum. Page generated in 0.01995 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top