VC++ Programming UESTC Chapter 12 Menus, Keyboard Accelerators, the rich Edit Control and Property sheets Let's create a Single Document Interface(SDI application and add menus and keyboard accelerators Step One: create a SDI exe project Step two: create menu items Open resource editor Drag the empty box to the place you want to put and click the right mouse button then click the properties"item on the popup menu 3. Dont give a Id number for the first level menu item(let it be gray), make sure you check the box. Give a caption you like and put"&""inside a bracelet following the caption, then click Enterkey
VC++ Programming @ UESTC 6 ⚫ Let’s create a Single Document Interface (SDI) application and add menus and keyboard accelerators. ⚫ Step One: create a SDI exe project ⚫ Step two : create menu items 1. Open resource editor 2. Drag the empty box to the place you want to put and click the right mouse button then click the “properties” item on the popup menu. 3. Don’t give a ID number for the first level menu item(let it be gray), make sure you check the “Pop-up” box. Give a caption you like and put “&I” inside a bracelet following the caption, then click “Enter” key. Chapter 12 Menus, Keyboard Accelerators, the RichEdit Control and Property Sheets
VC++ Programming UESTC Chapter 12 Menus, Keyboard Accelerators, the rich Edit Control and Property sheets Step two: create menu items 4. The Pop-up option give you a chance to create a next level menu items. The&I' is the shortcut system the framework gives you. The Ctrl-I will activate the menu Item 5. Click the newly created top level menu item and right click the empty box under, click the"properties item and do the similar job as above except you give a id this time Uncheck thePop-up"option
VC++ Programming @ UESTC 7 ⚫ Step two : create menu items 4. The Pop-up option give you a chance to create a next level menu items. The “&I” is the shortcut system the framework gives you. The Ctrl-I will activate the menu item. 5. Click the newly created top level menu item and right click the empty box under, click the “properties” item and do the similar job as above except you give a ID this time. Uncheck the “Pop-up” option. Chapter 12 Menus, Keyboard Accelerators, the RichEdit Control and Property Sheets
VC++ Programming@UESTC Chapter 12 Menus, Keyboard Accelerators, the rich Edit Control and Property sheets Step two: create menu items 6. This D will respond to user events inside your VC++ code. The ID's structure reflects the menu levels. like ID INSERT LINES LINE which is a three level submenu d 7. create another second level menu, dont give id this time and check the" Pop-up?"option. Now you can create a sub menu under this one 8. In this way you may create any level sub-menu as you like
VC++ Programming @ UESTC 8 ⚫ Step two : create menu items 6. This ID will respond to user events inside your VC++ code. The ID’s structure reflects the menu levels, like ID_INSERT_LINES_LINE which is a three level submenu ID. 7. create another second level menu , don’t give ID this time and check the “Pop-up” option. Now you can create a sub menu under this one. 8. In this way you may create any level sub-menu as you like. Chapter 12 Menus, Keyboard Accelerators, the RichEdit Control and Property Sheets
VC++ Programming UESTC Chapter 12 Menus, Keyboard Accelerators, the rich Edit Control and Property sheets Step three: create keyboard accelerators 1. Click the Accelerator--IDR MAINFRAME inside resource editor and you' ll see many IDs associated ith Keys Inside the right panel, right click your mouse and click the new accelerator"on the popup menu. You'lI see a popup Accel Properties window Choose a Id you may want to respond to Type a letter and choose any combination of modifiers Dont make the same accelerator for any two different user events 5. A accelerator does not have to be associated with a menu item. It connects the keystrokes with your responding VC++ codes
VC++ Programming @ UESTC 9 ⚫ Step three: create keyboard accelerators 1. Click the Accelerator--IDR_MAINFRAME inside resource editor and you’ll see many IDs associated with Keys. 2. Inside the right panel, right click your mouse and click the “new accelerator” on the popup menu. You’ll see a popup “Accel Properties” window. 3. Choose a ID you may want to respond to. 4. Type a letter and choose any combination of modifiers. Don’t make the same accelerator for any two different user events. 5. A accelerator does not have to be associated with a menu item. It connects the keystrokes with your responding VC++ codes. Chapter 12 Menus, Keyboard Accelerators, the RichEdit Control and Property Sheets
VC++ Programming@UESTC Chapter 12 Menus, Keyboard Accelerators, the rich Edit Control and Property sheets Command Message Handling The Id connects the menu items to the message handling. Make menu items first, then map the associated Id to the application Use Class wizard to add command message handlers in view class Step One: Use the framework to make your life easier Choose the view class under the"Class Name 2. Select Objects ID you want to respond 3. Choose"COMMAND inside"Messages, panel and you' ll see a popup dialog window 4. Click Enter", and go to view class"*. h?and"*.cpp?to see what's added there Step two: add codes inside view class to do the real work 0
VC++ Programming @ UESTC 10 ⚫ Command Message Handling The ID connects the menu items to the message handling. Make menu items first, then map the associated ID to the application. Use ClassWizard to add command message handlers in view class. Step One: Use the framework to make your life easier 1. Choose the view class under the “Class Name”; 2. Select Object’s ID you want to respond; 3. Choose “COMMAND” inside “Messages” panel and you’ll see a popup dialog window; 4. Click “Enter”, and go to view class “*.h” and “*.cpp” to see what’s added there. Step two: add codes inside view class to do the real work. Chapter 12 Menus, Keyboard Accelerators, the RichEdit Control and Property Sheets