> How can you change the -icon after it already exists in the
> system tray?
Don't know how supported it is but this is what I had to do is call
Win32::GUI::NotifyIcon::Modify directly (it is located in the GUI.xs file
for those with the source). Example works off the click on the tray icon.
Don't forget to get the -id bit the same across all calls.... Other problem
I came across was the limit of 63 chars for the -tip windows doesn't like it
and the good doctor will come and visit if you make it too long.
JB
== Begin Perl Code ==
use Win32::GUI;
my $IconMode = 1;
my $icoEna = new Win32::GUI::Icon("DateTime.ico");
my $icoDis = new Win32::GUI::Icon("DisabledDateTime.ico");
my $Trace = 1;
my $win = Win32::GUI::Window->new(
-name => 'WIN',
-text => 'Recorder',
-width => 200,
-height => 200,
);
my $ni = Win32::GUI::NotifyIcon->new(
$win,
-name => "NI",
-id => 1,
-icon => $icoEna,
-tip => "Recording",
);
$win->Enable();
$win->Show();
Win32::GUI::Dialog();
sub WIN_Terminate {
print "$0: ".(caller(0))[3]."::Start\n" if ($Trace);
-1;
}
sub NI_Click {
print "$0: ".(caller(0))[3]."::Start\n" if ($Trace);
if ($IconMode) {
$IconMode = 0;
Win32::GUI::NotifyIcon::Modify(
$win,
-id => 1,
-icon => $icoDis,
-tip => "Not Recording",
);
} else {
$IconMode = 1;
Win32::GUI::NotifyIcon::Modify(
$win,
-id => 1,
-icon => $icoEna,
-tip => "Recording",
);
}
1;
}
== End Perl Code ==