Search code examples
delphiribbon

How To Read and Write Delphi 2010 RibbonApplicationMenuBar Recent Items To A File


How do you read and write RibbonApplicationMenuBar recent items to a file or an INI file?

The help file is not very helpful for getting at the list of recent item strings to save and reload the recent items. I can add items to the recent items list by Ribbon1.AddRecentItem( APathFilename) and open the file associated with the recent item with the RecentItemClick event but I can not figure out how to save and reload recent filenames to the recent items list.


Solution

  • The TRibbonApplicationMenuBar has a RecentItems property, which provides access to a list of each recent item.

    // example code - untested.
    RibbonApplicationMenuBar1.RecentItems.Items[1].Caption;
    

    Another example for looping though each item.

    // example code - untested.  
    var
      count : Integer;
    begin
      For count := 1 to RibbonApplicationMenuBar1.RecentItems.Items.Count do
      begin
        ShowMessage(RibbonApplicationMenuBar1.RecentItems.Items[count].Caption);
      end;
    end;