Arthur I Schwarz wrote:

I'm have partitioned my program into modules:

[snip]

The window displays correctly.
All the pull down menus display correctly.
Selecting any item in a pull down menu has no effect (the event seems to be
unhandled).

Robert May wrote:
My suspicion is that you are letting the variable that holds your menu object go out of scope, but with no code posted it's hard to tell. Try using 'our $menu = ...' rather than 'my $menu = ...' when you create the menu object. Letting things go out of scope is very easy to do when you split code into modules.

Thinking further about it, this is actually unlikely to be the problem for a window menu. I confused myself with an issue that I recently tracked down with one of my programs that involved popup menus, where I had a handler like this:

sub handler {
  ...
  my $menu = Win32::GUI::Menu->new(...)
  TrackPopupMenu($menu, ...);

  return;
}

In this code $menu is in scope when TrackPopupmenu is called, so the menu displays fine, but goes out of scope (destroying the menu) as soon as the handler returns, and BEFORE the message pump tries to dispatch the windows event that is raised. As the menu item handlers are stored with the windows menu structure they don't exist when the message pump sees the event.

Regards,
Rob.

Reply via email to