Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 818639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:10:57+00:00 2026-05-15T02:10:57+00:00

Anybody knows how to merge two menus with the same name in a MDI

  • 0

Anybody knows how to merge two menus with the same name in a MDI application.

More exactly, in the MDI main form I have a menu called ‘File’ which has a sub-menu called ‘Load project’.
In the MDI child form, I have a menu called also ‘File’ which contains a sub-menu called ‘Save project’.

How can I force my application to show both ‘Load’ and ‘Save’ sub-menus under the ‘File’ menu?

–

PS: setting the same GoupIndex value will not work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:10:58+00:00Added an answer on May 15, 2026 at 2:10 am

    To merge your menus use this procedure:

    procedure MergeMenus(var SrcMenu, DstMenu: TMainMenu);
    var
      i, i2, i3: Integer;
      Menu: TMenuItem;
    begin
      for i := 0 to SrcMenu.Items.Count - 1 do
      begin
        for i2 := 0 to DstMenu.Items.Count - 1 do
        begin
          if (SrcMenu.Items[i].Name = DstMenu.Items[i2].Name) and
            (SrcMenu.Items[i].Count > 0) and (DstMenu.Items[i].Count > 0) then
          begin
            for i3 := 0 to SrcMenu.Items[i].Count - 1 do
            begin
              Menu := TMenuItem.Create(DstMenu.Owner);
              // copy another properties if necessery
              Menu.Name := SrcMenu.Items[i].Items[i3].Name;
              Menu.Caption := SrcMenu.Items[i].Items[i3].Caption;
              Menu.ShortCut := SrcMenu.Items[i].Items[i3].ShortCut;
              Menu.OnClick := SrcMenu.Items[i].Items[i3].OnClick;
              DstMenu.Items[i].Add(Menu);
            end;
          end;
        end;
      end;
    end;
    

    Call it in the OnCreate event of your MDIChildForm like this:

    procedure TMDIChild.FormCreate(Sender: TObject);
    begin
      MergeMenus(YourMainForm.MainMenu1, Self.MainMenu1);
    end;
    

    It will work if two different MainMenus will have MenuItems with the same name. Also please note that there is a possible memory leek if your DstMenu does not have an owner (but I guess it have and it is your MDICHildForm).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anybody knows how to get nic card name when I do ipconfig/all I can
Anybody knows a good book or two (or resources) for JVM Tuning? I am
anybody knows some open source asp.net mvc survey application
anybody knows efficiency in masking(anonymization) of some tables in a mysqldump? I have already
anybody knows efficiency in masking(anonymization) of some tables in a mysqldump? I have already
Anybody knows reasonable hooks usage? I wrote 2 projects and have no idea what
anybody knows how to hide border in HTML using Form or Input tag? My
If I have two arrays both with 10000 items, now I want to merge
Anybody knows how to prevent an Android application crashing when ab EditText has no
Anybody knows if it is possible to get a javascript for/in loop from coffeescript?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.