wardmw has asked for the wisdom of the Perl Monks concerning the following question:
I have a program that creates an icon in the system tray of Windows 7 and displays a tool-top when the mouse is hovered over it.
The issue comes when the user right-clicks the icon, it should display a menu but instead I get a thin sliver of a window, like a menu but with no text (the word "File" in this case). Something is there as if I click where "File" should be I get a sub-menu, no problem, I just cannot see the word "File".
I have worked through the articles elsewhere on Perlmonks but to no avail, even the "traymon.pl" code has this same problem, at least on my machine anyway.
The following code shows this exact problem, feel free to change the icon path to any .ICO file you have spare, or leave it blank and right-click in the blank space that will appear in your system tray.
I would appreciate your thoughts on this, or even a simple test to see if this code works on your system (in which case it is environmental, but I still have no clue as to what it might be!)# 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::GetCursorPo +s()); } # Main program start # First, build everything # Create the context menu to be displayed when the icon is right-click +ed # 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 yo +u 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();
|\/|artin
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::GUI won't display an NI menu properly
by ww (Archbishop) on Aug 03, 2015 at 14:04 UTC | |
by wardmw (Acolyte) on Aug 03, 2015 at 17:19 UTC | |
|
Re: Win32::GUI won't display an NI menu properly
by wardmw (Acolyte) on Aug 03, 2015 at 17:53 UTC | |
|
Re: Win32::GUI won't display an NI menu properly
by anonymized user 468275 (Curate) on Aug 03, 2015 at 15:30 UTC | |
by wardmw (Acolyte) on Aug 03, 2015 at 16:58 UTC |