Here is a repost of how to do it, written by Jason Bingham.

************************************************************************

From: Jason Bingham [EMAIL PROTECTED]
Sent: 27 August 2001 03:26
To: 'perl-win32-gui-users@lists.sourceforge.net'
Subject: RE: [perl-win32-gui-users] RE: NotifyIcon - How to Change icon
pr ogrammatically

> 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 ==




> -----Original Message-----
> From: Jeff Omick [mailto:[EMAIL PROTECTED]
> Sent: 21 December 2001 21:36
> To: perl-win32-gui-users@lists.sourceforge.net
> Subject: [perl-win32-gui-users] changing systray icon?
> 
> 
> 
> Is is posible to change the systray icon?  I got the 
> $main->ChangeIcon($icon)
> to change the upper left hand corner of the main window to change but 
> I would like to change the systray icon if that is 
> availble... A simple 
> example would be very much appreciated...
> 
> thanks in advance
> Jeff Omick
> http://msetimon.sourceforge.net
> 
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> 

Reply via email to