Hi.

I've got a script that adds a MenuItem to my Window menu for each
MDIChild I create.  However, I can't figure out how to get the OnClick
event for each window to act on the correct window.

Here's a code snippet:
my $sid = $tray->{SID}; # ID to be used in window title
 my $twin = trayWindow($tray); # returns an MDI Child window

 $twin->Show();

 $menu->{"&Window"}->AddMenuItem(
                            -name => $sid,
                            -text => $sid,
                            -onClick =>sub 
{Win32::GUI::BringWindowToTop($twin); return 1;}
                           );

As it's written, if I click any of the added items in the menu, the
last window I created gets brought to the top.

Can anyone tell me how to get the anonymous subroutine refernce I'm
creating in the -onClick line to use the value of $twin it's got when
I create the subroutine, rather than the value at runtime?

Is there a way for an onClick event to get the name of the actual
menuItem that was clicked rather than just a reference to the Window
that contains the menu, which is fairly useless?


--
Geoffrey Spear
http://www.geoffreyspear.com/

Reply via email to