in reply to Win32::NotifyIcon pop-up menu blues

This should do it. The main window is a global ($winTransformer), and the NotifyIcon control has the name "niTray". You need to have a window, but it doesn't have to be visible.

my $mnuTray = Win32::GUI::MakeMenu( "tray" => "tray", " > &URL" => "mnuTrayUrl", " > > &Fix" => "mnuTrayUrlFix", " > &Format" => "mnuTrayFormat", " > > Remove formatting" => "mnuTrayFormatRemove", " > > Flow" => "mnuTrayFormatFlow", " > &RegExp" => "mnuTrayRegexp", " > > Substitute" => "mnuTrayRegexpSubst", " > -" => 0, " > E&xit" => "mnuTrayExit", ); sub ::niTray_RightClick { my ($x, $y) = Win32::GUI::GetCursorPos(); $winTransformer->TrackPopupMenu($mnuTray->{tray}, $x, $y); return(1); }

/J

Replies are listed 'Best First'.
Re: Re: Win32::NotifyIcon pop-up menu blues
by MZSanford (Curate) on Oct 22, 2001 at 13:39 UTC
    I was so close, but i was missing the offset caused by adding the tray entry in the menu. My output was a 3 pixel wide menu with no text. I added the tray level of the menu, and POOF !. Thanks so much. For the un-imaginitive, here is the code :
    sub Tray_RightClick { print "Right Click\n"; my ($x,$y) = Win32::GUI::GetCursorPos(); my $menu = new Win32::GUI::Menu( "tray" => "tray", " > exit" => "Exit", " > foo" => {-text => "foo", -name => "NI_b", -checked + => 1 }, " > bar" => "NI_b", " > foobar" => "NI_b", ); $main->TrackPopupMenu($menu->{tray}, $x, $y); 1; }

    i had a memory leak once, and it ruined my favorite shirt.