Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Win32::OLE Usage

by Nitrox (Chaplain)
on Feb 06, 2003 at 21:59 UTC ( [id://233290]=perlquestion: print w/replies, xml ) Need Help??

Nitrox has asked for the wisdom of the Perl Monks concerning the following question:

I've successfully created an Win32::OLE object which gives me about 95% of the functionality available with this particular 3rd party application. The latest piece that I'm trying to get working is a callback. Here's what the documentation shows for VB interaction:

RegisterEventCB takes a long, and a reference to a form with a HSEvent(parms as variant) method declared public.

Private Sub Form_Load() Set hs = New HS.Application hs.RegisterEventCB 3, Me End Sub
Here is a snippet from my Perl version, which doesn't throw an error, but passing $cb to Data::Dumper shows its empty.
$obj = Win32::OLE->CreateObject('HS.Application'); $self = bless {}; $cb = $obj->RegisterEventCB(3,$self); print Dumper(\$cb); sub HSEvent{ print Dumper(\@_); }

Does anyone see what I'm doing wrong here? Thanks in advance.

-Nitrox

Replies are listed 'Best First'.
Re: Win32::OLE Usage
by LanceDeeply (Chaplain) on Feb 06, 2003 at 23:06 UTC
Re: Win32::OLE Usage
by tachyon (Chancellor) on Feb 06, 2003 at 23:38 UTC

    These two are not equivalent.

    hs.RegisterEventCB 3, Me $cb = $obj->RegisterEventCB(3,$self);

    You note that:

    RegisterEventCB takes a long, and a reference to a form with a HSEvent(parms as variant) method declared public

    You are passing a long (digit 3) and a blessed anon hash to the RegisterEventCB method when it wants a reference to a form (object). I think you need to generate the form object somewhere - Me.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      I admit it was a stretch, but I was hoping that the second argument in $self would be equivalent to a Form.

      Anyone have an idea on how to generate a Form object in Perl?

      -Nitrox

        Unfortunatly, whatever code you are using sounds like it is designed specifically for use in VB. Because perl is using OLE in a non-GUI (in the VB sence) environment, there are no forms to pass. There may be some bastardisation of Win32::GUI which could produce a form handle, but i have yet to see it.I suspect that there is currently no way to create a form in perl, but i may be wrong.
        from the frivolous to the serious
Re: Win32::OLE Usage
by Nitrox (Chaplain) on Feb 07, 2003 at 03:28 UTC
    I stumbled upon a copy of "OLE View" and it proved to be quite helpful. I took a look at the Type Info for the COM object I'm working with and saw that the "reference to a form" parameter is a IDispatch interface. A quick search turned up PerlCOM which doesn't mention callbacks, but it's a starting place.

    -Nitrox

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://233290]
Approved by Enlil
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found