Greetings honoured friars,

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.

# 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();
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!)

|\/|artin


In reply to Win32::GUI won't display an NI menu properly by wardmw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.