http://qs321.pair.com?node_id=421422

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

I need to add an ActiveX control to a Tk window. Its a simple window. The object is created correctly, but i'm not quite sure how to get it to show up. This is what i got so far.
#!/usr/local/bin/perl use strict; use Win32::OLE; use Tk; my $main = MainWindow->new(); $main->minsize(400,400); $main->title("STK/X Demo for Perl/Tk"); $main->configure(-background => 'black'); # Add ActiveX Component Here my $stkx = Win32::OLE->new('...') || die"Can't create STKX\n"; my $vo = Win32::OLE->new('...') || die "Can't create VO\n"; $stkx->ExecuteCommand('...'); MainLoop();

- Tom

Replies are listed 'Best First'.
Re: Adding ActiveX Control to Tk Window
by Mr. Muskrat (Canon) on Jan 12, 2005 at 05:31 UTC
Re: Adding ActiveX Control to Tk Window
by Courage (Parson) on Jan 12, 2005 at 06:38 UTC
Re: Adding ActiveX Control to Tk Window
by Grygonos (Chaplain) on Jan 11, 2005 at 21:08 UTC

    To my knowledge you can only add Tk widgets onto a Tk window. Thus, you'll have to roll your own Tk widget for this based on the methods and attributes of the OLE object. Something like Win32::GUI might be more what you need than Tk

Re: Adding ActiveX Control to Tk Window
by didier (Vicar) on Jan 12, 2005 at 09:30 UTC
    Here an example from: AxWindow
    You can host the Win32::GUI window in a Toplevel Tk Win using the 'use' arg with the hexa id of the win32 window.
    use Win32::GUI; use Win32::GUI::AxWindow; # Main Window $Window = new Win32::GUI::Window ( -name => "Window", -title => "Win32::GUI::AxWindow test", -post => [100, 100], -size => [400, 400], ); # Add a WebBrowser AxtiveX $Control = new Win32::GUI::AxWindow ( -parent => $Window, -name => "Control", -control => "Shell.Explorer.2", # -control => "{8856F961-340A-11D0-A96B-00C04FD705A2}" +, -pos => [0, 0], -size => [400, 400], ); # Register some event $Control->RegisterEvent("StatusTextChange", sub { $self = shift; $eventid = shift; print "Event : ", @_, "\n"; } ); # Call Method $Control->CallMethod("Navigate", 'http://www.perl.com/'); # Event loop $Window->Show(); Win32::GUI::Dialog(); # Main window event handler sub Window_Terminate { return -1; } sub Window_Resize { if (defined $Window) { ($width, $height) = ($Window->GetClientRect)[2..3]; $Control->Move (0, 0); $Control->Resize ($width, $height); } }


    Hope this help.

      Given that you gave complete code sample on Win32::GUI side, can you please provide complete example on Tk side?

      IMHO this really worth trying, but trying with pseudo-code is not easy