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

7.2 1stGrid - Step 1

Step 1 will guide you through the process of creating a skeleton application using a CGXGridView-derived view class.

7.2.1 Create a New 1stGrid Project

  1. Start up Microsoft Visual Studio.

  2. Select File|New | Project from the menu.

  3. The New dialog box appears.

  4. In the dialog, select the Visual C++ Projects folder.

  5. Enter 1stGrid for the Project name and <stingray-installdir>\Samples\Grid\Tutorial\1stgrid\1stgrid for the Location.

  6. Select MFC Application from the Templates list box.

    Figure 54: Visual C++| MFC New Project dialog

  7. Click OK.

7.2.2 1stGrid AppWizard Options

  1. The MFC Application Wizard dialog box will appear.

  2. If MFC 9 (Visual Studio 2008 SP1) or later version is not installed, accept the defaults for all steps. You can scan through the settings by clicking the links, or click Finish at any time to create the project.

  3. Otherwise, open Application Type page, then:

7.2.3 1stGrid Project Settings

This step specifies that the application should use Objective Grid as a shared library. You should skip this step if you want to link statically to the Objective Grid libraries.

  1. Select View|Solution Explorer from the menu.

  2. The Solution Explorer docking view appears.

  3. Right click on 1stgrid and select Properties.

  4. Expand the C/C++ node and select Preprocessor. Add _GXDLL to the Preprocessor definitions. This step indicates that the application will link dynamically to Objective Grid. Do not specify _GXDLL if you wish to link to Objective Grid as a static library. _GXDLL is similar to the _AFXDLL preprocessor in that _AFXDLL specifies that the application will link to MFC as a dynamic library.

    Figure 55: C/C++ Configuration Settings dialog

  5. Click OK.

7.2.4 Modify 1stGrid's stdafx.h

  1. Open stdafx.h.

  2. Add the following lines:

  3. Save and close stdafx.h.

7.2.5 Include Objective Grid Resources in 1stGrid

Including the Objective Grid resource header file in your application's resource script gives your application access to the Objective Grid Resources. When linking statically to the Objective Grid libraries, it is also necessary to include the Objective Grid resource script. The following steps demonstrate how to add the Objective Grid resource files to your project.

  1. Open the Resource View in Microsoft Visual Studio.

  2. Select the root of the Resource View tree (1stGrid.rc) and click with the right button on your mouse.

    A context menu pops up.

    Figure 57: Visual Studio Resource View

  3. Choose Resource Includes.

  4. The Resource Includes dialog box appears.

    Figure 58: Visual Studio Resource Includes dialog

  5. Add the following line to the Read-only symbol directives box.

  6. Add the following line to the end of the Compile-time directives box.


    Skip this step if your application is linking to Objective Grid as a shared library (DLL). Including the following file will not upset the function of your application, but it will cause unnecessary bloat to the final application file size. The Objective Grid resources are already included in Objective Grid DLLs and therefore do not need to be included in the application.

  7. Click OK.

  8. A message box pops up warning you that the "Directive text will be written verbatim into your resource script and may render it uncompilable." This is fine. You can safely choose OK.

  9. Save 1stGrid.rc (press CTRL+S).

7.2.6 Modify the 1stGrid Application Implementation File

GXInit() initializes resources and variables used by Objective Grid. It should be called from your application's InitInstance() to be sure Objective Grid is initialized before calling any Objective Grid functions. For more information about GXInit(), please refer to the Objective Grid Class Reference.

  1. Open 1stgrid.cpp and search for InitInstance().

  2. Add the following two lines to the beginning of InitInstance():

  3. Save and close 1stGrid.cpp.

7.2.7 Modify 1stGrid View's Header File

In this step, the application's view class is changed from a CView derivative to a CGXGridView derivative.

  1. Open 1stGridView.h.

  2. Change the derivation of the view by replacing all occurrences of CView with CGXGridView.

  3. Save and close 1stGridView.h.

7.2.8 Modify 1stGrid View's Implementation File

This step modifies the OnDraw(), OnBeginPrint(), and OnEndPrinting() methods to call the CGXGridView base class versions. This is essential for the Objective Grid view to work properly.

Note: You need to uncomment the parameter names for OnDraw(), OnBeginPrinting() and OnEndPrinting().

  1. Open 1stGridView.cpp.

  2. Replace all occurrences of CView with CGXGridView.

  3. Modify OnDraw() to call the CGXGridView implementation by replacing the // TODO: … line with:

  4. Modify OnBeginPrinting(…) to call the CGXGridView implementation by replacing the // TODO: … line with:

  5. Modify OnEndPrinting(…) to call the CGXGridView implementation by replacing the // TODO: … line with:

  6. Save 1stGridView.cpp.

7.2.9 Override CMy1stGridView::OnInitialUpdate()

OnInitialUpdate() is the primary location for initializing the grid object.

  1. Select View|Class View from the menu.

  2. Select the CMy1stGridView node under 1stGrid.

  3. Right click on CMy1stGridView and select Properties.

  4. Click Overrides in the properties box.

  5. Select <Add> OnInitialUpdate from the OnInitialUpdate field pull down combo box.

  6. The OnInitialUpdate() member function is added to the CMy1stGridView class.

  7. Replace the existing OnInitialUpdate() function with the following:

  8. Save and close 1stGridView.cpp.

7.2.10 Compile and Run 1stGrid - Step 1

If you are using Visual Studio 2010, you must add the user property sheet that defines paths needed by the project.

  1. Open the Propery Manager and expand the 1stGrid node to see the available build configurations.

  2. Right click on Debug|Win32 (or whatever configuration you want ot build with), and select Add Existing Property Sheet ...

    Figure 59: Add user property sheet defining Stingray Studio paths

  3. Navigate to the file SS-Win32-PropSheets.props in <stingray-installdir>\src and add this file to the project.

To complete this first step in the tutorial:

  1. Compile the application and run it.

  2. Interact with the grid object in the view.


    If the tutorial is run under Windows XP, the VC++ Application Wizard, by default, enables the XP Visual Styles. The Application Wizard does this by including a manifest resource pointing the application to COMCTRL32.DLL ver 6.0. If you would like the grid to work with XP Visual Styles, or any of the other supported Visual Styles, please refer to Section 4.3.4.1, "Vista Look and Feel."

  3. Figure 60: 1stGrid-Step 1 in action



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.