Sergey Cherniyenko wrote:
1. On each right click on tray icon I get following warnings
Use of uninitialized value in subroutine entry at D:\perl_projects\exrc1.pl
line 68.
Argument "-notifyicons" isn't numeric in subroutine entry at
D:\perl_projects\exrc1.pl line 68.
Argument "_NotifyIcon100" isn't numeric in subroutine entry at
D:\perl_projects\exrc1.pl line 68.
Argument "-notifyicons" isn't numeric in subroutine entry at
D:\perl_projects\exrc1.pl line 68.
I broke TrackPopupMenu in the V1.02 release. Please see an earlier
message to this list for work-arounds:
http://sourceforge.net/mailarchive/message.php?msg_id=12416384
2. Popup menu onClick handlers is not called.
You are missing the '-' on your onClick parameter definitions.
This works for me:
#!perl -w
use strict;
use warnings;
use Win32::GUI;
my $mw = Win32::GUI::Window->new(
-name => 'mw',
-size => [400, 400],
-pos => [200, 200],
-title => "FormsTest",
-onTerminate => \&DoExit,
-onMinimize => \&DoHideMe,
) or die "Creating mw failed";
my $popupMenu = Win32::GUI::Menu->new(
"Options" => "Options",
">ShowMe" => {-name => "ShowMe", -onClick => \&DoShowMe},
">HideMe" => {-name => "HideMe", -onClick => \&DoHideMe},
">Exit" => {-name => "Exit", -onClick => \&DoExit}
) or die "Creating Menu failed";
my $icon_no = Win32::GUI::Icon->new('no!.ico') or die "Creating Icon
failed";
my $icon_yes = Win32::GUI::Icon->new('yes!.ico') or die "Creating Icon
failed";
my $ni = $mw->AddNotifyIcon(
-icon => $icon_yes,
-id => 100,
-onClick => sub{$mw->Enable(); $mw->Show(); $mw->Restore() if
$mw->IsIconic();},
-onRightClick => \&myTrack,
) or die "Adding notify icon failed";
$mw->Show();
Win32::GUI::Dialog();
exit(0);
sub DoShowMe {
$mw->Enable() unless $mw->IsEnabled();
$mw->Show() unless $mw->IsVisible();
$mw->Restore() if $mw->IsIconic();
$mw->BringWindowToTop();
$mw->SetActiveWindow();
return 1;
}
sub myTrack {
$mw->Enable();
$mw->TrackPopupMenu($popupMenu->{Options});
return 1;
}
sub DoHideMe {
$mw->Hide() if $mw->IsVisible();
$mw->Disable() if $mw->IsEnabled();
return 1;
}
sub DoExit {
return -1;
}