Class: WIN32OLE_EVENT

Inherits:
Object
  • Object
show all
Defined in:
win32ole.c

Overview

WIN32OLE_EVENT objects controls OLE event.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#new(ole, event) ⇒ Object

Returns OLE event object. The first argument specifies WIN32OLE object. The second argument specifies OLE event name.

ie = WIN32OLE.new('InternetExplorer.Application')
ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')


# File 'win32ole.c'

static VALUE
fev_initialize(argc, argv, self)
int argc;
VALUE *argv;
VALUE self;
{
VALUE ole, itf;
struct oledata *pole;
char *pitf;
HRESULT hr;
IID iid;
ITypeInfo *pTypeInfo;
IDispatch *pDispatch;
IConnectionPointContainer *pContainer;
IConnectionPoint *pConnectionPoint;
IEVENTSINKOBJ *pIEV;
DWORD dwCookie = 0;
struct oleeventdata *poleev;

rb_secure(4);
rb_scan_args(argc, argv, "11", &ole, &itf);

if (!rb_obj_is_kind_of(ole, cWIN32OLE)) {
    rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE object");
}

Class Method Details

.message_loopObject

Translates and dispatches Windows message.



# File 'win32ole.c'

static VALUE
fev_s_msg_loop(klass)
    VALUE klass;
{
    ole_msg_loop();
    return Qnil;
}

Instance Method Details

#on_event([event]) { ... } ⇒ Object

Defines the callback event. If argument is omitted, this method defines the callback of all events.

ie = WIN32OLE.new('InternetExplorer.Application')
ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
ev.on_event("NavigateComplete") {|url| puts url}

Yields:



# File 'win32ole.c'

static VALUE
fev_on_event(argc, argv, self)
    int argc;
    VALUE *argv;
    VALUE self;
{
    return ev_on_event(argc, argv, self, Qfalse);
}

#on_event_with_outargs([event]) { ... } ⇒ Object

Defines the callback of event. If you want modify argument in callback, you should use this method instead of WIN32OLE_EVENT#on_event.

Yields:



# File 'win32ole.c'

static VALUE
fev_on_event_with_outargs(argc, argv, self)
    int argc;
    VALUE *argv;
    VALUE self;
{
    return ev_on_event(argc, argv, self, Qtrue);
}