Hi there ... Do the following: - Load the script - press Alt+F4 - click on "No" and the MsgBox "Bug..." appears and after that the window to save a file. But this shouldn't be the case. If you click on "No" my credits should be displayed and the program should exit. I don't know what is wrong in that code ..... I worked the whole evening and couldn't find a solution :-( <code> use Win32; use Win32::GUI; use Win32::FileOp; $version = "YATE 0.0.2-dev"; $Font_Buttons = new Win32::GUI::Font( -name => "MS Sans Serif", -height => 15, ); $Font_Editor = new Win32::GUI::Font( -name => "Courier New", -height => 16, ); $Menu = Win32::GUI::MakeMenu( "&File" => "File", "> &New" => "FileNew", "> -" => 0, "> &Open" => "FileOpen", "> &Save" => "FileSave", "> &Save As" => "FileSaveAs", "> -" => 0, "> &Exit" => "Exit", ); $Window = new Win32::GUI::Window( -name => "Window", -text => "YATE - Yet Another Text Editor", -width => 700, -height => 500, -left => 100, -top => 100, -menu => $Menu, -minsize => [400, 200], ); $Window->AddStatusBar( -name => 'Status', -text => $version, ); $FileNew = $Window->AddButton( -text => 'New', -name => 'FileNew', -font => $Font_Buttons, ); $FileOpen = $Window->AddButton( -text => 'Open', -name => 'FileOpen', -font => $Font_Buttons, -left => '38', ); $FileSave = $Window->AddButton( -text => 'Save', -name => 'FileSave', -font => $Font_Buttons, -left => '80', ); $FileSaveAs = $Window->AddButton( -text => 'Save As', -name => 'FileSaveAs', -font => $Font_Buttons, -left => '121', ); $Editor = $Window->AddRichEdit( -name => 'Schreibfeld', -top => 23, -width => $Window->ScaleWidth, -height => $Window->ScaleHeight-23-$Window->Status->Height, -exstyle => WS_EX_CLIENTEDGE, -style => WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, -font => $Font_Editor, ); $FILEOPEN = $ARGV[0] or $0; if($FILEOPEN eq "") { ### start with empty editor-window } else { StartLoadFile($FILEOPEN); } $Window->Show(); Win32::GUI::Dialog(); sub Window_Resize { my $Width = $Window->ScaleWidth; my $Height = $Window->ScaleHeight; $Window->Schreibfeld->Resize($Width, $Height-23-$Window->Status->Height); $Window->Status->Resize($Width, $Window->Status->Height); $Window->Status->Move(0, $Window->ScaleHeight-$Window->Status->Height); } sub Exit_Click { &Window_Terminate; } sub Window_Terminate { MsgBox("Save", "Do you want to save?", 36); if($return[$result] = '6') { if($files[0] eq undef) { MsgBox("Bug....", "This MsgBox shouldn't be displayed!!!", 48); &FileSaveAs_Click; MsgBox("YATE", "$version Copyright (c) 2000\n by Jens Luedicke \<jens\@irs-net.com\>", 32); return -1; } else { rename("$files[0]", "$files.bak"); $Editor->Save("$files[0]", "1"); MsgBox("YATE", "$version Copyright (c) 2000\n by Jens Luedicke \<jens\@irs-net.com\>", 32); return -1; } } elsif($return[$result] = '7') { MsgBox("YATE", "$version Copyright (c) 2000\n by Jens Luedicke \<jens\@irs-net.com\>", 32); return -1; } } sub FileNew_Click { MsgBox("Save", "Do you want to save?", 36); if($return[$result] = '6') { if($files[0] eq undef) { &FileSaveAs_Click; $Editor->Load(" ", "1"); } else { rename("$files[0]", "$files.bak"); $Editor->Save("$files[0]", "1"); $Editor->Load(" ", "1"); } } elsif($return[$result] = '7') { $Editor->Load(" ", "1"); } } sub FileOpen_Click { $handle = GetWindowHandle(); @files = OpenDialog(title => "Open", filters => ['Text Files (*.txt)' => '*.txt', 'All Files (*.*)' => '*.*'], defaultfilter => 1, handle => $handle, options => OFN_ALLOWMULTISELECT | OFN_EXPLORER); $Editor->Load("$files[0]", "1"); return; } sub FileSave_Click { if($files[0] eq undef) { &FileSaveAs_Click; } else { $Editor->Save("$files[0]", "1"); return; } } sub FileSaveAs_Click { $handle = GetWindowHandle(); @files = OpenDialog(title => "Save", filters => ['Text Files (*.txt)' => '*.txt', 'All Files (*.*)' => '*.*'], defaultfilter => 1, handle => $handle, options => OFN_ALLOWMULTISELECT | OFN_EXPLORER); if ($files[0] eq undef) { # Cancel return; } else { $Editor->Save("$files[0]", "1"); return; } } sub StartLoadFile { $Editor->Load("$FILEOPEN", "1"); } sub MsgBox { my ($caption, $message, $icon_buttons) = @_; my @return = qw/- Ok Cancel Abort Retry Ignore Yes No/; my $result = Win32::MsgBox($message, $icon_buttons, $caption); return $return[$result]; } </code>