Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

System Tray Icon Disappears

by vaguy (Initiate)
on Mar 12, 2014 at 00:07 UTC ( #1077943=perlquestion: print w/replies, xml ) Need Help??
vaguy has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl application that presents an icon in the system tray (Windows 8 calls it the notification area). I've seen it disappear once or twice but the app continues to run). I'm assuming this is because of an Explorer restart or crash. My research suggests I need to listed for a 'TaskbarCreated' message via a RegisterWindowMessage API call. I haven't seen any code snippets in perl that might get me going. Can anybody help me out here?

Replies are listed 'Best First'.
Re: System Tray Icon Disappears
by Anonymous Monk on Mar 12, 2014 at 00:29 UTC
      I'm using Active Perl with Tk and Win32::GUI().
      Calls are to Win32::GUI::Window->new and then to AddNotifyIcon.
      Code looks like this:
      sub SetupSystray{ $TrayIcon = new Win32::GUI::Icon('WebCam.ico'); $TrayWinHidden = Win32::GUI::Window->new( -name => 'TrayWindow', -text => 'TrayWindow', -width => 20, -height => 20, -visible => 0, ); $TrayNotify = $TrayWinHidden->AddNotifyIcon( -name => "WebCam-App", -icon => $TrayIcon, -tip => "WebCam", -balloon_icon => "info", -onRightClick => \&TrackTrayMenu, -onClick => \&ToggleProgWindow, ); $TrayMenu = Win32::GUI::Menu->new( "" => "Options", ">WebCam" => {-name => "WebCam"}, ">-" => 0, ">Open/Close" => {-name => "ToggleProg", -onClick => \&To +ggleProgWindow,-default => 1}, ">-" => 0, ">Exit" => {-name => "Exit",-onClick => \&CloseDownFrom +Tray} ) or prtFTL "Failed to create Tray Menu $!"; } sub CloseDownFromTray{ $mw->destroy; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1077943]
Front-paged by bulk88
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2018-03-25 01:30 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (299 votes). Check out past polls.