in reply to Win32::GUI Popup Menu no callback

You could try using a callback event when calling TrackPopupMenu(), like so:

$window->TrackPopupMenu( $menu->{mymenu}, 20, 20, 0, 0, 0, 0, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_LEFTBUTTON, \&callback ); sub callback { my ($self, $message, $wParam, $lParam) = @_; # Process message here... return 1; }

See the docs for more info.

Replies are listed 'Best First'.
Re^2: Win32::GUI Popup Menu no callback
by Anonymous Monk on Jun 28, 2010 at 10:05 UTC
    That is workable (if you define/import TPM_LEFTALIGN | TPM_TOPALIGN | TPM_LEFTBUTTON,), or call  Win32::GUI::Dialog(); as per Win32::GUI::Tutorial::Part1

      It depends on what you are doing, but in most cases, I can't see why you wouldn't be using Win32::GUI::Dialog() anyway.

      Here is the above code modified to use Win32::GUI::Dialog():

      use strict; use Win32::GUI (); $|=1; my $window = Win32::GUI::Window->new(); my $menu = new Win32::GUI::Menu( "mymenu" => "mymenu", " > foo" => "foo", " > bar" => { -name => 'bar', -onClick => \&bar_onclickcallback + }, ); print "Start Tracking\n"; $window->TrackPopupMenu($menu->{mymenu}, 20,20); Win32::GUI::Dialog(); # enter Dialog() here print "Done Tracking, if it didn't print 'GOTCHA ...' then no callback +?\n"; sub bar_onclickcallback { print "GOTCHA bar\n"; return -1; # return -1 here to exit from dialog loop } sub foo_Click { print "GOTCHA foo\n"; return -1; # return -1 here to exit from dialog loop }