1. Home
  2. Computing & Technology
  3. Delphi Programming

How to Hide / Show the Main Menu of a Delphi Application

By Zarko Gajic, About.com

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.

Delphi tips navigator:
» PopupMenu With Different Item Heights (and Custom Graphics)
« How to Implement the OnCreate event for a Delphi TFrame object

More Delphi Programming Quick Tips
Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. Delphi 2007 Tips
  7. How to Hide / Show the Main Menu of a Delphi Application

©2009 About.com, a part of The New York Times Company.

All rights reserved.