Possible to push a mainmenu under a panel?

  • Thread starter Thread starter NBB
  • Start date Start date
N

NBB

Is it possible to push a MainMenu under a panel control that's docked
at the top of the window? If not, is it possible OwnerDraw MenuItems
into other controls. Essentially, I'm trying to move the MainMenu
functionality downward.

The effect I'm trying to acheive is sort of like this:

------------------------------
|[] TitleBar [_][-][x]|
|------------------------------|
| |
| *Some user controls* |
| |
|------------------------------|
|File Edit View |
|------------------------------|
| |
| *Some other controls* |
| |
| |
| |
|______________________________|
 
Hi NBB,
This is not possible using Windows Forms menu.
WindowsForms MainMenu and ContextMenu components are not a controls.

MainMenu component adds standard windows menu to a top level window.
In windows windows with style WS_OVERLAPPED and WS_POPUP can have a main
menu. Windows with style WS_CHILD (all controls like panels, user controls,
etc), though, cannot have a main menu.

This becomes obvious when you look at CreateWindow, CreateWindowEx and
SetMenu API specifications in MSDN.
The paramter called hMenu when creating a child window is used for child
window ID.

For SetMenu you can read the following remark
"... A menu can be assigned to any window that is not a child window..."

Even if you try to create a form and add it to the main form's Controls
collection you have to set TopLevel property to false. Setting it will make
the form a child window so it will lose the menu.

The only way you can do this is to go with some third party manu control.
Usually the are implemented as a noraml controls so they can be hosted
anywhere.
 
Back
Top