Date post: | 31-Dec-2015 |
Category: |
Documents |
Upload: | kerry-bennett |
View: | 214 times |
Download: | 0 times |
Masoud MilaniSchool of Computer ScienceFlorida International UniversityMiami, FL 33199 [email protected]
Windows Programming Using MFC and
Visual C++ .Net
Menus and Tool Bars
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 2
Menus
AppWizard creates two menu resources IDR_MAINFRAME
The mainFrame menu is displayed when there is no childFrame
IDR_MAINFRAME
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 3
Menus
IDR_"DocType"Type The mainFrame menu when there is at
least one childFrame
IDR_IntroType
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 4
Menus
Menus are created or modified using the Menu Editor
Menu
resources
Plac
e ho
lder
for
new
men
u
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 5
Menus
To create a new menu Type a name in a menu place
holder
Set the menu's properties
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 6
Menus
Decide which class must handle this menu command Document ? View? Mainframe? App? ChildFrame?
Use the class wizard to write a handler for the menu's COMMAND message
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 9
Menu Prompt
Menu prompt is the message that appears inside the status bar when the mouse is on the menu
Menu Prompt
Enter menu's prompt in its property box
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 10
Short Cuts
For Alt key short cut, put & in front of a letter in the menu's caption
New Men&u
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 11
Short Cuts
Enter other short cuts in the Accelerator Table
Place holder for anew accelerator
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 12
Short Cut Properties
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 13
Menu State
A menu can be in one of the following states: Enabled
Enabled(TRUE);
Disabled Enable(FALSE);
Checked SetCheck(TRUE);
Unchecked SetCheck(FALSE);
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 14
Menu State
The state of a menu is set in the handler for the menu UPDATE_COMMAND_UI message
void CIntroView::OnUpdateEditNew(CCmdUI* pCmdUI) {
// TODO: Add your command update UI handler code herepCmdUI->SetCheck(TRUE);
}
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 15
Command Routing
Menus and Tools bars are a part of the MainFrame.
Who gets the menu commands? Menu commands are routed to the
following objects to a find a event handler View Document ChildFrame MainFrame Application
Introduction to Windows Programming Using MFC and Visual C++ .NetMenus and Tool Bars 16
ToolBars
Similar to Menus Can have the same ID as a menu
item Can have Tool Tip
ToolTip