in reply to How do you toggle the system tray icon using Win32::Gui?
Let me know if it works - it might just be a funny bug on my machine. FYI. Win32::GUI version is 0.0.434, I'm running ActivePerl build 629 on Win2k.# Test Icons from http://www.royaltyfreeart.com/favicons.html use Win32::GUI; use strict; my $okIcon = new Win32::GUI::Icon("info1.ico"); my $badIcon = new Win32::GUI::Icon("info2.ico"); my $lastState = 1; # start off ok my $iconCounter = 1; # maintain an icon count my $main = Win32::GUI::Window->new(); DoIcon($okIcon, $iconCounter); # set the initial icon while(1){ if (int rand 2) # Yeah, This is how I do system monitoring! { unless ($lastState) { # Everything's ok now - it wasn't last time round changeIcon($okIcon); $lastState = 1; } } else { if ($lastState) { # Something's gone down - everything was ok last check changeIcon($badIcon); $lastState = 0; } } sleep(5); } sub DoIcon { my ($icon, $id) = @_; $main->AddNotifyIcon( -name => "Tray", -tip => $id, -icon => $icon, -id => $id, ); } sub changeIcon { my $icon = shift; DoIcon($icon, $iconCounter); # Clear the old Icon DoIcon($icon, ++$iconCounter); # Set the new one and incriment coun +ter }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How do you toggle the system tray icon using Win32::Gui?
by jplindstrom (Monsignor) on Oct 02, 2001 at 05:32 UTC |