11_f08_MenuPrintA - Menus and Printing Menus A focal point...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Menus and Printing Menus • A focal point of most Windows applications – Almost all applications have a Main Menu bar – Main Menu Bar resides under the title bar – Main Menu contains Menu Items • Short words/phrases representing actions that can be selected • Many of these items are themselves menus – “Popup menus” (“drop-down menus”, “submenus”) – Main Menu contains “top-level” items • Always visible • Contains an array of Menu Items – Menus can be nested – form a hierarchy • Each Menu Itemcan contain an array of other Menu Items – Menu classes – all derived from abstract Menu class • Subclasses: MainMenu, MenuItem, ContextMenu classes
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 MainMenu Class • Constructors: – MainMenu() • If this variant is used, MenuItems must be added to it in code – MainMenu(MenuItem[ ] ami) • ami is an array of MenuItems to be included in the main menu – Attach a MainMenu to a form by assigning it to the form’s Menu property, e.g.: this.Menu = new MainMenu(new MenuItem[ ] {mi_1, mi_2, …}); • mi_1, mi_2, etc. are instances of the MenuItemclass MenuItem Class • Several constructors to create a single Menu Item: – MenuItem(); – MenuItem(string strText ); //strText is the text that appears – MenuItem(string strText, EventHandler(ehClick) ); • EventHandler is the Delegate • Adds the ehClickevent handler function to the Menu Item’s Click event • Every Menu Item that doesn’t invoke a submenu should have a Click event handler that is called when user clicks the item • If not done using this constructor, the Click event handler mustbe added to the menu item’s Click event in code (delegating as with other events) – MenuItem(string strText, EventHandler(ehClick), Shortcut sc); • Shortcut: a keyboard interface to underlined menu items • Specified by using values from the Shortcut enumeration • Creating a menu item that is a submenu: – MenuItem(string strText, MenuItem[ ] ami) – ami is an array of Menu Items • the items to be included in this menu item’s submenu
Background image of page 2
3 MenuItem Properties • Important ones: – string Text – Shortcut Shortcut – bool ShowShortcut – bool Visible – bool Enabled – bool Break – bool BarBreak – bool Checked – bool RadioCheck Manual Coding of a Menu • Do it “bottom up” – Define low-level Menu Items first – Then their parents – Finally the Main Menu – In each case, attach menu items to their parent • See Menu-Drawing-Manual example program
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Using VS Designer to Prepare Menus • Just drag a “MenuStrip” from the tool box to the form – It will appear in the component tray below the form – Brings up the menu editor/designer – Where it says “Type Here”, type in menu items and change their Text and other properties in their property boxes • In the Text property, prefixing a character with “&” causes an <Alt> keyboard shortcut – Submenu items go below, menu items at the same level in the hierarchy to the right
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/04/2009 for the course ER CS 360 taught by Professor Reckert during the Spring '09 term at Istanbul Technical University.

Page1 / 13

11_f08_MenuPrintA - Menus and Printing Menus A focal point...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online