This may not be _exactly_ what you are looking for, but this does create
Dynamic menu Items upon startup of the application.  I havent looked into
updating a Menu while the program is running however (if that is even
possible), so you are on your own there.

sub create_recent_list  {
        my $mrunum;
        if ( $hklm )  {
                foreach $key ( keys(%$hklm) )  {
                        if ( $key =~ /RecentFile/i )  {
                                $mrulist[$mrunum++] = $hklm->{$key};
                                push (@mrumenu, " > $mrunum  $hklm->
{$key}");
                                push (@mrumenu, "MRUFile$mrunum");
                                $subname = "MRUFile${mrunum}_Click";
                                *$subname = eval ( qq(
                                        sub  {
                                                OpenFile_Click ($mrunum);
                                        }
                                ));
                        }
                }
                if ( $#mrumenu > 0 )  {
                        unshift (@mrumenu, "0");
                        unshift (@mrumenu, " > -");
                }
        }  else  {
                print "DEBUG - Unable to open the Registry\n" if $debug;
        }
}

Basically the above just goes through a list of registry keys and gets the
Value assigned to them and populates that into a @mrumenu array, which is
used during the creation of the Menu for the Main Window.  The sub also
creates the callback functions for what happens if those items are clicked
on.  The Main Window Menu creation then looks like this.

        $windowmenu = Win32::GUI::MakeMenu (
                "&LogFile"                              => "LogFile",
                " > &Open..."                           => "OpenFile",
                " > &Pause Monitoring"                  => "PauseMon",
                " > &Resume Monitoring"                 => "ResumeMon",
                " > -"                                  => 0,
                " > &Stop Monitoring"                   => "StopMon",
                @mrumenu,
                " > -"                                  => 0,
                " > E&xit"                              => "Exit",
                "&Edit"                                 => "Edit",
                " > Reset &Log"                         => "ResetLog",
                " > Reset &Statistics"                  => "ResetStats",
                "&Stats"                                => "Stats",
                " > Export to &Pretty Text"             => "ExportToText",
                " > Export to &Excel Graph"             => "ExportToExcel",
                " > Export to &Tab Delimited Format"    => "ExportToTab",
                "&Help"                                 => "Help",
                " > &About LogMon"                      => "About",
        );

Hope this helps at least a little bit.

Len.



                                                                                
                                                   
                      "Jez White"                                               
                                                   
                      <[EMAIL PROTECTED]>                 To:       "Peter 
Eisengrein" <[EMAIL PROTECTED]>,        
                      Sent by:                                      Win32-GUI 
<perl-win32-gui-users@lists.sourceforge.net>         
                      [EMAIL PROTECTED]        cc:                              
                               
                      ceforge.net                                  Subject:  
Re: [perl-win32-gui-users] Dynamic popup menus        
                                                                                
                                                   
                                                                                
                                                   
                      02/27/2004 11:34 AM                                       
                                                   
                                                                                
                                                   
                                                                                
                                                   




Easy when you know how:) Thanks, that's saved me hours of playing around.

So it looks like I'll have to completely recreate my whole menu tree rather
than just the sub menu.

Cheers and thanks again,

jez.
 ----- Original Message -----
 From: Peter Eisengrein
 To: 'Jez White' ; Win32-GUI
 Sent: Friday, February 27, 2004 5:26 PM
 Subject: RE: [perl-win32-gui-users] Dynamic popup menus

 Yes, that much I know!!!

 my $Menu = new Win32::GUI::Menu(
      "&Menu" => "Menu",
      "   >   &Sub Menus" => "",
      "   >>  Sub Item &1" => "submenu1",
      "   >>  Sub Item &2" => "submenu2",
      "   >>  Sub Item &3" => "submenu3",
      "   >>  Sub Item &4" => "submenu4",
     );
  -----Original Message-----
  From: Jez White [mailto:[EMAIL PROTECTED]
  Sent: Friday, February 27, 2004 12:07 PM
  To: Jez White; Peter Eisengrein; Win32-GUI
  Subject: Re: [perl-win32-gui-users] Dynamic popup menus

  Humm....Is it even possible to create a sub menu at all?

  ----- Original Message -----
  From: Jez White
  To: Peter Eisengrein ; Win32-GUI
  Sent: Friday, February 27, 2004 2:14 PM
  Subject: Re: [perl-win32-gui-users] Dynamic popup menus

  Hi,

  Thanks for the reply - I probably didn't explain myself to well:) What I
  was trying to do was something like below:

   Show
   -------------
   Manual Entry  >   Manual Entry 1
   Edit entries      Manual Entry 1
   Work Offline      Manual Entry 1
   Synchronize       --------------
   -------------     All
   Quit

  Where the manual entry sub menu is the dynamic one. Does this make any
  sense?

  cheers,

  jez.






Reply via email to