应用程序常常在最小化时保留系统托盘的图标。在Perl的win32::GUI模块中是这样实现的。
在最小化时建立托盘图标,还原时删除托盘图标。(1.ico是icon文件,自己随便找个图标文件命名成1.ico就行了)
#!perl
#系统托盘图标;
use strict; use warnings; use Win32::GUI();
#make a window;
my $main_window = new Win32::GUI::Window( -name => "main_window", -title => "Window", -size => [300, 100], -resizable => 0 ) or die "MainWindow $!"; $main_window->Center();
our $icon = new Win32::GUI::Icon('1.ico'); our $ni;
$main_window->Show(); Win32::GUI::Dialog(); #icon;
sub main_window_Minimize { $main_window->Disable(); $main_window->Hide();
$ni = $main_window->AddNotifyIcon( -name => "NI", -icon => $icon, -tip => "icon", ); return 1; } sub NI_Click { $main_window->Enable(); $main_window->Show(); $ni->Remove(); return 1; }
|
(2009-20-16)
by banban
阅读(1054) | 评论(0) | 转发(0) |