Update of /cvsroot/perl-win32-gui/Win32-GUI-AxWindow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15455
Added Files: AxWindow.html AxWindow.pm AxWindow.xs Changes MANIFEST Makefile.PL README TYPEMAP Log Message: Added to repository --- NEW FILE: AxWindow.pm --- package Win32::GUI::AxWindow; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); use Win32::GUI; require Exporter; require DynaLoader; require AutoLoader; @ISA = qw(Exporter DynaLoader Win32::GUI::Window); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. @EXPORT = qw(); $VERSION = '0.07'; bootstrap Win32::GUI::AxWindow $VERSION; # Preloaded methods go here. # Initialise Win32::GUI::AxWindow::_Initialise(); # DeInitialise END { Win32::GUI::AxWindow::_DeInitialise(); } # Autoload methods go after =cut, and are processed by the autosplit program. # # new : Create a new ActiveX Window # sub new { my $class = shift; my %in = @_; ### Control option croak("-parent undefined") unless exists $in{-parent}; croak("-name undefined") unless exists $in{-name}; croak("-control undefined") unless exists $in{-control}; my $parent = $in{-parent}; my $name = $in{-name}; my $clsid = $in{-control}; # print "Parent = $parent->{-name}\n"; # print "Name = $name\n"; # print "Control = $clsid\n"; ### Size my ($x, $y, $w, $h) = (0,0,1,1); $x = $in{-left} if exists $in{-left}; $y = $in{-top} if exists $in{-top}; $w = $in{-width} if exists $in{-width}; $h = $in{-height} if exists $in{-height}; ($x, $y) = ($in{-pos}[0] , $in{-pos}[1]) if exists $in{-pos}; ($w, $h) = ($in{-size}[0],$in{-size}[1]) if exists $in{-size}; # print "(x,y) = ($x,$y)\n(w,h) = ($w,$h)\n"; ### Window Style my $style = WS_CHILD | WS_CLIPCHILDREN; $style = $in{-style} if exists $in{-style}; $style |= $in{-pushstyle} if exists $in{-pushstyle}; $style ^= $in{-popstyle} if exists $in{-popstyle}; $style |= $in{-addstyle} if exists $in{-addstyle}; $style ^= $in{-remstyle} if exists $in{-remstyle}; $style |= WS_VISIBLE unless exists $in{-visible} && $in{-visible} == 0; $style |= WS_TABSTOP unless exists $in{-tabstop} && $in{-tabstop} == 0; $style |= WS_DISABLED if exists $in{-enable} && $in{-enable} == 0; $style |= WS_HSCROLL if exists $in{-hscroll} && $in{-hscroll} == 1; $style |= WS_VSCROLL if exists $in{-vscroll} && $in{-vscroll} == 1; # print "Style = $style\n"; ### Window ExStyle my $exstyle = 0; $exstyle = $in{-exstyle} if exists $in{-exstyle}; $exstyle |= $in{-pushexstyle} if exists $in{-pushexstyle}; $exstyle ^= $in{-popexstyle} if exists $in{-popexstyle}; $exstyle |= $in{-addexstyle} if exists $in{-addexstyle}; $exstyle ^= $in{-remexstyle} if exists $in{-remexstyle}; # print "ExStyle = $exstyle\n"; ### Create Window and ActiveX Object my $self = {}; bless $self, $class; if ( $self->_Create($parent, $clsid, $style, $exstyle, $x, $y, $w, $h) ) { ### Store Data (Win32::GUI glue) $self->{-name} = $in{-name}; $parent->{$name} = $self; return $self; } return undef; } # # CallMethod : Use Invoke with DISPATCH_METHOD # sub CallMethod { my $self = shift; return $self->Invoke (0x01, @_); } # # GetProperty : Use Invoke with DISPATCH_PROPERTYGET # sub GetProperty { my $self = shift; return $self->Invoke (0x02, @_); } # # PutProperty : Use Invoke with DISPATCH_PROPERTYPUT # sub SetProperty { my $self = shift; return $self->Invoke (0x04, @_); } 1; __END__ # Below is the stub of documentation for your module. You better edit it! =head1 NAME Win32::GUI::AxWindow - Perl extension for Hosting ActiveX Control in Win32::GUI =head1 SYNOPSIS 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); } } =head1 DESCRIPTION =head2 AxWindow =item C<new> (...) Create a new ActiveX window. options : -parent => parent window (Required) -name => window name (Required) -size => window size [ width, heigth ] -pos => window pos [ left, top ] -width => window width -height => window height -left => window left -top => window top -control => clisd (see below) (Required). clsid is a string identifier to create the control. Must be formatted in one of the following ways: - A ProgID such as "MSCAL.Calendar.7" - A CLSID such as "{8E27C92B-1264-101C-8A2F-040224009C02}" - A URL such as "http://www.microsoft.com" - A reference to an Active document such as 'file://Documents/MyDoc.doc' - A fragment of HTML such as "MSHTML:<HTML><BODY>This is a line of text</BODY></HTML>" Note "MSHTML:" must precede the HTML fragment so that it is designated as being an MSHTML stream. styles: -visible => 0/1 -tabstop => 0/1 -hscroll => 0/1 -vscroll => 0/1 -style, -addstyle, -pushstyle, -remstyle, -popstyle -exstyle, -exaddstyle, -expushstyle, -exremstyle, -expopstyle Default style is : WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPCHILDREN =item C<Release> () If have crash when exiting, call this function before all the window are destroy (before Win32::GUI::Dialog(); exit). Generaly, call this function in the Window_Terminate handle. =head2 Property =item C<EnumPropertyID> () Return a list of all the Property ID of the control. =item C<EnumPropertyName> () Return a list of all the Property name of the control. =item C<GetPropertyInfo> (ID_or_Name) Return a hash with information about the Property from ID or Name. Hash entry : -Name => Property Name. -ID => Property ID. -VarType => Property Type (Variant type). -EnumValue => A formated string of enum value ( enum1=value1,enum2=value2,... ). -ReadOnly => Indicate if a property can only be read. -Description => Property Description. -Prototype => Prototype =item C<GetProperty> (ID_or_Name, [index, ...]) Get property value. For indexed property, add index list. =item C<SetProperty> (ID_or_Name, [index, ...], value) Set property value For indexed property, add index list before value. =head2 Method =item C<EnumMethodID> () Return a list of all the Method ID of the control. =item C<EnumMethodName> () Return a list of all the Method name of the control. =item C<GetMethodInfo> (ID_Name) Return a hash with information about the Method from ID or Name. Hash entry : -Name => Method Name. -ID => Method ID. -Description => Method Description. -Prototype => Method Prototype. =item C<CallMethod> (ID_or_Name, ...) Invoke a method of an ActiveX control. =head2 Event =item C<EnumEventID> () Return a list of all the Event ID of the control. =item C<EnumEventName> () Return a list of all the Event Name of the control. =item C<GetEventInfo> (ID_or_Name) Return a hash with information about the Event from ID or Name. Hash entry : -Name => Method Name. -ID => Method ID. -Description => Method Description. -Prototype => Method Prototype. =item C<RegisterEvent> (ID_or_Name, Callback) Associate a Callback for an ActiveX Event. =head2 Win32::OLE =item C<GetOLE> () Return a Win32::OLE object of Hosted ActiveX Control. You MUST add use Win32::OLE in your script. =head1 AUTHOR Laurent Rocher ([EMAIL PROTECTED]) HomePage :http://perso.club-internet.fr/rocherl/Win32GUI.html =head1 SEE ALSO Win32::GUI =cut --- NEW FILE: Makefile.PL --- use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Win32::GUI::AxWindow', 'VERSION_FROM' => 'AxWindow.pm', # finds $VERSION 'XS' => { 'AxWindow.xs' => 'AxWindow.cpp' }, 'LIBS' => ['atl.lib'], # e.g., '-lm' 'INC' => '', # e.g., '-I/usr/include/other' ($] eq '5.00503') ? ( 'DEFINE' => '-DPERL_5005', # e.g., '-DHAVE_SOMETHING' ) : ( 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING' ), ($] ge '5.005') ? ( 'AUTHOR' => 'ROCHER Laurent ([EMAIL PROTECTED])', 'ABSTRACT' => 'Add ActiveX Control Hosting in Win32::GUI', ) : (), ); sub MY::xs_c { ' .xs.c: $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.c .xs.cpp: $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.cpp '; } --- NEW FILE: MANIFEST --- Makefile.PL Changes AxWindow.pm AxWindow.xs MANIFEST TYPEMAP Samples/WebBrowser.pl Samples/InfoControl.pl Samples/DHtmlEdit.pl Samples/DHtmlEdit.pm Samples/DHtmlEditor.pl Samples/MsFlexGrid.pl Samples/TestOLE.pl --- NEW FILE: AxWindow.xs --- /**********************************************************************/ /* C o n t a i n e r . x s */ /**********************************************************************/ #include <atlbase.h> CComModule _Module; #include <atlcom.h> #include <atlhost.h> #include <atlctl.h> #include <winbase.h> /*====================================================================*/ /* Perl Compatibility */ /*====================================================================*/ #ifdef PERL_5005 [...2660 lines suppressed...] void Release (container) CContainer* container CODE: // printf("Release\n"); container->Clean(); // printf("Release\n"); ################################################################## # # DESTROY # void DESTROY(container) CContainer* container CODE: // printf("DESTROY\n"); delete container; // printf("DESTROY\n"); --- NEW FILE: README --- Win32::GUI::AxWindow 0.07 ========================= Win32::GUI::AxWindow - Perl extension for Hosting ActiveX Control in Win32::GUI INSTALLATION To install this module type the following: perl Makefile.PL make make install DEPENDENCIES This module requires these other modules and libraries: Win32::GUI Active Template Library (ATL) WEB PAGE AND PPM REPOSITORY See: http://perso.club-internet.fr/rocherl/Win32GUI.html COPYRIGHT AND LICENCE Copyright 2003 by Laurent Rocher ([EMAIL PROTECTED]). This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html>. --- NEW FILE: Changes --- Revision history for Perl extension AxWindow. 0.07 03/02/2004 - Correct GetOLE() method when using PAR and PerlApp. 0.06 28/09/2003 - Rewrite creation method (Remove AttachControl method). - No more need to call Release Method before exit. - Correct bug in GetPropertyInfo with VARTYPE property. - Correct -heigth option. - Update and add samples. 0.05 15/10/2002 - Add GetOLE method (return a Win32::OLE object of Hosted ActiveX Control). - Add TestOle.pl Sample. 0.04 14/09/2002 - Add indexed property support. - Change code organisation (Invoke method, CProperty child of CMethod). - Add MSFlexGrid Sample. 0.03 30/05/2002 - Add VARTYPE property support. - Add output parameter for event support. - Accept control without event. - Correct DHTMLEdit.pm wrapper class. 0.02 25/03/2002 - Correct ReadOnly value for Properties. - Add =value for Enum string list for Properties. - Test ReadOnly attribut in SetProperty. - SetProperty handle Enum property by value or string constant. - Add a Release method for clean ActiveX reference before window destroy. - Manage VT_USERDEFINED as enum in CallMethod. - Add some documentation (sorry for my english ;-). - Add DHTML Edit sample (basic and a wrapper class). 0.01 22/03/2002 - original version; created by h2xs 1.19 - ActiveX control information (Properties, Metods, Events). - Set/Get property. - Call a Method. - Event Support. - Support of basic variant type. --- NEW FILE: TYPEMAP --- TYPEMAP CContainer* T_CONTAINER HWND T_HANDLE HMENU T_HANDLE HICON T_HANDLE HCURSOR T_HANDLE HBITMAP T_HANDLE HFONT T_HANDLE HGDIOBJ T_HANDLE HIMAGELIST T_HANDLE HDC T_HANDLE HBRUSH T_HANDLE HPEN T_HANDLE HTREEITEM T_IV LONG T_IV LPCTSTR T_PV LPTSTR T_PV DWORD T_IV UINT T_IV BOOL T_IV WPARAM T_IV LPARAM T_IV LRESULT T_IV HINSTANCE T_IV COLORREF T_COLOR LPCSTR T_PV HENHMETAFILE T_IV FLOAT T_FLOAT LPVOID T_PV HACCEL T_IV ################################################################################ INPUT T_HANDLE if(SvROK($arg)) { if(hv_fetch((HV*)SvRV($arg), \"-handle\", 7, 0) != NULL) $var = ($type) SvIV(*(hv_fetch((HV*)SvRV($arg), \"-handle\", 7, 0))); else $var = NULL; } else $var = ($type) SvIV($arg); T_COLOR $var = SvCOLORREF($arg); T_CONTAINER $var = ($type) SvIV(*(hv_fetch((HV*)SvRV($arg), \"-CContainer\", 11, 0))); ################################################################################ OUTPUT T_HANDLE sv_setiv($arg, (IV) $var); T_COLOR sv_setiv($arg, (IV) $var); --- NEW FILE: AxWindow.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Win32::GUI::AxWindow - Perl extension for Hosting ActiveX Control in Win32::GUI</title> <link rev="made" href="mailto:" /> </head> <body style="background-color: white"> <p><a name="__index__"></a></p> <!-- INDEX BEGIN --> <ul> <li><a href="#name">NAME</a></li> <li><a href="#synopsis">SYNOPSIS</a></li> <li><a href="#description">DESCRIPTION</a></li> <ul> <li><a href="#axwindow">AxWindow</a></li> <li><a href="#property">Property</a></li> <li><a href="#method">Method</a></li> <li><a href="#event">Event</a></li> <li><a href="#win32::ole">Win32::OLE</a></li> </ul> <li><a href="#author">AUTHOR</a></li> <li><a href="#see_also">SEE ALSO</a></li> </ul> <!-- INDEX END --> <hr /> <p> </p> <h1><a name="name">NAME</a></h1> <p>Win32::GUI::AxWindow - Perl extension for Hosting ActiveX Control in Win32::GUI</p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <pre> use Win32::GUI; use Win32::GUI::AxWindow;</pre> <pre> # Main Window $Window = new Win32::GUI::Window ( -name => "Window", -title => "Win32::GUI::AxWindow test", -post => [100, 100], -size => [400, 400], );</pre> <pre> # 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], );</pre> <pre> # Register some event $Control->RegisterEvent("StatusTextChange", sub { $self = shift; $eventid = shift; print "Event : ", @_, "\n"; } );</pre> <pre> # Call Method $Control->CallMethod("Navigate", '<a href="http://www.perl.com/">http://www.perl.com/</a>');</pre> <pre> # Event loop $Window->Show(); Win32::GUI::Dialog();</pre> <pre> # Main window event handler</pre> <pre> sub Window_Terminate {</pre> <pre> return -1; }</pre> <pre> sub Window_Resize {</pre> <pre> if (defined $Window) { ($width, $height) = ($Window->GetClientRect)[2..3]; $Control->Move (0, 0); $Control->Resize ($width, $height); } }</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p> </p> <h2><a name="axwindow">AxWindow</a></h2> <dl> <dt><strong><a name="item_new"><code>new</code> (...)</a></strong><br /> </dt> <dd> <pre> Create a new ActiveX window.</pre> </dd> <dd> <pre> options :</pre> </dd> <dd> <pre> -parent => parent window (Required) -name => window name (Required) -size => window size [ width, heigth ] -pos => window pos [ left, top ] -width => window width -height => window height -left => window left -top => window top -control => clisd (see below) (Required).</pre> </dd> <dd> <pre> clsid is a string identifier to create the control. Must be formatted in one of the following ways:</pre> </dd> <dd> <pre> - A ProgID such as "MSCAL.Calendar.7" - A CLSID such as "{8E27C92B-1264-101C-8A2F-040224009C02}" - A URL such as "<a href="http://www.microsoft.com"">http://www.microsoft.com"</a>; - A reference to an Active document such as '<a href="file://Documents/MyDoc.doc">file://Documents/MyDoc.doc</a>' - A fragment of HTML such as "MSHTML:<HTML><BODY>This is a line of text</BODY></HTML>" Note "MSHTML:" must precede the HTML fragment so that it is designated as being an MSHTML stream.</pre> </dd> <dd> <pre> styles:</pre> </dd> <dd> <pre> -visible => 0/1 -tabstop => 0/1 -hscroll => 0/1 -vscroll => 0/1</pre> </dd> <dd> <pre> -style, -addstyle, -pushstyle, -remstyle, -popstyle -exstyle, -exaddstyle, -expushstyle, -exremstyle, -expopstyle</pre> </dd> <dd> <pre> Default style is : WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPCHILDREN</pre> </dd> <dt><strong><a name="item_release"><code>Release</code> ()</a></strong><br /> </dt> <dd> <pre> If have crash when exiting, call this function before all the window are destroy (before Win32::GUI::Dialog(); exit). Generaly, call this function in the Window_Terminate handle.</pre> </dd> </dl> <p> </p> <h2><a name="property">Property</a></h2> <dl> <dt><strong><a name="item_enumpropertyid"><code>EnumPropertyID</code> ()</a></strong><br /> </dt> <dd> <pre> Return a list of all the Property ID of the control.</pre> </dd> <dt><strong><a name="item_enumpropertyname"><code>EnumPropertyName</code> ()</a></strong><br /> </dt> <dd> <pre> Return a list of all the Property name of the control.</pre> </dd> <dt><strong><a name="item_getpropertyinfo"><code>GetPropertyInfo</code> (ID_or_Name)</a></strong><br /> </dt> <dd> <pre> Return a hash with information about the Property from ID or Name.</pre> </dd> <dd> <pre> Hash entry : -Name => Property Name. -ID => Property ID. -VarType => Property Type (Variant type). -EnumValue => A formated string of enum value ( enum1=value1,enum2=value2,... ). -ReadOnly => Indicate if a property can only be read. -Description => Property Description. -Prototype => Prototype</pre> </dd> <dt><strong><a name="item_getproperty"><code>GetProperty</code> (ID_or_Name, [index, ...])</a></strong><br /> </dt> <dd> <pre> Get property value. For indexed property, add index list.</pre> </dd> <dt><strong><a name="item_setproperty"><code>SetProperty</code> (ID_or_Name, [index, ...], value)</a></strong><br /> </dt> <dd> <pre> Set property value For indexed property, add index list before value.</pre> </dd> </dl> <p> </p> <h2><a name="method">Method</a></h2> <dl> <dt><strong><a name="item_enummethodid"><code>EnumMethodID</code> ()</a></strong><br /> </dt> <dd> <pre> Return a list of all the Method ID of the control.</pre> </dd> <dt><strong><a name="item_enummethodname"><code>EnumMethodName</code> ()</a></strong><br /> </dt> <dd> <pre> Return a list of all the Method name of the control.</pre> </dd> <dt><strong><a name="item_getmethodinfo"><code>GetMethodInfo</code> (ID_Name)</a></strong><br /> </dt> <dd> <pre> Return a hash with information about the Method from ID or Name.</pre> </dd> <dd> <pre> Hash entry : -Name => Method Name. -ID => Method ID. -Description => Method Description. -Prototype => Method Prototype.</pre> </dd> <dt><strong><a name="item_callmethod"><code>CallMethod</code> (ID_or_Name, ...)</a></strong><br /> </dt> <dd> <pre> Invoke a method of an ActiveX control.</pre> </dd> </dl> <p> </p> <h2><a name="event">Event</a></h2> <dl> <dt><strong><a name="item_enumeventid"><code>EnumEventID</code> ()</a></strong><br /> </dt> <dd> <pre> Return a list of all the Event ID of the control.</pre> </dd> <dt><strong><a name="item_enumeventname"><code>EnumEventName</code> ()</a></strong><br /> </dt> <dd> <pre> Return a list of all the Event Name of the control.</pre> </dd> <dt><strong><a name="item_geteventinfo"><code>GetEventInfo</code> (ID_or_Name)</a></strong><br /> </dt> <dd> <pre> Return a hash with information about the Event from ID or Name.</pre> </dd> <dd> <pre> Hash entry : -Name => Method Name. -ID => Method ID. -Description => Method Description. -Prototype => Method Prototype.</pre> </dd> <dt><strong><a name="item_registerevent"><code>RegisterEvent</code> (ID_or_Name, Callback)</a></strong><br /> </dt> <dd> <pre> Associate a Callback for an ActiveX Event.</pre> </dd> </dl> <p> </p> <h2><a name="win32::ole">Win32::OLE</a></h2> <dl> <dt><strong><a name="item_getole"><code>GetOLE</code> ()</a></strong><br /> </dt> <dd> <pre> Return a Win32::OLE object of Hosted ActiveX Control.</pre> </dd> <dd> <pre> You MUST add use Win32::OLE in your script.</pre> </dd> </dl> <p> </p> <hr /> <h1><a name="author">AUTHOR</a></h1> <pre> Laurent Rocher ([EMAIL PROTECTED]) HomePage :<a href="http://perso.club-internet.fr/rocherl/Win32GUI.html">http://perso.club-internet.fr/rocherl/Win32GUI.html</a></pre> <p> </p> <hr /> <h1><a name="see_also">SEE ALSO</a></h1> <pre> Win32::GUI</pre> </body> </html>