package Tray; use Win32::GUI; use Alias qw(attr); use vars qw($BILD $TEXT $CONTROLLER $WIN32 @FUNKTIONEN); my %felder = ( BILD => undef, TEXT => undef, CONTROLLER => undef, WIN32 => undef, FUNKTIONEN => [], ); sub new { my $that = shift; my $bildPfad = shift; my $text = shift; $CONTROLLER = shift; my $class = ref($that)||$that; my $self = { %felder, }; bless $self, $class; initWin($bildPfad, $text); return $self; } sub initWin { my $bildPfad = shift; my $text = shift; my $mw; $WIN32 = new Win32::GUI::DialogBox( -width => 0, -height => 0, -name => 'TrayWindow' ); my $icon_nr = 0; my @icon = (new Win32::GUI::Icon( $bildPfad )); new Win32::GUI::NotifyIcon( $WIN32, -name => "Notify", -id => 255, -icon => $icon[$icon_nr], -tip => $text, -onClick => sub { clicked(); }, #-onRightClick => sub { context_menu($mw, $main_win32); } ); -onRightClick => sub { context_menu(); } ); } #Rechtsklickmenü aufrufen sub context_menu { #my $mw = shift; #my $popup = $mw->Menu( Name => 'popupMenu', -tearoff => 0 ); $popup->command( -label => 'Verbindung trennen', -command => sub { &clean_exit } ); $popup->Popup( -popover => 'cursor', -popanchor => 'nw' ); return 1; } #Hauptfenster verstecken / anzeigen sub clicked { $CONTROLLER->tray_clicked(); } #Icon verändern sub toggle_icon { $icon_nr = !$icon_nr; Win32::GUI::NotifyIcon::Modify( $WIN32, -id => 255, -icon => $icon[$icon_nr], -tip => ' verändertes Icon ' ); } #TrayIcon erntfernen und Beenden sub clean_exit { $WIN32->Notify->Delete( -id => 255 ); CORE::exit; } 1;