Win32 COM events

Discussion in 'Ruby' started by Tim Uckun, Jan 15, 2007.

  1. Tim Uckun

    Tim Uckun Guest

    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)


    Thanks in Advance.
    Tim Uckun, Jan 15, 2007
    1. Advertisements

  2. Tim Uckun

    Jan Svitok Guest

    If you want to receive COM events,
    see WIN32OLE library, class WIN32OLE_EVENT,
    Programming Ruby, chapter on windows support,
    and my doc patch

    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.
    Jan Svitok, Jan 16, 2007
    1. Advertisements

  3. Tim Uckun

    Tim Uckun Guest

    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.

    The example says...
    router ='SomeOleObject.Something')
    ev =, 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?
    Tim Uckun, Jan 25, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.