Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hiding Main Menu Item

568 views
Skip to first unread message

Helmut Leitner

unread,
Aug 25, 1999, 3:00:00 AM8/25/99
to
How can I hide a main menu item, the visible property does not seem to work
with that one.

Thanks Helmut

Yorai Aminov (TeamB)

unread,
Aug 25, 1999, 3:00:00 AM8/25/99
to
On Wed, 25 Aug 1999 07:44:25 +0800, "Helmut Leitner"
<ct...@ctr.com.au> wrote:

>How can I hide a main menu item, the visible property does not seem to work
>with that one.

Works for me. What version of Delphi are you using?

---
Yorai Aminov (TeamB)
http://ourworld.compuserve.com/homepages/yaminov
(TeamB cannot answer questions received via email.
To contact me for any other reason remove nospam from my address)

Graeme Chandler (Melbourne)

unread,
Aug 25, 1999, 3:00:00 AM8/25/99
to
Hi Helmut

I take it you want to hide the entire menu??

I'd take a look at RemoveComponent and InsertComponent.

You'll need to assign your main menu component to something else in your
FormCreate for example:

SaveMainMenu := MainMenu1;

The reason for this is that as soon as you use RemoveComponent, your form no
longer knows anything about MainMenu1 (and Delphi sets the variable for
MainMenu1 to nil)..

To remove the main menu from the form (ugly since its going to scroll
everything up):

RemoveComponent(SaveMainMenu);

To show the main menu:

InsertComponent(SaveMainMenu)

I've no idea whether this confuses the hell out of the the VCL when it tries to
tidy up the VCL controls when closing. Use at your own risk. Someone else might
have better ideas though.

Graeme
http://www.gajits.com

Helmut Leitner wrote:

> How can I hide a main menu item, the visible property does not seem to work
> with that one.
>

> Thanks Helmut


Helmut Leitner

unread,
Aug 25, 1999, 3:00:00 AM8/25/99
to
Sorry forgot to mention that I am trying to change the visible property at
run time
I am using version 4.03 and have never been able to hide or disable main
menu items at run time.

Regards Helmut


Yorai Aminov (TeamB) <yam...@nospam.trendline.co.il> wrote in message
news:37c456af...@forums.inprise.com...


> On Wed, 25 Aug 1999 07:44:25 +0800, "Helmut Leitner"

> <ct...@ctr.com.au> wrote:
>
> >How can I hide a main menu item, the visible property does not seem to
work
> >with that one.
>

Helmut Leitner

unread,
Aug 25, 1999, 3:00:00 AM8/25/99
to
Thanks

Yes forgot to mention that I want to hide/show a main menu item at
runtime. e.g hide the Tools menu with all associated menu items.

Regards Helmut

Graeme Chandler (Melbourne) <gra...@gajits.com> wrote in message
news:37C34991...@gajits.com...


> Hi Helmut
>
> I take it you want to hide the entire menu??
>
> I'd take a look at RemoveComponent and InsertComponent.
>
> You'll need to assign your main menu component to something else in your
> FormCreate for example:
>
> SaveMainMenu := MainMenu1;
>
> The reason for this is that as soon as you use RemoveComponent, your form
no
> longer knows anything about MainMenu1 (and Delphi sets the variable for
> MainMenu1 to nil)..
>
> To remove the main menu from the form (ugly since its going to scroll
> everything up):
>
> RemoveComponent(SaveMainMenu);
>
> To show the main menu:
>
> InsertComponent(SaveMainMenu)
>
> I've no idea whether this confuses the hell out of the the VCL when it
tries to
> tidy up the VCL controls when closing. Use at your own risk. Someone else
might
> have better ideas though.
>
> Graeme
> http://www.gajits.com
>

> Helmut Leitner wrote:
>
> > How can I hide a main menu item, the visible property does not seem to
work
> > with that one.
> >

> > Thanks Helmut
>

Steve Schafer (TeamB)

unread,
Aug 26, 1999, 3:00:00 AM8/26/99
to
On Wed, 25 Aug 1999 13:55:43 +0800, "Helmut Leitner"
<ct...@ctr.com.au> wrote:

>Sorry forgot to mention that I am trying to change the visible property at
>run time
>I am using version 4.03 and have never been able to hide or disable main
>menu items at run time.

Works just fine for me. I created the following menu structure in a
new Delphi project:

File Edit Window
New Cut Tile
Open Copy Cascade
Paste

I then dropped a button on the form and put the following code in its
OnClick event handler:

Edit1.Visible := not Edit1.Visible;

Clicking the button at runtime toggles the visibility of the Edit menu
as expected.

-Steve


Yorai Aminov (TeamB)

unread,
Aug 26, 1999, 3:00:00 AM8/26/99
to
On Wed, 25 Aug 1999 13:55:43 +0800, "Helmut Leitner"
<ct...@ctr.com.au> wrote:

>Sorry forgot to mention that I am trying to change the visible property at
>run time
>I am using version 4.03 and have never been able to hide or disable main
>menu items at run time.

I can't reproduce this. I've set a main menu item's Visible property
at run time and it works just fine. I've tested with Delphi 3, 4, and
5.

Ray Adams

unread,
Aug 27, 1999, 3:00:00 AM8/27/99
to
Is it doesn't work??? MenuItem1.Visible:=false ???
Go to borland and take new update for Delphi 4
post update 3
Ray
Helmut Leitner <ct...@ctr.com.au> wrote in message
news:7q00fi$kt...@forums.borland.com...

> Sorry forgot to mention that I am trying to change the visible property at
> run time
> I am using version 4.03 and have never been able to hide or disable main
> menu items at run time.
>
> Regards Helmut
>
>
> Yorai Aminov (TeamB) <yam...@nospam.trendline.co.il> wrote in message
> news:37c456af...@forums.inprise.com...
> > On Wed, 25 Aug 1999 07:44:25 +0800, "Helmut Leitner"
> > <ct...@ctr.com.au> wrote:
> >
> > >How can I hide a main menu item, the visible property does not seem to
> work
> > >with that one.
> >
> > Works for me. What version of Delphi are you using?
> >

Helmut Leitner

unread,
Aug 27, 1999, 3:00:00 AM8/27/99
to
Thanks everyone
Found the problem, I am using a TMenubar which does not reflect this
property, needs setting of the buttons visible property.

Regards Helmut

Yorai Aminov (TeamB) <yam...@nospam.trendline.co.il> wrote in message

news:37c5546c...@forums.inprise.com...
>

Andrey Cherepakhin

unread,
Aug 27, 1999, 3:00:00 AM8/27/99
to
That's why I'm always recommending to use a third-party menu component --
Delphi's TMenuBar is way too incompatible and you need to be aware of a lot
of things.

Andrey.


Helmut Leitner <hlei...@ctr.com.au> wrote in message
news:7q4jmn$pj...@forums.borland.com...

0 new messages