Win32::GUI menus are 2 pixels wide!

Posted by wardmw on 2015-07-31 05:08

Hi all,

Has anyone seen this problem? I have created a context or pop-up menu but when I display it it is very narrow (OK, maybe more than two pixels but not wide enough to see any menu text).

I am writing a perl program that has no window, it appears only in the Windows 7 status bar to the bottom right of the screen. When you hover over its icon a tooltip is displayed with various bits of text. This all works fine and dandy except I need to be able to display a menu for "Exit" and "About" options.

The menu is created thus:

$menu_popup = Win32::GUI::Menu->new(
"&File"     =>            "File",
        ">E&xit"           => { -name => "File_Exit",  -onClick => sub{-1} },
        ">&About"          => { -name => "Help_About", -onClick => \&OnAbout },

The main window is created but never displayed:

$win_main = Win32::GUI::Window->new(
        -name   => 'Main',
        -menu   => $menu_popup,
        -width  => 1,
        -height => 1,
        -text   => '',

and the Notify Icon is created like so:

        -name           => 'NI',
        -icon            => get_defaulticon(),
        -tip             => '',
        -balloon         => 0,

The tooltip text gets modified elsewhere,

When the user right-clicks the NI this event occurs:

sub NI_RightClick() {
        print "NI_RightClick event called.\n" if ($debug);

I know it happens because I see the debug text and the menu is displayed, just very narrow. If I move the pointer to where "File" should be I get a fly-out showing the "Exit" and "About" options so that works fine, it's merely the initial menu display that is the problem.

Any suggestions as to how to get a context menu to display properly from a Notify icon?

Thanks for reading,