A few days ago I was building an application, where I had embedded an 
Internet Explorer axwindow and created a menu.  Unfortunately, I could 
not use the standard shortcut keys, like Ctrl-C (Copy), Ctrl-X (Cut), Ctrl-
V (Paste), etc.

Thanks to Jez White's recommendation to examine the AxWindow 
sample apps (available in the source code download), I was able to add 
the shortcuts that I needed, except for the most important one, tabbing 
through form fields.  Since many of us are embedding IE in our apps, 
what seems to be the trend in gui design, I am supplying a sample app, 
below.  Thanks to Laurent Rocher for having created such a great 
example!  Though, in Laurent's example, instead of using 
InternetExplorer, DHTMLEdit was used.

In the process, I believe I have discovered a disparity in win32-
gui/axwindow, or, perhaps, there is a reason for this disparity:  when I 
created my acceleratortable, I could not use the -onClick=> sub {...} 
method.  Instead, I had to create subroutines for each function.  
Further, my accereratortable would not work if my $mainWindow had an 
-on... functions attached to it, like -onTerminate=>sub{...}, -
onResize=>sub{...}, etc.

You can obtain the complete list of "pass-through" OLE commands by 
using your OLE Browser (a component of Activestate's ActivePerl 
release).  Here is where the commands are located:  Microsoft Internet 
Controls->InternetExplorer->OLECMDID.  A complete listing and 
definition of each command is available from 
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/com/htm/oen_a2z_015y.asp. Here is the list, without the definitions:

     OLECMDID_OPEN                   = 1, 
     OLECMDID_NEW                    = 2, 
     OLECMDID_SAVE                   = 3, 
     OLECMDID_SAVEAS                 = 4, 
     OLECMDID_SAVECOPYAS             = 5, 
     OLECMDID_PRINT                  = 6, 
     OLECMDID_PRINTPREVIEW           = 7, 
     OLECMDID_PAGESETUP              = 8, 
     OLECMDID_SPELL                  = 9, 
     OLECMDID_PROPERTIES             = 10, 
     OLECMDID_CUT                    = 11, 
     OLECMDID_COPY                   = 12, 
     OLECMDID_PASTE                  = 13, 
     OLECMDID_PASTESPECIAL           = 14, 
     OLECMDID_UNDO                   = 15, 
     OLECMDID_REDO                   = 16, 
     OLECMDID_SELECTALL              = 17, 
     OLECMDID_CLEARSELECTION         = 18, 
     OLECMDID_ZOOM                   = 19, 
     OLECMDID_GETZOOMRANGE           = 20, 
     OLECMDID_UPDATECOMMANDS         = 21, 
     OLECMDID_REFRESH                = 22, 
     OLECMDID_STOP                   = 23, 
     OLECMDID_HIDETOOLBARS           = 24, 
     OLECMDID_SETPROGRESSMAX         = 25, 
     OLECMDID_SETPROGRESSPOS         = 26, 
     OLECMDID_SETPROGRESSTEXT        = 27, 
     OLECMDID_SETTITLE               = 28, 
     OLECMDID_SETDOWNLOADSTATE       = 29, 
     OLECMDID_STOPDOWNLOAD           = 30, 
     OLECMDID_ONTOOLBARACTIVATED     = 31, 
     OLECMDID_FIND                   = 32, 
     OLECMDID_DELETE                 = 33, 
     OLECMDID_HTTPEQUIV              = 34, 
     OLECMDID_HTTPEQUIV_DONE         = 35, 
     OLECMDID_ENABLE_INTERACTION     = 36, 
     OLECMDID_ONUNLOAD               = 37, 
     OLECMDID_PROPERTYBAG2           = 38, 
     OLECMDID_PREREFRESH             = 39, 
     OLECMDID_SHOWSCRIPTERROR        = 40, 
     OLECMDID_SHOWMESSAGE            = 41, 
     OLECMDID_SHOWFIND               = 42, 
     OLECMDID_SHOWPAGESETUP          = 43, 
     OLECMDID_SHOWPRINT              = 44, 
     OLECMDID_CLOSE                  = 45, 
     OLECMDID_ALLOWUILESSSAVEAS      = 46, 
     OLECMDID_DONTDOWNLOADCSS        = 47, 
     OLECMDID_UPDATEPAGESTATUS       = 48, 
     OLECMDID_PRINT2                 = 49, 
     OLECMDID_PRINTPREVIEW2          = 50, 
     OLECMDID_SETPRINTTEMPLATE       = 51, 
     OLECMDID_GETPRINTTEMPLATE       = 52 
     OLECMDID_PAGEACTIONBLOCKED      = 55,
     OLECMDID_PAGEACTIONUIQUERY      = 56,
     OLECMDID_FOCUSVIEWCONTROLS      = 57,
     OLECMDID_FOCUSVIEWCONTROLSQUERY = 58

Here is my demonstration code:

#########################
use Win32::GUI;
use Win32::GUI::AxWindow;
#use Win32::OLE;

$Menu = Win32::GUI::MakeMenu(
    "&Admin"                    => "&Admin",
    " > &Microsoft"             => "gotoMicrosoft",       
    " > &Adobe"                 => "gotoAdobe",
    " > &Google"                => "gotoGoogle",       
    " > -"                      => 0,
    " > &Edit"                  => "&Edit",
    " > > &Copy\tCtrl-C"        => "EditCopy",
    " > > &Paste\tCtrl-V"       => "EditPaste",
    " > > &Cut\tCtrl-X"         => "EditCut",
    " > > -"                    => 0,       
    " > > &Select All\tCtrl-A"  => "EditSelectAll",
    " > > -"                    => 0,       
    " > > &Delete\tDel"         => "EditDelete",
    );

my $accel=new Win32::GUI::AcceleratorTable(
    "Ctrl-C"    => "EditCopy",
    "Ctrl-V"    => "EditPaste",
    "Ctrl-X"    => "EditCut",
    "Ctrl-A"    => "EditSelectAll",
    "Del"       => "EditDelete",
    );

my $icon = new Win32::GUI::Icon("adim.ico");
my $window_class = new Win32::GUI::Class(
    -name => "Icon",
    -icon => $icon,
    );
    
$desk=Win32::GUI::GetDesktopWindow();
$dw=Win32::GUI::Width($desk);
$dh=Win32::GUI::Height($desk);
$dw=($dw*.9);
$dh=($dh*.9);

$mainWindow = new Win32::GUI::Window (
    -name     => "mainWindow",
    -menu     => $Menu,
    -accel    => $accel,
    -title    => "Testing",
    -pos      => [0, 0],
    -minsize  => [(800*.9), (600*.9)],
    -size     => [$dw, $dh],
    -class    => $window_class,
#    -onResize => sub {
#        $Control->Resize ($mainWindow->ScaleWidth(), $mainWindow-
>ScaleHeight());
#        },
#    -onTerminate => sub {
#        return (-1);
#        },
    );

$Control = new Win32::GUI::AxWindow  (
    -parent  => $mainWindow,
    -name    => "Control",
    -control => "Shell.Explorer.2",
    # -control => "{8856F961-340A-11D0-A96B-00C04FD705A2}",
    -left    => 0,
    -top     => 0,
    -width   => $mainWindow->ScaleWidth(),
    -height  => $mainWindow->ScaleHeight(),
    );

# Call Method
$weblink="http://adobe.com";;
$Control->CallMethod("Navigate", "$weblink");

#$Control->Update();
$mainWindow->Show();
Win32::GUI::Dialog();

sub gotoMicrosoft_Click {
$Control->CallMethod("Navigate", "http://www.microsoft.com";);
    #$OLEControl = $Control->GetOLE();
    #$Control->Navigate("http://www.microsoft.com";);
    }

sub gotoGoogle_Click {
$Control->CallMethod("Navigate", "http://www.google.com";);
    #$OLEControl = $Control->GetOLE();
    #$OLEControl->Navigate("http://www.google.com";);
    }

sub gotoAdobe_Click {
$Control->CallMethod("Navigate", "http://www.adobe,com";);
    #$OLEControl = $Control->GetOLE();
    #$OLEControl->Navigate("http://www.adobe,com";);
    }

sub EditCopy_Click {
    $Control->CallMethod(ExecWB,12,2);
    }

sub EditPaste_Click {
    $Control->CallMethod(ExecWB,13,2);
    }

sub EditCut_Click {
    $Control->CallMethod(ExecWB,11,2);
    }

sub EditSelectAll_Click {
    $Control->CallMethod(ExecWB,17,2);
    }

sub EditDelete_Click {
    $Control->CallMethod(ExecWB,33,2);
    }

sub mainWindow_Terminate {
    return (-1);
    }

###################

As I mentioned earlier, I have not been able to get the TAB key to work.  
This is a vital key, especially when working with a web form, where you 
want the end-user to Tab through sequential form fields.  I hope that 
this bit of brain-candy helps the list.  But, further, I hope that someone 
can tell me/us how to enable the Tab key to tab through form fields.  
Please help!  It's the last piece in my puzzle! :)

Brad Smith

Reply via email to