Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 20: List-Based Controls


A check box that has the Tri-State property set or the BS_3STATE style, can appear
checked, unchecked, or dimmed. When using this kind of check box, the user may have
to click the control three times in order to get the necessary state.

Practical Learning: Creating Check Boxes



  1. Add a new Dialog resource to the application

  2. Change its ID to IDD_INGREDIENTS and its Caption to Ingredients Selection
    Here is how you will design it:

  3. Add a Group Box control to the dialog box and delete its caption

  4. On the Controls toolbox, click the Check Box button and click inside the newly
    added group box

  5. Change its ID to IDC_CHK_LETTUCE and change its Caption to &Lettuce

  6. Set its Left Text to True or checked

  7. Add another check box under the first one. Set its ID to IDC_CHK_ONION, its
    Caption to &Onion, and its Left Text property to True

  8. Add another check box under the first one. Set its ID to IDC_CHK_TOMATO, its
    Caption to &Tomato, and its Left Text property to True

  9. Add another check box under the first one. Set its ID to IDC_CHK_PICKLES, its
    Caption to &Pickle, and its Left Text property to True

  10. Add a class for the dialog box based on CDialog and named CIngredientsDlg

  11. Add a Value variable for each check box as follows:


ID Value Variable ID Value Variable
IDC_CHK_LETTUCE m_bLettuce IDC_CHK_ONION m_bOnion
Free download pdf