
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