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

 

5th Step, Add the 3rd list of controls to IDD_TESTVC0_DIALOG dialog.


Declaration step ...
  • Search operation - to find all records include a word you specified.
  • List of controls to be add: two Static Texts, one Edit Box, one Push Button and one List control.

    Note:
    The
    controls to be appear in the 1st tab page of the Tab control.

Details ...


The IDD_TESTVC0_DIALOG dialog design, part 3.

Learn how to write a Visual C++ application ...

Note:
The label
of the 1st tab page is By Word.

  1. Add controls ...
    1. Add the Static Text - IDC_STATICTYPE, Text Properties:
      Right click the Static Text and click Properties on the shortcut menu to open the Text Properties dialog box.:
      General tab
      * ID:
      * Caption:
      *
      boxes checked
      Styles tab
      * Align text:

      IDC_STATICTYPE
      Type in the word to search for:
      Visible, Group

      left


    2. Add the Edit Box - IDC_EDWORD, Edit Properties:
      Right click the Edit Box and click Properties on the shortcut menu to open the Edit Properties dialog box:
      General tab
      * ID:
      *
      boxes checked
      Styles tab
      * Align text:
      * boxes checked

      IDC_EDWORD
      Visible, Tab stop

      left
      Auto Hscroll, Border


    3. Add the Push Button - IDC_DISPLAY, Push Button Properties:
      Right click the Button and click Properties on the shortcut menu to open the Push Button Properties dialog box:
      General tab
      * ID:
      * Caption:
      *
      boxes checked
      Styles tab
      * Horizontal alignment:
      * Vertical alignment:

      IDC_DISPLAY
      Display
      Visible, Disabled, Tab stop

      Default
      Default


    4. Add the List control - IDC_SEARCHLIST, List control Properties:
      Use a list control to display any arrangement of icons with labels, as in the Windows Explorer, or columnar lists of text, with or without icons.
      The CListCtrl class encapsulates the functionality of a “list view control,” which displays a collection of items each consisting of an icon (from an image list) and a label. In addition to an icon and label, each item can have information displayed in columns to the right of the icon and label.


      Right click the List and click Properties on the shortcut menu to open the List control Properties dialog box:
      General tab
      * ID:
      *
      boxes checked
      Styles tab
      * View:
      * align:
      * Sort:
      *
      box checked
      More styles
      *
      box checked

      IDC_SEARCHLIST
      Visible, Tab stop

      Report
      Top
      None
      Sigle Selection

      Border


    5. Add the Static Text - IDC_STATICFOUND, Text Properties:
      Right click the Static Text and click Properties on the shortcut menu to open the Text Properties dialog box:
      General tab
      * ID:
      *
      boxes checked
      Styles tab
      * Align text:

      IDC_STATICFOUND
      Visible, Group

      Default

    Note:
    The TestVC0.rc file stores information about all controls included in IDD_
    TESTVC0_DIALOG.
    Examine this information,
    click here.

  2. Multi - operation ...
    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_ STATICTYPE.
      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_statictype.
      6. In the Category drop-down list, select the appropriate type of variable - Control.
      7. In the Variable type drop-down list, select the appropriate class that defines the
        variable's data type - CStatic.
      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_EDWORD
      IDC_EDWORD
      IDC_DISPLAY
      IDC_SEARCHLIST
      IDC_STATICFOUND
      IDC_STATICFOUND
      IDC..
      m_edwordcontrol
      m_edword
      m_display
      m_searchlist
      m_staticfoundcontrol
      m_staticfound
      Control
      Value
      Control
      Control
      Control
      Value
      CEdit
      CString
      CButton
      CListCtrl
      CStatic
      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. Make these controls ...
      At the 1st time, make the last controls added visible in the 1st tab page and define the header
      row of the List control .
      When the user select the corresponding tab page make the controls visible or invisible.
      This operation make changes to TestVC0Dlg.h and TestVC0Dlg.cpp files. Examine these
      changes,
      click here.

    4. Save this application.
      Run
      it, from Build menu, choose and click Execute TestVC0.exe.
  3. Activate the Push Button - IDC_DISPLAY.
    • The button - IDC_DISPLAY set enable, when you type a word in the Edit box - IDC_EDWORD.
    • Click the IDC_DISPLAY, two types of information:
      1. A list of information about all records of the KJV database include the word you specified will appears in the List control - IDC_SEARCHLIST.
      2. The number of these records found appears in the IDC_STATICFOUND.

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


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

  4. Activate the List control - IDC_SEARCHLIST.
    Select an item of the List control. Into the Record data boxes displays the record corresponding to the item selected.
    This operation makes changes to TestVC0Dlg.h and TestVC0Dlg.cpp files. Examine these changes, click here.

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

Previous
Home 6 Home
Next