Win32 COM events

T

Tim Uckun

Hello All.

I want to translate the following VB code to Ruby. Does anybody know
how to handle these events?

Dim WithEvents myOBJ As SomeOBJ

Private Sub myOBJ_SomeEvent(ByVal nCommand As Integer,
ByRef cResult As String)

---
Also things like this...

Event SomeFunction(ByVal n as Integer)

SomeFunction(5)

Thanks in Advance.
 
J

Jan Svitok

Hello All.

I want to translate the following VB code to Ruby. Does anybody know
how to handle these events?

Dim WithEvents myOBJ As SomeOBJ

Private Sub myOBJ_SomeEvent(ByVal nCommand As Integer,
ByRef cResult As String)

---
Also things like this...

Event SomeFunction(ByVal n as Integer)

SomeFunction(5)

If you want to receive COM events,
see WIN32OLE library, class WIN32OLE_EVENT,
Programming Ruby, chapter on windows support,
thread
http://groups.google.com/group/comp...146a1c503e7/37b07544198f5bf1#37b07544198f5bf1
http://groups.google.com/group/ruby...ac34191f20c/3e16fc7ea887a00a#3e16fc7ea887a00a
and my doc patch
http://rubyforge.org/tracker/?func=detail&aid=7557&group_id=426&atid=1700

If you want to rewrite the code without interacting with COM, it's
another story.
In that case, write in more detail what are you trieng to achieve.
 
T

Tim Uckun

If you want to receive COM events,
see WIN32OLE library, class WIN32OLE_EVENT,
Programming Ruby, chapter on windows support,
thread
http://groups.google.com/group/comp...146a1c503e7/37b07544198f5bf1#37b07544198f5bf1
http://groups.google.com/group/ruby...ac34191f20c/3e16fc7ea887a00a#3e16fc7ea887a00a
and my doc patch
http://rubyforge.org/tracker/?func=detail&aid=7557&group_id=426&atid=1700

If you want to rewrite the code without interacting with COM, it's
another story.
In that case, write in more detail what are you trieng to achieve.

I have read the win32 doc, and I have read your doc patch. I don't
know if .invoke and on_event are compatible in some way or not.
though.

The example says...
router = WIN32OLE.new('SomeOleObject.Something')
ev = WIN32OLE_EVENT.new(router, nil)

ev.on_event {|*args| default_handler(*args)}
ev.on_event("NavigateComplete") {|url| navigate(url)}

in my case many of the params passed in are by reference and need to
be modified by the code that is handling the event. In other words the
ole object is requesting information my code by invoking events.

Do I still use the .invoke function here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top