Hi, Main reason why Win32::GUI::MenuItem isn't passed to NEM handler, it's because this object it's not stored anywhere when using AddMenuButton/AddMenuItem (memory managment reason).
When you use Win32::GUI::MakeMenu, a perl tree representation of your menu it's create and store in your Win32::GUI::Menu object. But, we can't retreive this tree from event handling. Win32::GUI::Window is pass as parameter because generaly a menu interact with it's associate window. We can add menu name as second parameter if exist easily but not more. Laurent. > Hi, > > I was wondering if there is any reason for MenuItem objects to forward the > main Window class as their first argument to NEM subs and not the MenuItem > object itself? > > I.e. > > <pre> > > use Win32::GUI; > my $M = new Win32::GUI::Menu(); > my $B = $M->AddMenuButton(-text=>'B'); > my $I = $B->AddMenuItem(-text=>'I', -onClick=>sub { print ref($_[0])."\n"}); > my $W = new GUI::Window(-height=>60,-width=>100,-menu=>$M); > $W->Center(); > $W->Show(); > Win32::GUI::Dialog; > > </pre> > > Clicking the MenuItem 'I' returns a reference to a "Win32::GUI::Window" but > not a "Win32::GUI::MenuItem" object. > > If not, how hard would it be to change this? Where is this coded within the > XS scheme of things? > > Blair__________________________________________ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >