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

3.4 Creating Code for the Toolbar

Now we need to add some new toolbar commands and write handlers for those commands.


The following procedure is applicable if the MFC feature pack is not used. Otherwise, see the document <stingray-installdir>\Docs\Stingray Feature Pack Migration, and the sample <stingray-installdir>\Samples\FoundationEx\ShowcaseEx.

  1. First, let's add the toolbar to the frame window. Declare the new toolbar in the CMainFrame class:

  2. To create the toolbar, you need to add some code to the frame window class in the source file. Find the CMainFrame::OnCreate() method and update it as follows. Make sure you add this code before the EnableDocking(CBRS_ALIGN_ANY) call.

  3. The EnableDocking member function of the newly created toolbar must be called:

  4. Add the following code after the EnableDocking(CBRS_ALIGN_ANY) call:

  5. Now add command handlers for the commands on the toolbar. The ID_OD_DRAW_SELECT and ID_OD_LINK_SYMBOLS commands already have handlers in the Objective Views CODController class. The controller is the piece of the canvas that handles events and translates them into actions. The AppWizard generated a controller class called CSimpleController for our project, derived from the CODController class. You need to add command handlers to the CSimpleController class to insert your custom symbols.

    Add the following function declarations to CSimpleController:

    Add the following entries to the CSimpleController message map:

    Add the implementation of the command handlers to the CSimpleController .cpp file.

  6. Now you're ready to compile the application and execute it. Your compiled application should appear as in Figure 30.

    Figure 30: Sample compiled application

Experiment with your new application. Create the canvas in Figure 31 using the tool buttons you just created.

Figure 31: Sample canvas



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.