From: Masaki Suketa Date: 2002-02-21T20:55:39+09:00 Subject: Re: Win32ole event callback? In message "Re: Win32ole event callback?" on 02/02/06, Masaki Suketa writes: > > > Here is a sample: > > > > > > Private Sub ie_NewWindow2(ppDisp As Object, Cancel As Boolean) > > > '//prevent the new window // > > > Cancel = True > > > End Sub > > > > Thank you. Now, I understand what you want to do. > But, sorry, the current version of Win32OLE does not provide > the feature you want. Win32OLE 0.4.0 provides WIN32OLE_EVENT#on_event_with_out_args. This is not straightforward as like as VB, but this sample works fine and I hope this is what you want. require 'win32ole' def stop_msg_loop $LOOP = FALSE; end def new_window2(ppdisp, cancel, args) # sorry 'cancel = true' does not work. # prevent the new window args[1] = true end ie = WIN32OLE.new('InternetExplorer.Application') ie.visible = TRUE ie.gohome ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents2') ev.on_event_with_out_args("NewWindow2") {|ppdisp, cancel, args| new_window2(ppdisp, cancel, args) } ev.on_event("OnQuit") {|*args| stop_msg_loop} $LOOP = TRUE while ($LOOP) WIN32OLE_EVENT.message_loop end Regards, Masaki Suketa