170 likes | 344 Views
Windows Programming Using MFC and Visual C ++ .Net. Menus and Tool Bars. Menus. AppWizard creates two menu resources IDR_MAINFRAME The mainFrame menu is displayed when there is no childFrame. IDR_MAINFRAME. Menus. IDR_ " DocType " Type
E N D
Windows Programming Using MFC andVisual C++ .Net Menus and Tool Bars
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++ .Net Menus and Tool Bars
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++ .Net Menus and Tool Bars
Place holder for new menu Menus • Menus are created or modified using the Menu Editor Menu resources Introduction to Windows Programming Using MFC and Visual C++ .Net Menus and Tool Bars
Menus • To create a new menu • Type a name in a menu placeholder • Set the menu's properties Introduction to Windows Programming Using MFC and Visual C++ .Net Menus and Tool Bars
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++ .Net Menus and Tool Bars
Menus Introduction to Windows Programming Using MFC and Visual C++ .Net Menus and Tool Bars
Menus Introduction to Windows Programming Using MFC and Visual C++ .Net Menus and Tool Bars
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++ .Net Menus and Tool Bars
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++ .Net Menus and Tool Bars
Short Cuts • Enter other short cuts in the Accelerator Table Place holder for a new accelerator Introduction to Windows Programming Using MFC and Visual C++ .Net Menus and Tool Bars
Short Cut Properties Introduction to Windows Programming Using MFC and Visual C++ .Net Menus and Tool Bars
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++ .Net Menus and Tool Bars
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 here pCmdUI->SetCheck(TRUE); } Introduction to Windows Programming Using MFC and Visual C++ .Net Menus and Tool Bars
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++ .Net Menus and Tool Bars
ToolBars • Similar to Menus • Can have the same ID as a menu item • Can have Tool Tip Tool Tip Introduction to Windows Programming Using MFC and Visual C++ .Net Menus and Tool Bars
ToolBars • A Toolbar Button's Tool Tip is also entered in its prompt property box • Prompt and Tool Tip strings are seperated by \n Introduction to Windows Programming Using MFC and Visual C++ .Net Menus and Tool Bars