I have introduced how to compile a menu wizard ), however, the menu item can only be used as a sub-item of the "help" menu in the Delphi IDE environment. What should we do if we want to insert our own menu items in any position in the main menu of Delphi ide?
In fact, the method is very simple. You only need to write an add-in Wizard plug-in expert to insert the menu into the main menu of Delphi IDE in its constructor, the newly inserted menu items are parsed In the destructor.
First, we need to define some private members in the expert class to save the main menu of Delphi IDE and the newly created menu items.
Fmainmenu: tmainmenu;
Fnewmenuitem: tmenuitem;
The next step is to obtain an example of the Delphi ide Main Menu object in the constructor, create a new menu item, and insert it.
// Find Delphi's main menu
Fmainmenu: = (borlandideservices as intaservices). mainmenu;
// Create new menu item
Fnewitem: = tmenuitem. Create (NiL );
Fnewitem. Caption: = 'add-in menu ';
Fnewitem. onclick: = menuitemclick;
// Insert new menu item
Fmainmenu. Items. insert (fmainmenu. Items. Count-1, fnewitem );
Finally, we need to release the menu items we have inserted in the destructor.
Fmainmenu. Items. Remove (fnewitem );
Fnewitem. Free;