Mega Code Archive

 
Categories / Delphi / Ide Indy
 

How to Hide Show the Main Menu of a Delphi Application

Title: How to Hide / Show the Main Menu of a Delphi Application The TMainMenu Delphi component encapsulates a menu bar and its accompanying drop-down menus for a form. The TMainMenu Delphi component does not expose the Visible property to let you show or hide the menu for a form programmatically, does it? It does not, but there is a way to hide the main menu for a Delphi form at run time. Here's how... To assign a menu for a form, drop a TMainMenu on it (let's say it has "MainMenu1" for its Name property), add menu items and asign it for the Menu property of a form. If you want to hide the menu programmatically, at run-time, just use this line of code: //MainForm is the name of the form MainForm.Menu := nil; To show the menu again, simply reassign the Menu property for the form: //MainForm is the name of the form MainForm.Menu := MainMenu1; That's it.