Windows Develop Bookmark and Share   
 index > Windows Forms General > Difference between Mainmenu and MenuStrip (VS 2003 and 2005)
 

Difference between Mainmenu and MenuStrip (VS 2003 and 2005)

I am not sure if anyone can explain the difference between Mainmenu (in VS 2003) and MenuStrip (2005).

For Mainmenu control, its height will not be counted as a part of client area's height.

For MenuStrip control, its height will be counted as a part of client area's height.

This causes menuStrip control and some control (bitmap) of my old VB2003 program overlapping each other. My original bitmap paints the whole client area. But now either menustrip takes away top slice of bitmap, or bitmap covers menustrip control.

Although I may be able to find a way to compensate the loss of height of client area, it is very troublesome. Since once a menustrip is added, it uses part of "original client" area. The real client area should be calculated based on this change.

jimmy1949  Thursday, July 26, 2007 3:46 PM
MenuStrip is a complete replacement for MainMenu and has nothing in common with that control. The old MainMenu was built on top of the built-in Windows support for menus. The GetClientRect() API function automatically deducts the menu size from the client rectangle. MenuStrip doesn't use Windows menus, thus GetClientRect() returns the size of the window's client area, disregarding the space taken up by the MenuStrip. The same is true for any other window edge adornments like StatusStrip and ToolStrip. Or any docked panels for that matter.

The workaround is not difficult, just add the height of the MenuStrip to client coordinates. Or use Graphics.TranslateTransform() for painting. Or keep the MainMenu, it is still supported.

Off topic for the BCL, moved to Windows Forms General.
nobugz  Friday, July 27, 2007 2:22 PM
MenuStrip is a complete replacement for MainMenu and has nothing in common with that control. The old MainMenu was built on top of the built-in Windows support for menus. The GetClientRect() API function automatically deducts the menu size from the client rectangle. MenuStrip doesn't use Windows menus, thus GetClientRect() returns the size of the window's client area, disregarding the space taken up by the MenuStrip. The same is true for any other window edge adornments like StatusStrip and ToolStrip. Or any docked panels for that matter.

The workaround is not difficult, just add the height of the MenuStrip to client coordinates. Or use Graphics.TranslateTransform() for painting. Or keep the MainMenu, it is still supported.

Off topic for the BCL, moved to Windows Forms General.
nobugz  Friday, July 27, 2007 2:22 PM

You can use google to search for other answers

Custom Search

More Threads

• Change Form contents dynamically
• Problem with DataGridView: No new row created after editing text
• datagridviewcheckboxcell control
• How change the language input?
• Where should I report a bug of .Net Framework?
• How can I customise the default OpenFileDialog appearance.
• Where the heck have my scrollbars gone!!
• right click on TreeNode / C#
• how does printdocument work?
• How to Access MDI Child Forms From MDI Parent Child Form?