Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Grid User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

7.3 1stGrid - Step 2

7.3.1 Modify 1stGrid View's Menu Resource

This step adds new menu items for Redo, Find, and Properties.

  1. Open the 1stGrid project resources (1stGrid.rc).

    (To open resources in Visual Studio, select the View|Resource View from the menu.)

    Figure 61: Visual Studio Resource View

  2. Expand Menu in the resource tree and double click IDR_My1stGridTYPE.

  3. The IDR_My1stGridTYPE menu resource appears in a resource edit view.

    Figure 62: Visual Studio resource editor view

  4. Click Edit in the menu resource.

  5. Click the Separator after Undo.

  6. Right click and select Insert New.

  7. A blank menu item is inserted.

  8. Right click on the newly inserted item and select Properties.

  9. Type &Redo\tCtrl+R in the Caption field and ID_EDIT_REDO in the ID field.

  10. Press Enter.

    Figure 63: Redo Menu Item Properties dialog - Visual Studio

  11. Click the last empty menu item under Edit in the menu resource edit view.

  12. Right click and select Insert Seperator.

  13. Select the last empty menu item under Edit in the menu resource edit view.

  14. Right click the empty menu item and select Insert New.

  15. Right click the newly inserted item and select Properties.

  16. Type &Find...\tAlt+F3 in the Caption field. The ID for the menu item should be ID_EDIT_FIND.

    Figure 64: Find Menu Item Properties dialog - Visual Studio

    Figure 65: New Edit menu items

  17. Click View in the menu resource.

  18. Select the last empty menu item under View in the menu resource edit view.

  19. Right click and select Insert New.

  20. Type &Properties... in the Caption box.

  21. Set the ID for this item to ID_VIEW_PROPERTIES, then type Change Display Properties\nProperties in the Prompt box.

    Figure 66: View Menu Item Properties dialog with ID generated by Visual Studio

    Figure 67: New View menu item

  22. Close and save the resource file.

7.3.2 Map the 1stGrid Menu Messages

This step demonstrates how to map the new menu items from the previous step to message handlers in the view class. Objective Grid already provides handlers for Edit|Undo, Edit|Redo and Edit|Find in the CGXGridView class. Only the View|Properties menu needs to be mapped in this step.

The code provided in this section is more advanced than code presented in other sections. This is to give you a feel for the object oriented nature of Objective Grid. It also demonstrates the ease with which Objective Grid can be customized.

To understand the code below it may help to understand that the properties object is an instance of CGXProperties. CGXProperties stores display and print properties for the grid object. The property object is contained in the parameter object. Recall from the Design Overview section that the parameter object is analogous in some ways to the MFC CDocument. The parameter object is the data storehouse for the grid object in much the same way as the CDocument derived classes are for MFC applications. Also recall that parameter objects can be stored in MFC documents.

  1. Open the View|Class View menu.

  2. Right click CMy1stGridView and select Properties.

  3. Select the Events icon.

  4. Expand the ID_VIEW_PROPERTIES node.

  5. Click on the COMMAND field and select <Add> OnViewProperties from the combo box.

    The source file is opened in the editor and the OnViewProperties function is added.

    Figure 68: Adding the Properties menu handler

  6. Replace the following method in 1stgrvw.cpp:

7.3.3 Map the 1stGrid Accelerator Keys

This step maps accelerator keys to the new menu items. Note the fact that this editing can be done in two ways: directly in the Accelerator editor window, or in the associated Properties dialog.

  1. Open 1stgrid.rc (View|Resource View).

  2. Open Accelerator and double-click IDR_MAINFRAME.

  3. The Accelerator editor window appears.

    Figure 69: Visual Studio accelerator table editor

  4. Double click the last empty line in the Accelerator table.

    The Properties dialog box appears.

  5. In the Accelerator table, select ID_EDIT_FIND in the combo box for the ID column.

  6. Click in the Modifiers column, and select Alt from the combo box. This causes Alt to be set to True in the Properties dialog, and Shift and Ctrl to be set to False.

  7. Click in the Key column and select VK_F3 from the combo box.

    Figure 70: Accelerator Properties dialog -- Find

  8. Press Enter.

  9. Double-click on the last empty line of the Accelerator table.

    The Properties dialog box appears again.

  10. In the Accelerator table, select ID_EDIT_REDO in the ID combo box.

  11. In the Behavior group of the Properties dialog, set Ctrl to False, and Shift and Alt to True.

  12. Type R in the Key text field.

    Figure 71: Accelerator Properties dialog -- Redo

  13. Press Enter.

  14. Close and save the resource file.

7.3.4 More Formatting

This step initializes the grid view. You can find a complete listing of the code changes for this step in 1stGrid\Step2 sample available from the Rogue Wave Web site, as explained in Section 3.6.1, "Location of Sample Code," in the Stingray Studio Getting Started Guide. Also refer to the comments in the code below for an explanation of its purpose.

  1. Open 1stGridView.cpp.

  2. Add the following code to OnInitialUpdate() immediately before the line with GetParam()->EnableUndo(TRUE).

7.3.5 Compile and Run 1stGrid - Step 2

At this point, you can compile and run the 1stGrid application.

  1. Use the Edit|Find menu command to type in text, undo and redo your changes and search text.

  2. Compile the application and run it.

    Figure 72: 1stGrid-Step 2 in action


    You can copy menu items from gridapp.rc in <stingray-installdir>\Samples\Grid\General\GridApp to your application. Open gridapp.rc and take a look at the IDR_GRIDAPTYPE menu resource and copy the menu items you would like to support in your own application. The file mygridvw.cpp in \samples\grid\general\gridapp contains code that you may want to include in your view class for menu handlers.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.