Making Copy Of a MDI Main Form Menu for Child 
Author Message
 Making Copy Of a MDI Main Form Menu for Child

hi,

Is there any way of making a copy of all the
items in an MDI Main form Menu, and
transferrring this copy into the child
forms Menu Editor,

Regards
Marco Orlandi
Dbn, SA



Thu, 13 Feb 2003 14:40:30 GMT  
 Making Copy Of a MDI Main Form Menu for Child
Ha!  See my response a couple minutes ago to your thread in the controls
n.g. - you can copy and paste code within a text editor much faster than
you can use the menu editor . . .


Thu, 13 Feb 2003 14:53:28 GMT  
 Making Copy Of a MDI Main Form Menu for Child


Quote:
>Ha!  See my response a couple minutes ago to your thread in the controls
>n.g. - you can copy and paste code within a text editor much faster than
>you can use the menu editor . . .

Have tried copying the following code into
my Child.frm using notepad,

Begin VB.Menu mnuFile
      Caption         =   "&File"
      Begin VB.Menu mnuFileNew
         Caption         =   "&New"
         Shortcut        =   ^N
      End
      Begin VB.Menu mnuFileOpen
         Caption         =   "&Open"
         Shortcut        =   ^O
      End
      Begin VB.Menu mnuFileClose
         Caption         =   "&Close"
      End
End

This code simply appears in the child forms
"view code" window, with no entries in the
Menu Editor, is there a correct way of doing it,

Regards
Marco Orlandi
Dbn, SA



Thu, 13 Feb 2003 03:00:00 GMT  
 Making Copy Of a MDI Main Form Menu for Child
Gettin close now, Marco . .  This must be done using a text editor; it
cannot be done in the IDE!  (Best is to close your project, make the
edits, then re-opem.  Best of all is to backup your project somewhere
safe before you start!)

The entire menu structure must be added just before
-----------
End
Attribute VB_Name = "xxx"
-----------
in the frm file. A good way to know where is to put a simple one-item
menu in the target form, then replace its menu definition structure with
the more complex one you are copying in.  (Some menus are 50+ items
going 6 levels deep - doesn't matter, this works in all cases.)

FYI: I have just followed this procedure with the menu structure code
from your post, pasting it into an MDI form I just created; I then add a
form to the project and add
--------
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
  PopupMenu MDIForm1.mnuFile
End Sub
-------
and it works like a champ!

Re processing the event:

If you intend for an event to be passed from the MDI to a child form,
the MDI form event process is going to have to be able to signal the
right form that the event has occured.  'The right form' is almost
certainly MDIForm1.ActiveForm; you will have to put into each child form
that will be using the popup menu a public sub that the MDI can call,
something like
---------
Public sub MenuSelected(WhichMenu as integer)
---------
or maybe, if you prefer, a number of subs, like
---------
Public Sub OpenSelected()
End Sub

Public Sub NewSelected()
End Sub
---------
(etc)

Finally, it looks like I am giving advice haphazardly for two distinct
strategies, either leaving a single menu on the MDI form or copying that
menu to the child form(s).  Either strategy works; just use those
portions of what I have given you that are relevant to the technique you
select and put the rest in your pocket to know and use in some future
project <g>

Good luck!

Quote:



> >Ha!  See my response a couple minutes ago to your thread in the controls
> >n.g. - you can copy and paste code within a text editor much faster than
> >you can use the menu editor . . .

> Have tried copying the following code into
> my Child.frm using notepad,

> Begin VB.Menu mnuFile
>       Caption         =   "&File"
>       Begin VB.Menu mnuFileNew
>          Caption         =   "&New"
>          Shortcut        =   ^N
>       End
>       Begin VB.Menu mnuFileOpen
>          Caption         =   "&Open"
>          Shortcut        =   ^O
>       End
>       Begin VB.Menu mnuFileClose
>          Caption         =   "&Close"
>       End
> End

> This code simply appears in the child forms
> "view code" window, with no entries in the
> Menu Editor, is there a correct way of doing it,

> Regards
> Marco Orlandi
> Dbn, SA



Thu, 13 Feb 2003 03:00:00 GMT  
 Making Copy Of a MDI Main Form Menu for Child


Quote:
>Gettin close now, Marco . .  This must be done using a text editor; it
>cannot be done in the IDE!  

ok, appreciate this advise, will go through your post carefully ,seems to
be functioning now, ...
Quote:

>> Regards
>> Marco Orlandi
>> Dbn, SA



Thu, 13 Feb 2003 03:00:00 GMT  
 Making Copy Of a MDI Main Form Menu for Child



Quote:
> If you intend for an event to be passed from the MDI to a child form,
> the MDI form event process is going to have to be able to signal the
> right form that the event has occured.  'The right form' is almost
> certainly MDIForm1.ActiveForm; you will have to put into each child form
> that will be using the popup menu a public sub that the MDI can call,
> something like

If you use a lot of popupmenu's, you can write a public function which
returns the selected item in the submenu.

When I started in VB I used your method, but if you have a lot of MDI forms,
with (like I have) two or more controls like listboxes and/or listviews with
different popupwindows on a right mousebutton press, things getting hard to
manage.

Rene



Sat, 15 Feb 2003 03:00:00 GMT  
 Making Copy Of a MDI Main Form Menu for Child


 with (like I have) two or more controls like listboxes and/or

Quote:
>listviews with different popupwindows on a right mousebutton press,
>things getting hard to manage.

the menu editor seems a little limited, however nice to know
that can copy/paste menu items in the form files,
appreciate this info,


Sat, 15 Feb 2003 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Q: Form activate Fires On Non Child MDI Forms But Only Once On Child Mdi Forms

2. Making a form a child form of an MDI form

3. Making a form a child form of an MDI form

4. How to make menu in MDI child appear together with MDI form

5. Menu, MDI form and MDI child

6. MDI Form's menu replaced by MDI Child

7. Making a child form much bigger than the parent MDI form

8. MDI and Child Form Menus / Menu Editor

9. MDI Menu with Child form Popup menu's

10. Using MDI Menus with child menu when child are hidden for popup

11. Using MDI Menus with child menu when child are hidden for popup

12. Starting Child from from MDI Main form.

 

 
Powered by phpBB® Forum Software