Mega Search
23.2 Million


Sign Up

Make a donation  
Move main menu to different form?  
News Group: embarcadero.public.cppbuilder.language.cpp

Is there a straightforward way to re-parent a TMainMenu from one form to another?  I need to host a form on a tabsheet in a different form.  The form where the tab sheet is doesn't have a main menu yet; I want the first form's main menu to be applied to the tabsheet's form.  

The only option seems to be a brute-force traversal of the original menu, duplicating it property by property on the tabsheet's form (Assign doesn't seem to work for TMainMenu or TMenuItem).  Was hoping there's a simpler way.

Thanks!

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 8-Jan-2015, at 8:39 AM EST
From: Dean Clark
 
Re: Move main menu to different form?  
News Group: embarcadero.public.cppbuilder.language.cpp
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> You should be using a Frame for that instead of a Form.  Then you can move 
> the Frame around as needed.  Put the Frame on your MainForm, move it to the 
> TabSheet, move it back, etc.

We use frames when we know in advance we're going to host a tool different ways.  Putting this tool on a tab sheet wasn't expected until just recently.

> Have you considered using Actions instead?  Then you can put a TActionMainMenuBar 
> or TActionToolBar on the two Forms and have them share the same TAction objects.

Another good idea going forward. We haven't used Actions at all, though I've used Qt's version of them quite a bit.  

Was hoping for something I could whip out this morning.  However, thanks for reminding me about Actions; I'm going to finally take some time and learn how to use them.

Thanks as always Remy.

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 8-Jan-2015, at 9:53 AM EST
From: Dean Clark
 
Re: Move main menu to different form?  
News Group: embarcadero.public.cppbuilder.language.cpp
Hello Dean,

> Is there a straightforward way to re-parent a TMainMenu from one form
> to another?

> I need to host a form on a tabsheet in a different form.

You should be using a Frame for that instead of a Form.  Then you can move 
the Frame around as needed.  Put the Frame on your MainForm, move it to the 
TabSheet, move it back, etc.

> The form where the tab sheet is doesn't have a main menu yet; I
> want the first form's main menu to be applied to the tabsheet's form.

Have you considered using Actions instead?  Then you can put a TActionMainMenuBar 
or TActionToolBar on the two Forms and have them share the same TAction objects.

--
Remy Lebeau (TeamB)

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 8-Jan-2015, at 9:26 AM EST
From: Remy Lebeau (TeamB)