[ Pobierz całość w formacie PDF ]
.The accelerator will perform thesame action as selecting Bears from the pop-up shortcut menu.Open the IDR_MAINFRAME accelerator resource folder, and add a new acceleratorresource to the Menu project using the values from Table 10.3.Table 10.3.The new accelerator resource for the Menu project.IDKeyModifiersTypeID_BEARSBCtrlVirtualBuild the Menu project.Instead of selecting an item from the shortcut menu, trypressing Ctrl+B on your keyboard; you will get the same message as when you selectBears from the shortcut menu.SummaryIn this hour, you learned about the use of menus in Windows applications.Youlearned about the routing of menu command messages, as well as methods for modifyingand creating menu resources.As an example, you created an application that displaysa floating pop-up menu when the right mouse button is clicked.Q&AQ I added a new item to my menu, but it's gray.I've checked the menu attributesto make sure that the menu should be enabled; why is the menu item still gray?A Make sure that you have provided a message-handling function for the menuitem.The MFC framework will not enable a menu item that doesn't have a message handler.Q All the menu items with keyboard accelerators that are provided by MFC and AppWizardplace the accelerator label to the far right of the menu window.How can I providethat effect for my controls?A Use the \t tab escape sequence between your menu item and the acceleratortext.For example, the caption for the Bears menu item would be&Bears\tCtrl+BWorkshopThe Workshop is designed to help you anticipate possible questions, review whatyou've learned, and begin thinking ahead to putting your knowledge into practice.The answers to the quiz are found in Appendix B, "Quiz Answers."Quiz1.What MFC class is used to manage menus?2.What message is handled when providing a shortcut menu?3.What visual cue should be provided for a menu that leads to a dialog box thatrequires further input from the user?4.What is a mnemonic?5.What is a keyboard accelerator?Exercises1.The File|Enable Hello and File|Check Hello menu items are not updated to reflectthe current state of the application.Add update command UI handlers for these menuitems so that their captions read File|Disable Hello and File|Uncheck Hello whenappropriate.2.Add accelerators for the Lions and Tigers shortcut menu items in the Menu project.© Copyright, Macmillan Computer Publishing.Allrights reserved
[ Pobierz całość w formacie PDF ]