This does not work. But I did discover that a DialogBox closes on ESC,
So if you want to prevent this, make it a Window and you don't need
An accelerator object.

-----Original Message-----
From: Eric Hansen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 11, 2004 4:46 PM
To: 'perl-win32-gui-users@lists.sourceforge.net'
Subject: RE: ESC Key, How to stop program termination?

$A = new Win32::GUI::AcceleratorTable(
        "Esc"   => "Esc");

$M = new Win32::GUI::Menu(
    "&File"     => "File",
    " > E&xit"  => "Exit");

$W = new Win32::GUI::Window (
    -title    => "Some Title",
    -menu     => $M,
    -accel    => $A,
    -name     => "Window",
    -left     => 125, 
    -top      => 25, 
    -width    => 550, 
    -height   => 580);

sub Esc_Click {
   my $question  = "Do you wish to Exit the Program?";
   my $ans   = Win32::GUI::MessageBox($W,$question,"Some Title",36,);
   #-- 6=yes, 7=no
   if ($ans == 7) {return;}
   return -1;   #-- stops event handler
}

-----Original Message-----
From: Eric Hansen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 11, 2004 4:26 PM
To: 'perl-win32-gui-users@lists.sourceforge.net'
Subject: ESC Key, How to stop program termination?

My Win32::GUI program terminates when the ESC key is pressed.
I only want my users to be able to mouse click File->Exit, or
The X in the upper right corner of the window/dialogbox to end
The program.  How can the ESC key be trapped?   Thanks,  -Eric
 
Exit_Click {
   return -1;
}
Window_Terminate {
   return -1;
}



Reply via email to