Re: How do I merge menus from one form onto another?
- From: "Joseph Geretz" <jgeretz@xxxxxxxxxx>
- Date: Mon, 12 Dec 2005 21:15:27 -0500
Hi Mark,
Thank you for pointing out that Controls do exhibit this menu merging
behavior.
Now why couldn't Microsoft implement this for Forms? :-\ grrrr....
Here's my situation. I need to engineer an application framework which will
allow other developers to add their own modules in order to customize /
extend the capabilities of the application. I'd like to engineer a common
framework which would first of all be utilized by our own in-house
developers. If we can get a framework in place which is good enough for our
own development purposes, then it will certainly be robust and fully
functional enough to support customizations / extensions.
I initially had the idea of using an MDI environment for the framework, with
Modules being supplied as Forms implemented with a known interface, provided
in one or more external ActiveX DLL's. The advantage to this approach is
that it would allow VB developers to develop their modules using the native
VB IDE Forms design facilities etc... The disadvantage to this would be as
follows:
1. Merging of menus not natively supported
2. At this point, I don't even know if its possible for a Form in an
external DLL to be 'acquired' as an MDI child. Can anyone tell me whether
this is possible or not?
My evolving idea would be to have the modules implemented as user controls,
rather than as forms. With this approach, my framework environment would be
a simple VB form which would host the User Control Modules supplied in
external OCX files. As you've pointed out, controls do merge their menus
nicely with those of their host form. Keeping this approach in mind, I still
need to find out the following:
1. How do I dynamically load an ActiveX control at run time? (Each ActiveX
Control Module would implement a standard interface, so once loaded, I'd be
able to communicatre with it. But given an OCX library, is is possible for
me to interrogate and dynamically load one or more UserControls within that
library?
The drawback to this approach (assuming that I can get past the dynamic
loading issue) is that it forces the users to develop their use interfaces
within a somewhat artificial User Control environment. Although I'm not sure
how big a drawback this really is. The truth is, that plugged-in modules
would be borderless, no title bar, no control bar, etc. When you strip this
all out of a Form in the IDE what you're left with looks pretty much like a
user control canvas. (Except for the menu which allows you to click in the
IDE and jump straight into the corresponding click event - big deal) This
might actually be the way to go. I just need to know how to dynamically load
a control from an OCX at run time. I can get by without interrogating the
OCX itself. If necessary, I'll insist on an accompanying XML file which can
describe the available conformant user controls inside the OCX.
Has anyone ever built any such similar application framework? Any advice
will be extremely appreciated.
Thanks!
- Joe Geretz -
"Mark Alexander Bertenshaw" <mark.bertenshaw@xxxxxxxxxx> wrote in message
news:O2goKw3$FHA.4080@xxxxxxxxxxxxxxxxxxxxxxx
> Joseph -
>
> I can't give you a complete solution to this, but I do know that it is
> possible to "inherit" top level menu items from a UserControl. I'll give
> you an example:
>
> Open a new EXE project. Add a UserControl to the project. Press CTL-E to
> open the menu editor, and create a top level menu, for instance Edit with
> Copy and Paste immediately below it. Click on the top level menu control
> in
> the editor, and ensure that the NegotiatePosition property is set to
> something other than 0-None. The most appropriate one would be 1-Left.
> Close the menu editor, and close the UserControl editor.
>
> Open Form1, and press CTL-E to open the menu editor. Create a top level
> menu, such as File, with Open and Save below it. Ensure that the top
> level
> menu item has NegotiatePosition to something other than 0-None. Close the
> menu editor, and find the NegotiateMenus property. Ensure that this is
> set
> to True.
>
> Now add UserControl1 to your form. Now press F5. You should see the menu
> from the form, and from the UserControl. This is true as long as your
> UserControl has the focus.
>
> The general behaviour for NegotiateMenus=True is that as long as you don't
> have focus on a UserControl, all the menus on the main form are shown. If
> you have focus on a UserControl, all the form menus which are set to
> NegotiatePosition=0 disappear. All form menus which are set to
> NegotiatePosition=1 will appear before all menus on UserControls. You can
> probably guess what the other values do.
>
> In practice, you would implement your system by having one or more forms
> which would contain your standard menus. All your modules would be
> implemented as UserControls with custom "negotiated" menus, that fill up
> all
> the space on a form (a good way of modularising your code, anyway). The
> UserControls would be loaded using Form.Controls.Add().
>
> Sadly, the Negotiate Menus thing doesn't work with MDI forms! I agree
> with
> you about this one. It's been like that since VB 2, and amazingly, it's
> never been changed!!
>
> Alternatively, you could make all your menus dynamically using control
> arrays and a lot of standard menu code i.e. a CreateFileMenu(),
> CreateEditMenu().
>
> --
> Mark Bertenshaw
> Kingston upon Thames
> UK
> "Joseph Geretz" <jgeretz@xxxxxxxxxx> wrote in message
> news:#NyS4g2$FHA.1768@xxxxxxxxxxxxxxxxxxxxxxx
>> I'm working on an application framework. The intent of the framework will
> be
>> to encapsulate many common application features. This will free the
>> developers to focus in on their particular application modules which will
> be
>> implemented on specific forms.
>>
>> The challenge arises in attempting to impose a set of globally available
>> menus, which will be 'inherited' so to speak by each specific application
>> form. Now I haven't worked with MDI since the mid to late 90's but I was
>> surprised to discover that MDI children don't merge their menus onto the
> MDI
>> parent form. Rather, they unilaterally replace the parent menu with their
>> own. Bummer.
>>
>> Any solutions?
>>
>> (And don't tell me to move to .NET. For what the client is asking,
>> believe
>> me I tried my best; but that's not my decision :-\ )
>>
>> Thanks for your help!
>>
>> - Joe Geretz -
>>
>>
>
>
.
- Follow-Ups:
- Re: How do I merge menus from one form onto another?
- From: Mark Alexander Bertenshaw
- Re: How do I merge menus from one form onto another?
- From: Ken Halter
- Re: How do I merge menus from one form onto another?
- References:
- How do I merge menus from one form onto another?
- From: Joseph Geretz
- Re: How do I merge menus from one form onto another?
- From: Mark Alexander Bertenshaw
- How do I merge menus from one form onto another?
- Prev by Date: Re: Imitating Windows Title bar
- Next by Date: Constant values
- Previous by thread: Re: How do I merge menus from one form onto another?
- Next by thread: Re: How do I merge menus from one form onto another?
- Index(es):
Relevant Pages
|