Hide TActionMainMenuBar?
Asked Answered
O

2

10

I would like to have an option from my Application to toggle the display of the Main Menu.

Functionality can still be used through the Toolbar etc, so hiding the Menu will not take anything away. Hiding the Menu is really a GUI choice for user.

Anyway my Main Menu is setup using the TActionMenuBar and TActionManager (for the XP alphablend style).

I tried simply setting the Visible property of the MainMenuBar which resulted in this error message: "ActionMainMenuBar does not allow hiding."

I thought that was a bit odd, giving the fact the Visible property exists. Why would it be there, if I cannot actually change it?

So as usual I expected this to be a simple case of changing one setting and voila, but no I think this may require more work, I wouldn't even know where to start or what to look for.

Appreciate your ideas and suggestions thanks.

Osteomalacia answered 7/1, 2012 at 14:3 Comment(4)
This is a good question. I suggest you dig into the source code of the VCL for TActionMenuBar.Pistoleer
Thanks Warren, I will have a look. I am interested to see why there is a Visible property, especially if it cannot actually be used.Osteomalacia
@Craig - I have answered your question, you don't need to fiddle with the sources etc..Snocat
Yeah I have just seen thanks Sertac, I don't really know what I would of been looking for anyway to be honest. In this case the answer really was simple :)Osteomalacia
S
8

You need to set AllowHiding to 'true' before setting Visible to 'false'.

Snocat answered 7/1, 2012 at 14:42 Comment(3)
Thanks for pointing out AllowHiding, I did not see this. I don't see why there should be a need for AllowHiding property though, it could of just been tied into the Visible property.Osteomalacia
@Craig - The property is there in case your users are able to customize toolbars. You might want that users be able to hide toolbars but not the menu bar.Snocat
Oh I see, well then I guess that does make sense! Thanks Sertac appreciate your help.Osteomalacia
T
0

The menu is usually associated with the main form so setting Form1.Menu := nil will hide it and Form1.Menu := MainMenu will show it.

Trajectory answered 7/1, 2012 at 14:23 Comment(1)
No, you can't set a ActionMainMenuBar through a form's Menu property.Snocat

© 2022 - 2024 — McMap. All rights reserved.