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

7.3 STEP 1 - Generate a Skeleton Application

In the following sections, we describe in detail how to generate a skeleton application by breaking the procedure into a number of smaller steps. Each step forms a subhead in this section, so that you can quickly navigate the procedure by reading the subheads.

7.3.1 Create a New Project

The first step in generating a skeleton application is to create a new Visual C++ project. To create a new project, follow this procedure:

  1. Start Visual Studio.

  2. Select File | New.

  3. In the New Project dialog box, select Visual C++ Projects, as shown in Figure 23.

    Figure 23: Visual Studio New Project Dialog

  4. Enter 1stEdit for the project name.

  5. Select MFC Application.

  6. Click OK. The AppWizard launches.

7.3.2 Choose AppWizard Options

Figure 24: Step 1 of the MFC AppWizard

Follow this procedure:

  1. Accept the defaults.

  2. Click Finish.

    This will generate the new project and the necessary files for you.

  3. If you are using Visual Studio 2010, please refer to Section 2.7.4, "Microsoft Visual Studio 2010 Changes," of the Stingray Studio Getting Started Guide to add property sheet(s) with Stingray Studio paths to the project.

Figure 25: Step 6 of the MFC AppWizard

7.3.3 Modify stdafx.h

Now that you have created a new project, the next step in generating a skeleton application is to modify the stdafx.h file. Here are the steps in this procedure:

  1. Open stdafx.h.

  2. Add the following line at the end of the file:

      #include "Edit\SECEditAll.h"
      

    This is the core Objective Edit header file. Once this file is added, all required classes are available to you inside your application.

7.3.4 Include Objective Edit Resources

You can now move on to the step of including Objective Edit resources in your skeleton application. To do so, follow this procedure:

  1. In Visual Studio, open the Resource View by clicking View|Resource View.

  2. Right-click on the .rc file, and select Resource Includes.

    You will see a window similar to Figure 26.

  3. Add the following line to Read-only symbol directives:

      #include "Edit\seceditres.h"
      

    This makes the resource symbols available to your application.

  4. Add the following line to Compile-time directives:

      #include "Edit\seceditres.rc"
      

    Note that this line is added outside of any #ifdefs that are present. The text boxes will appear as in Figure 26.

    Figure 26: The Resource Includes window

  5. Click OK.

  6. A message box, shown in Figure 27, warns that what you have just entered will be written verbatim into the resource script.

    Figure 27: Visual C++ verbatim text warning

  7. Click OK.

    The two previous steps, Modify stdafx.h (Section 7.3.3) and Include Objective Edit Resources (Section 7.3.4), are required for all your applications that use Objective Edit.

7.3.5 Modify the View's Header File

The next step in generating your skeleton application is to modify the view's header file. Here is the procedure:

  1. In Visual Studio, open 1stEditView.h.

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

  3. Delete these three function declarations:

      virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
      virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
      virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
      

    If you decide not to delete these, be sure to modify the implementation to call the SECEditView base class versions of these functions.

7.3.6 Modify the View's Implementation File

After you modify the view's header file, you must also modify the view's implementation file. Here is the procedure:

  1. In Visual Studio, open 1stEditView.cpp.

  2. Replace all occurrences of CView with SECEditView.

  3. Delete the implementation for these three functions because their functionality is already provided by the SECEditView class:

      virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
      virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
      virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
      
  4. You must also delete the message map entries for the previous functions:

      // Standard printing commands
      ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
      ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
      ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
      

    If you decide to leave these in, call the base class versions after you do your processing. If you leave these functions in, but do not call the base class, Objective Edit will crash when you try to do Printing or Print Preview.

7.3.7 Add an SECEdit Object to the C1stEditDoc Class

The next step in generating our skeleton application is to add an SECEdit object to the C1stEditDoc class. Open the file 1stEditDoc.h, and add a public member variable of type SECEdit as follows:

7.3.8 Override SECEditView::GetEdit()

You must now override the virtual function SECEditView::GetEdit() in your CMy1stEditView class. Here is the procedure:

  1. Right-click the mouse on the CMy1stEditView class.

  2. Select Add Member Function.

  3. In the Function Type box, add:

      SECEdit*
      
  4. In the function declaration, add:

      GetEdit()
      
  5. Make the function protected and virtual.

  6. As the body of this function, add:

      return &GetDocument()->m_Edit;
      

7.3.9 Override the Methods for Document Loading and Saving

There should already be an override of the method:

You must now add a call to m_Edit.Init() to the implementation, immediately before it returns TRUE. Here is how to do it:

You can use ClassWizard to add overrides for SaveModified(), OnOpenDocument(), and OnSaveDocument() to your CMy1stEditDoc class. The SaveModified() code will be written by the ClassWizard. Make the implementation for the OnOpenDocument() and OnSaveDocument() overrides as follows:

You will need to override IsModified() by yourself because you cannot do this through the ClassWizard.

7.3.10 Build and Run Step 1

You have reached the end of Step 1. You can now compile and run the application. Figure 28 shows the application in action.

Figure 28: 1stEdit showing Step 1 in action

Now let's discuss syntax highlighting.



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.