Application developed with Microsoft Visual C++, Part 4.


The Code files ...


  1. Add the MFC database support - afxdao.h.
    StdAfx.cpp and StdAfx.h files are used to build a precompiled header file (.PCH) and a precompiled types file StdAfx.obj.
    Add the MFC database support - afxdao.h in the StdAfx.h file. Examine this operation,
    click here.

    Note:
    afxdao.h definies the DAO database class.


  2. ClassWizard - add member variables.

    ClassWizard is like a programmer's assistant: it makes it easier for you to do certain routine tasks such as creating new classes, defining message handlers, overriding MFC virtual functions, and gathering data from controls in a dialog box, form view, or record view.
    MFC defines a mechanism that automates the process of gathering values from a dialog box, this mechanism is called a “data map.” In the same way that a message map binds a user-interface element with a member function, a data map binds a dialog-box control with a member variable. The value of the member variable reflects the status or the contents of the control.
    The newly-generated .clw file contains information about all the classes that have the special-format ClassWizard comments.

    1. Add member Varaiables.
      1. On the View menu, click ClassWizard.
        The MFC ClassWizard dialog box appears, click the Member Variables tab.

        Note:
        This tab, contains a list box displaying the mapping between controls and member variables.
      2. In the Class name box, select the class CTestVC0Dlg.
      3. Select the name of the Control ID you want to add a variable - IDC_ BOOK.
      4. Click Add Variable, the Add Member Variable dialog box appears.
      5. In the Member variable name text box, type the name of the variable - m_book.
      6. In the Category drop-down list, select the appropriate type of variable - Value.
      7. In the Variable type drop-down list, select the appropriate class that defines the
        variable's data type - CString.
      8. Click OK.

        Note:
        The member name and type you specified now appear in the Control IDs list.

      Repeat steps 3 through to 8 to add a member Variable for other controls:

      Control IDs Member Variable name Category Variable Type
      IDC_TITLE
      IDC_CHAPTER
      IDC_VERSE
      IDC_TEXTDATA
      ...
      m_title
      m_chapter
      m_verse
      m_textdata
      Value
      Value
      Value
      Value
      CString
      CString
      CString
      CString


    2. ClassWizard makes changes to TestVC0Dlg.h and TestVC0Dlg.cpp files after you’ve mapped
      the controls to member variables. Examine these changes,
      click here.

    3. Save this application.
      Run
      it, from Build menu, choose and click Execute TestVC0.exe.
  3. Initialize the database operation.

    1. At the 1st time , the 2nd record of the KJV database displays into the Record data boxes.

      Note:
      The first record of the KJV database stores general information.

      This operation
      makes changes to TestVC0Dlg.h and TestVC0Dlg.cpp files. Examine these
      changes,
      click here.

    2. Save this application.
      Run
      it, from Build menu, choose and click Execute TestVC0.exe.
  4. Activate the navigation operations/functions - OnRecordFirst, OnRecordPrev, OnRecordNext and OnRecordLast.

    1. To move the current record position to the first, last, next, or previous record. Using the
      Push Button -
      IDC_RECORD_FIRST, IDC_RECORD_PREV, IDC_RECORD_NEXT or IDC_RECORD_LAST.
      Examine these operations, click here.

    2. Save this application.
      Run
      it, from Build menu, choose and click Execute TestVC0.exe.
  5. Activate the Link operation , Push Button - IDC_ABOUT.

    1. To load the IDD_ABOUTBOX dialog, using the Push Button - IDC_ABOUT. Examine this
      operation,
      click here.

    2. Save this application.
      Run
      it, from Build menu, choose and click Execute TestVC0.exe.

Previous
Home 4 Home
Next