# A simple Perl program to show the fly-out menu problem. # Uses and requires use strict; use Win32::GUI(); my $win_main; # Pointer to the main window. my $menu_popup; # Pointer to the menu that should appear. my $icn; # Ptr to an icon. my $debug = 1; # Debug flag # Windows event handlers go here. sub Main_Terminate { $win_main->NI->Remove(); -1; } sub NI_RightClick() { print "NI_RightClick event called.\n" if ($debug); $win_main->TrackPopupMenu($menu_popup, Win32::GUI::GetCursorPos()); } # Main program start # First, build everything # Create the context menu to be displayed when the icon is right-clicked # Translate the menu $menu_popup = Win32::GUI::Menu->new( "&File" => "File", ">E&xit" => { -name => "File_Exit", -onClick => sub{-1} }, ); # Create the main window - this will not be displayed. $win_main = Win32::GUI::Window->new( -name => 'Main', -menu => $menu_popup, -width => 1, -height => 1, -text => '', ); # Create an icon that will appear in the system tray. Pick any icon you want. $icn = new Win32::GUI::Icon("c:/Windows/System32/PerfCenterCpl.ico"); # Add the icon to the window. $win_main->AddNotifyIcon( -name => 'NI', -icon => $icn, -tip => 'Thi is a notify fly-out/tool-tip thing.', -balloon => 0, ); # Enter the Windows message loop Win32::GUI::Dialog();