Home

Windows Controls: Check Boxes

  

Introduction Check Boxes

 

Description

A check box is a Windows control that allows the user to set or change the value of an item as true or false. The control appears as a small square Check Box. When this empty square is clicked, it gets marked by a check symbol Check Box. These two states control the check box as checked Check Box or unchecked Check Box.

Like a radio button, a check box does not indicate what it is used for. Therefore, it is usually accompanied by a caption that displays an explicit and useful string. The caption can be positioned on either part of the square box, depending on the programmer who implemented it.

Unlike the radio buttons that implement a mutual-exclusive choice, a check box can appear by itself or in a group. When a check box appears in a group with other similar controls, it assumes a completely independent behavior and it must be implemented as its own entity. This means that clicking a check box has no influence on the other controls.

Practical LearningPractical Learning: Introducing Check Boxes

  1. To start a new application, on the main menu, click File -> New Project...
  2. In the middle list, click MFC Application and set the name to PayrollEvaluation
  3. Press Enter
  4. In the first page of the MFC Application Wizard, click Next
  5. In the second page, click Dialog Based and click Next
  6. Click Finish
  7. Design the dialog box as follows:
     
    PayrollEvaluation
    Control Caption ID Align Left
    Static Text Static Text Employee Name:    
    Edit Control Edit Control   IDC_EMPLOYEE_NAME  
    Static Text Static Text Hourly Salary:    
    Edit Control Edit Control   IDC_HOURLY_SALARY  
    Picture Control Picture Control      
    Static Text Static Text Monday    
    Static Text Static Text Tuesday    
    Static Text Static Text Wednesday    
    Static Text Static Text Thursday    
    Static Text Static Text Friday    
    Static Text Static Text Saturday    
    Static Text Static Text Sunday    
    Static Text Static Text Week 1:    
    Edit Control Edit Control   IDC_WEEK1MONDAY Right
    Edit Control Edit Control   IDC_WEEK1TUESDAY Right
    Edit Control Edit Control   IDC_WEEK1WEDNESDAY Right
    Edit Control Edit Control   IDC_WEEK1THURSDAY Right
    Edit Control Edit Control   IDC_WEEK1FRIDAY Right
    Edit Control Edit Control   IDC_WEEK1SATURDAY Right
    Edit Control Edit Control   IDC_WEEK1SUNDAY Right
    Static Text Static Text Week 2:    
    Edit Control Edit Control   IDC_WEEK2MONDAY Right
    Edit Control Edit Control   IDC_WEEK2TUESDAY Right
    Edit Control Edit Control   IDC_WEEK2WEDNESDAY Right
    Edit Control Edit Control   IDC_WEEK2THURSDAY Right
    Edit Control Edit Control   IDC_WEEK2FRIDAY Right
    Edit Control Edit Control   IDC_WEEK2SATURDAY Right
    Edit Control Edit Control   IDC_WEEK2SUNDAY Right
    Picture Control Picture Control      
    Static Text Static Text Time    
    Static Text Static Text Pay Amount    
    Button Button Calculate IDC_CALCULATE  
    Static Text Static Text Regular:    
    Edit Control Edit Control   IDC_REGULARTIME Right
    Edit Control Edit Control   IDC_REGULARPAY Right
    Static Text Static Text Net Pay    
    Edit Control Edit Control   IDC_NETPAY Right
    Static Text Static Text Overtime:    
    Edit Control Edit Control   IDC_OVERTIME Right
    Edit Control Edit Control   IDC_OVERTIMEPAY Right
  8. Right-click each of the edit controls and click Add Variable... Then create the variables as follows:
     
    ID
    Category Type Name
    IDC_EMPLOYEE_NAME Value CString m_EmployeeName
    IDC_HOURLY_SALARY Value double m_HourlySalary
    IDC_WEEK1MONDAY Value double m_Week1Monday
    IDC_WEEK1TUESDAY Value double m_Week1Tuesday
    IDC_WEEK1WEDNESDAY Value double m_Week1Wednesday
    IDC_WEEK1THURSDAY Value double m_Week1Thursday
    IDC_WEEK1FRIDAY Value double m_Week1Friday
    IDC_WEEK1SATURDAY Value double m_Week1Saturday
    IDC_WEEK1SUNDAY Value double m_Week1Sunday
    IDC_WEEK2MONDAY Value double m_Week2Monday
    IDC_WEEK2TUESDAY Value double m_Week2Tuesday
    IDC_WEEK2WEDNESDAY Value double m_Week2Wednesday
    IDC_WEEK2THURSDAY Value double m_Week2Thursday
    IDC_WEEK2FRIDAY Value double m_Week2Friday
    IDC_WEEK2SATURDAY Value double m_Week2Saturday
    IDC_WEEK2SUNDAY Value double m_Week2Sunday
    IDC_REGULARTIME Value double m_RegularTime
    IDC_REGULARPAY Value double m_RegularPay
    IDC_NETPAY Value double m_NetPay
    IDC_OVERTIME Value double m_Overtime
    IDC_OVERTIMEPAY Value double m_OvertimePay

Creating a Check Box

To provide a check box to an application, on the Toolbox, click the Check Box button and click the desired area on the dialog box. If you require more than one check box, you can keep adding them as you judge necessary.

Like the radio button, a check box is based on the CButton class. Therefore, to programmatically create a check box, declare CButton variable or pointer using its constructor. Here is an example:

CButton *HotTempered = new CButton;

After declaring a variable or a pointer to CButton, you can call its Create() member function to initialize the control. The syntax is the same as for the radio button. To make the button a check box, its style must include the BS_CHECKBOX style. If you want the control to display or hide a check mark when it gets clicked, create it with the BS_AUTOCHECKBOX style.

Like the radio button, a check box is a button with just a different style. Therefore, it shares the same characteristics as the radio button. This means that we can simply avoid repeating the descriptions we reviewed for the radio control.

Characteristics of a Check Box

 

The Caption of a Check Box

To indicate what it is used for, a check box should be accompanied by static, which is its caption. The caption appears to the left or the right side of the square box.

To visually specify the caption, after selecting the check box on the dialog box, in the Properties window, click Caption and type the desired string. If you are programmatically creating the check box, pass its caption as the first argument of the Create() member function. Here are examples:

BOOL CExample1Dlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();

    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);			// Set big icon
    SetIcon(m_hIcon, FALSE);		// Set small icon

    // TODO: Add extra initialization here
    CButton *chkDay[5];

    chkDay[0] = new CButton;
    chkDay[0]->Create(_T("&Monday"),
    		      WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
		      CRect(10, 5, 140, 35), this, 0x11);
    chkDay[1] = new CButton;
    chkDay[1]->Create(_T("&Tuesday"),
    		      WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
		      CRect(10, 40, 140, 55), this, 0x12);
    chkDay[2] = new CButton;
    chkDay[2]->Create(_T("&Wednesday"),
    		      WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
		      CRect(10, 65, 140, 85), this, 0x13);
    chkDay[3] = new CButton;
    chkDay[3]->Create(_T("&Thursday"),
    		      WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
		      CRect(10, 95, 140, 110), this, 0x14);
    chkDay[4] = new CButton;
    chkDay[4]->Create(_T("&Friday"),
     		      WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
		      CRect(10, 120, 140, 140), this, 0x15);
		      
    return TRUE;  // return TRUE  unless you set the focus to a control
}

Check Boxes

Practical LearningPractical Learning: Adding a Check Box to a Project

  1. Add a check box to the dialog box as follows:
     
    Payroll Evaluation
    Control Caption ID
    Check Box Check Box Consider Overtime IDC_CONSIDER_OVERTIME
  2. Right-click the check box and click Add Variable...
  3. Keep the Category as Control and set the Variable Name to m_ConsiderOvertime

    Add Member Variable
  4. Click Finish

Using a Check Box

To use a check box, the user can click it. When this is done, the control sends a BN_CLICKED message. In some cases, it can also send a BN_DOUBLECLICKED message, which originates when the user double-clicks the control. If you need to, you can use either the events of the parent window or hand code the messages yourself.

A Tri-State Check Box

To use a check box, the user cal click it. As a result, a check box can be checked or unchecked. The check box as a control adds a third state for its appearance. Instead of definitely appearing as checked or unchecked, a check box can appear "half-checked". This is considered as a third state. To visually apply this behavior to a check box, set its Tri-State property to True or add the BS_3STATE style to it:

Check Boxes

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.

Selecting a Check Box

To let you programmatically check or uncheck the control, you have two uptions: The CWnd or the CButton class. The CWnd class provides the CheckDlgButton() member function whose syntax is:

void CheckDlgButton( int nIDButton, UINT nCheck );

The nIDButton argument is the identifier of the check box whose state you want to modify. The nCheck argument is the value to apply. It can have one of the following values:

State Value Description
BST_UN CHECKED The check mark will be completely removed
BST_ CHECKED The button will be checked
BST_INDETERMINATE A dimmed checked mark will appear in the control's square. If the Tri-State property is not set or the BS_3STATE style is not applied to the control, this value will be ignored

Here is an example that automatically sets a check box to a dimmed appearance when the dialog box comes up:

BOOL CCheckBoxes::OnInitDialog()
{
    CDialog::OnInitDialog();

    // TODO: Add extra initialization here
    CheckDlgButton(IDC_CHECK_PHYSICAL, BST_INDETERMINATE);

    return TRUE; // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}

Alternatively, to change the state of a check box, you can call the CButton::SetCheck() and pass of the above state values. For a check box, to set a dimmed check mark, here is an example:

BOOL CCheckBoxes::OnInitDialog()
{
    CDialog::OnInitDialog();

    // TODO: Add extra initialization here
    CButton *ChkPhysical = new CButton;

    ChkPhysical = reinterpret_cast<CButton *>(GetDlgItem(IDC_CHECK_PHYSICAL));
    ChkPhysical->SetCheck(BST_INDETERMINATE);

    return TRUE; // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}

To get the current state of a check box, you can call the CWnd::IsDlgButtonChecked() member function. If a check mark appears in the square box, this member function will return 1. If the square box is empty, this member function returns 0. If the check box control has the BS_3STATE style, the member function can return 2 to indicate that the check mark that appears in the square box is dimmed.

 
 
 

Practical LearningPractical Learning: Using a Check Box

  1. In the Class View, right-click CPayrollEvaluationDlg -> Add -> Function...
  2. Set the Return Type to void
  3. Set the Function Name to CalculateWithoutOvertime
  4. Click Finish
  5. Implement the event as follows:
    void CPayrollEvaluationDlg::CalculateWithoutOvertime(void)
    {
    	double TimeTotal = m_Week1Monday + m_Week1Tuesday + m_Week1Wednesday +
    		           m_Week1Thursday + m_Week1Friday + m_Week1Saturday +
    			   m_Week1Sunday + m_Week2Monday + m_Week2Tuesday +
    			   m_Week2Wednesday + m_Week2Thursday + m_Week2Friday +
    			   m_Week2Saturday + m_Week2Sunday;
    
    	m_RegularTime = TimeTotal;
    	m_Overtime    = 0.00;
    	m_RegularPay  = m_HourlySalary * TimeTotal;
    	m_OvertimePay = 0.00;
    	m_NetPay      = m_HourlySalary * TimeTotal;
    }
  6. In the Class View, right-click CPayrollEvaluationDlg -> Add -> Function...
  7. Set the Return Type to void
  8. Set the Function Name to CalculateWithOvertime
  9. Click Finish
  10. Implement the event as follows:
    void CPayrollEvaluationDlg::CalculateWithOvertime(void)
    {
        double Week1TotalTime, Week2TotalTime;
    
        double Week1RegularTime = 0.00, Week2RegularTime = 0.00,
    	   Week1Overtime = 0.00, Week2Overtime = 0.00;
        double Week1RegularAmount = 0.00, Week2RegularAmount = 0.00,
    	   Week1OvertimeAmount = 0.00, Week2OvertimeAmount = 0.00;
    	
        // Calculate the total number of hours for each week
        Week1TotalTime = m_Week1Monday + m_Week1Tuesday +
    		 m_Week1Wednesday + m_Week1Thursday +
    		 m_Week1Friday + m_Week1Saturday + m_Week1Sunday;
        Week2TotalTime = m_Week2Monday + m_Week2Tuesday +
    		 m_Week2Wednesday + m_Week2Thursday +
    		 m_Week2Friday + m_Week2Saturday + m_Week2Sunday;
    
        // The overtime is paid time and half
        double OvertimeSalary = m_HourlySalary * 1.5;
    
        // If the employee worked under 40 hours, there is no overtime
        if( Week1TotalTime < 40 )
        {
    	Week1RegularTime  = Week1TotalTime;
    	Week1RegularAmount = m_HourlySalary * Week1RegularTime;
    	Week1Overtime  = 0.00;
    	Week1OvertimeAmount = 0.00;
        } // If the employee worked over 40 hours, calculate the overtime
        else if( Week1TotalTime >= 40 )
        {
    	Week1RegularTime  = 40;
    	Week1RegularAmount = m_HourlySalary * 40;
    	Week1Overtime  = Week1TotalTime - 40;
    	Week1OvertimeAmount = Week1Overtime * OvertimeSalary;
        }
    
        if( Week2TotalTime < 40 )
        {
    	Week2RegularTime  = Week2TotalTime;
    	Week2RegularAmount = m_HourlySalary * Week2RegularTime;
    	Week2Overtime  = 0.00;
    	Week2OvertimeAmount = 0.00;
        }
        else if( Week2TotalTime >= 40 )
        {
    	Week2RegularTime  = 40;
    	Week2RegularAmount = m_HourlySalary * 40;
    	Week2Overtime  = Week2TotalTime - 40;
    	Week2OvertimeAmount = Week2Overtime * OvertimeSalary;
        }
    	
        m_RegularTime = Week1RegularTime  + Week2RegularTime;
        m_Overtime    = Week1Overtime  + Week2Overtime;
        m_RegularPay  = Week1RegularAmount + Week2RegularAmount;
        m_OvertimePay = Week1OvertimeAmount + Week2OvertimeAmount;
        m_NetPay      = m_RegularPay + m_OvertimePay;
    }
  11. Return to the dialog box and double-click the Calculate button
  12. Implement its event as follows:
    void CPayrollEvaluationDlg::OnBnClickedCalculate()
    {
    	// TODO: Add your control notification handler code here
    	UpdateData();
    
    	if( m_EmployeeName == _T("") )
    	{
    		MessageBox(_T("You must specify the name of the employee"),
    				   _T("Payroll Evaluation"));
    		return;
    	}
    	else
    	{
    		if( m_ConsiderOvertime.GetCheck() == BST_UNCHECKED )
    			CalculateWithoutOvertime();
    		else
    			CalculateWithOvertime();
    	}
    
    	UpdateData(FALSE);
    }
  13. To execute, press F5
  14. Enter an employee name and a few values in the edit controls
     
    Payroll Evaluation
  15. Click Calculate
     
    Payroll Evaluation
  16. Click the check box
  17. Click Calculate
     
    Payroll Evaluation
  18. Close the dialog box and return to your programming environment

The Caption Alignment

By default, the caption of a check box is positioned to the right side of the square box. If you want to visually position the caption to the left, in the Properties window, set the Left Align value to True. If you are programmatically creating the check box, add the BS_LEFTTEXT style.

To let you control the horizontal and the vertical alignments of the caption, use the Horizontal Alignment or the Vertical Alignment field in the Properties window.

Practical LearningPractical Learning: Creating Check Boxes

  1. Display the dialog box and click the check box
  2. In the Properties window, double-click Left Text to set its value to True
     
    Payroll Evaluation
  3. Press F5 to execute
  4. Close the dialog box and return to your programming environment

The Push Check Box

We saw that a radio button can appear as a regular command button with 3-D borders. This feature is also available for check boxes. To visually apply it, after selecting the check box on the dialog box, in the properties window, set the desired value to the Push Like property. If you set it to True, the check box appears as a rectangular button. In this case, when a check box is up and it gets clicked, it stays down until it is clicked again, regardless of the appearance of the other controls (remember that a check box behaves independently of the other controls even if it appears in a group).

Practical LearningPractical Learning: Implementing the Push Check Boxes

  1. To start a new application, on the main menu, click File -> New Project...
  2. In the middle list, click MFC Application and set the name to BooleanAlgebra
  3. Click OK
  4. In the first page of the MFC Application Wizard, click Next
  5. In the second page, click Dialog Based and click Next
  6. In the third page of the wizard, set the title to Boolean Algebra
  7. Click Finish
  8. Click the TODO line and press Delete
  9. While the OK is selected, press Delete
  10. Change the caption of the Cancel button to Close
  11. Design the dialog box as follows:
     
    Boolean Algebra
    Control Caption ID Push Like
    Static Text Static Text A    
    Static Text Static Text B    
    Static Text Static Text A ^ B IDC_OPERATION  
    Check Box Check Box False IDC_OPERAND1 True
    Check Box Check Box False IDC_OPERAND2 True
    Check Box Check Box False IDC_RESULT True
    Button Button New Operation IDC_NEW_OPERATION  
    Button Button Check IDC_CHECK  
    Button Button Close IDCANCEL  
  12. Right-click each of the check boxes and the top-right static text and click Add Variable... Then create the variables as follows:
     
    ID
    Category Type Name
    IDC_OPERAND1 Control CButton m_Operand1
    IDC_OPERAND2 Control CButton m_Operand2
    IDC_RESULT Control CButton m_Result
    IDC_OPERATION Value CString m_Operation
  13. Double-click the most left check box on the dialog box
  14. Implement the event as follows:
    void CBooleanAlgebraDlg::OnBnClickedOperand1()
    {
        // TODO: Add your control notification handler code here
        if( m_Operand1.GetCheck() == 1 )
    	m_Operand1.SetWindowTextW(_T("True"));
        else
    	m_Operand1.SetWindowTextW(_T("False"));
    }
  15. Return to the dialog box
  16. Double-click the middle check box
  17. Implement the event as follows:
    void CBooleanAlgebraDlg::OnBnClickedOperand2()
    {
        // TODO: Add your control notification handler code here
        if( m_Operand2.GetCheck() == 1 )
    	m_Operand2.SetWindowTextW(_T("True"));
        else
    	m_Operand2.SetWindowTextW(_T("False"));
    }
  18. Return to the dialog box and double-click the Result check box
  19. Implement its event as follows:
    void CBooleanAlgebraDlg::OnBnClickedResult()
    {
        // TODO: Add your control notification handler code here
        if( m_Result.GetCheck() == 1 )
    	m_Result.SetWindowTextW(_T("True"));
        else
    	m_Result.SetWindowTextW(_T("False"));
    }
  20. Return to the dialog box and double-click the New Operation button
  21. Implement its event as follows:
    void CBooleanAlgebraDlg::OnBnClickedNewOperation()
    {
    	// TODO: Add your control notification handler code here
    	// Prepare to generate a random number
    	UpdateData();
    	srand(time(NULL));
    	// These array will be used for random operations
    	CString strBooleanValues[] = { _T("True"), _T("False"), _T("Unknown") };
    	CString strOperations[] = { _T("A ^ B"), _T("A V B"), _T("") };
    
    	// Create a string for the first operand and get a random number for it
    	CString strOperand1;
    	strOperand1.Format(_T("%s"), strBooleanValues[rand() % 2]);
    	// Show the random value in the left operand
    	m_Operand1.SetWindowTextW(strOperand1);
    
    	// Get the current caption of the left operand
    	m_Operand1.GetWindowTextW(strOperand1);
    
    	// Set the state of the left check box depending on its caption
    	if( strOperand1 == _T("True") )
    		m_Operand1.SetCheck(1);
    	else
    		m_Operand1.SetCheck(0);
    	
    	// Create a (random) caption for the right operand
    	CString strOperand2;
    	strOperand2.Format(_T("%s"), strBooleanValues[rand() % 2]);
    	// Display that caption
    	m_Operand2.SetWindowTextW(strOperand2);
    
    	// Get the current caption of the right check box
    	m_Operand2.GetWindowTextW(strOperand2);
    	
    	// Change the state of the right check box depending on its caption
    	if( strOperand2 == _T("True") )
    		m_Operand2.SetCheck(1);
    	else
    		m_Operand2.SetCheck(0);
    
    	// Create a caption for the result, using a random value
    	CString strResult;
    	strResult.Format(_T("%s"), strOperations[rand() % 2]);
    	// Display the caption
    	m_Operation = strResult;
    
    	UpdateData(FALSE);
    }
  22. Scroll up in the file and locate the OnInitDialog() event
  23. Call the event of the New Operation button as follows:
    BOOL CBooleanAlgebraDlg::OnInitDialog()
    {
        CDialogEx::OnInitDialog();
    
        // Set the icon for this dialog.  The framework does this automatically
        //  when the application's main window is not a dialog
        SetIcon(m_hIcon, TRUE);			// Set big icon
        SetIcon(m_hIcon, FALSE);		// Set small icon
    
        // TODO: Add extra initialization here
        OnBnClickedCheck();
        
        return TRUE;  // return TRUE  unless you set the focus to a control
    }
  24. Return to the dialog box and double-click the Check button
  25. Implement its event as follows:
    void CBooleanAlgebraDlg::OnBnClickedCheck()
    {
        // TODO: Add your control notification handler code here
        // Logical Conjunction
        if( m_Operation == _T("A ^ B") )
        {
    	// If A = true
            if (m_Operand1.GetCheck() == true )
            {
                if( m_Operand2.GetCheck() == true )
    	    {
                    if( m_Result.GetCheck() == true )
    		{
                        // | A | B | A ^ B |
                        // | T | T |   T   |
                         MessageBox(_T("Bravo - Good Answer"),
                         		_T("Boolean Algebra"));
                    }
                    else  if( m_Result.GetCheck() == false)
                    {
                        // | A | B | A ^ B |
                        // | T | T |   F   |
                        MessageBox(_T("Wrong - Get it right next time!"),
                        	       _T("Boolean Algebra"));
                    }
                }
                else if (m_Operand2.GetCheck() == false)
                {
                    if( m_Result.GetCheck() == false)
                    {
                        // | A | B | A ^ B |
                        // | T | F |   F   |
                         MessageBox(_T("Bravo - Good Answer"),
                         		    _T("Boolean Algebra"));
                    }
                    else  if( m_Result.GetCheck() == true)
                    {
                        // | A | B | A ^ B |
                        // | T | F |   T   |
                        MessageBox(_T("Wrong - Get it right next time!"),
                        	       _T("Boolean Algebra"));
                    }
                }
            }
            else  if( m_Operand1.GetCheck() == false )
            {
                if (m_Operand2.GetCheck() == true)
                {
                    if( m_Result.GetCheck() == false)
                    {
                        // | A | B | A ^ B |
                        // | F | T |   F   |
                         MessageBox(_T("Bravo - Good Answer"),
                         		_T("Boolean Algebra"));
                    }
                    else  if( m_Result.GetCheck() == true )
                    {
                        // | A | B | A ^ B |
                        // | F | T |   T   |
                        MessageBox(_T("Wrong - Get it right next time!"),
                        	       _T("Boolean Algebra"));
                    }
                }
                else  if (m_Operand2.GetCheck() == false)
                {
                    if( m_Result.GetCheck() == false)
                    {
    					// | A | B | A ^ B |
                        // | F | F |   F   |
                        MessageBox(_T("Bravo - Good Answer"),
                        	       _T("Boolean Algebra"));
    				}
                    else  if( m_Result.GetCheck() == true)
                    {
    					// | A | B | A ^ B |
                        // | F | F |   T   |
                        MessageBox(_T("Wrong - Get it right next time!"),
                        	       _T("Boolean Algebra"));
    		}
                }
            }
    	}
    	else if (m_Operation == "A V B") // Logical Disjunction:
    	{
    		// If A = true
            if (m_Operand1.GetCheck() == true)
    	{
                if (m_Operand2.GetCheck() == true)
    	    {
                    if( m_Result.GetCheck() == true)
    		{
                        // | A | B | A V B |
                        // | T | T |   T   |
    		    MessageBox(_T("Bravo - Good Answer"),
    		    		_T("Boolean Algebra"));
                    }
                    else if( m_Result.GetCheck() == false)
    		{
                        // | A | B | A V B |
                        // | T | T |   F   |
    		    MessageBox(_T("Wrong - Get it right next time!"),
    		    	       _T("Boolean Algebra"));
                    }
                }
    	    else if (m_Operand2.GetCheck() == false)
                {
    		if( m_Result.GetCheck() == true)
                    {
                        // | A | B | A V B |
    		    // | T | F |   T   |
                        MessageBox(_T("Bravo - Good Answer"),
                        	       _T("Boolean Algebra"));
                    }
    		else if( m_Result.GetCheck() == false)
                    {
                        // | A | B | A V B |
    					// | T | F |   F   |
                        MessageBox(_T("Wrong - Get it right next time!"),
                        	       _T("Boolean Algebra"));
                    }
    	    }
            }
    	else if (m_Operand1.GetCheck() == false)
            {
    	    if (m_Operand2.GetCheck() == true)
                {
    		if( m_Result.GetCheck() == true)
                    {
                        // | A | B | A V B |
    		    // | F | T |   T   |
                        MessageBox(_T("Bravo - Good Answer"),
                        	       _T("Boolean Algebra"));
                    }
    		    else if( m_Result.GetCheck() == false)
                    {
                        // | A | B | A V B |
    		    // | F | T |   F   |
                        MessageBox(_T("Wrong - Get it right next time!"),
                        	       _T("Boolean Algebra"));
                    }
    	    }
                else if (m_Operand2.GetCheck() == false)
    	    {
                    if( m_Result.GetCheck() == false)
    		{
                        // | A | B | A V B |
                        // | F | F |   F   |
    		    MessageBox(_T("Bravo - Good Answer"),
    		    	       _T("Boolean Algebra"));
                    }
                    else if( m_Result.GetCheck() == true)
    		{
                        // | A | B | A V B |
    		    // | F | F |   T   |
                        MessageBox(_T("Wrong - Get it right next time!"),
                        	       _T("Boolean Algebra"));
                    }
    	    }
            }
    
    	OnBnClickedNewOperation();
        }
    }
  26. Close the dialog box. If asked whether you want to save, click Yes
  27. On the main menu, click File -> Open File...
  28. click BooleanAlgebra.rc
  29. In the bottom right section of the Open dialog box, click the down-pointing arrow of the Open button and click Open With...
  30. In the Open With dialog box, click Source Code (Text) Editor
     
    Open File
  31. Click OK.
    If you asked whether to open a file, click Yes
  32. Locate the following line:
    FONT 8, _T("MS Shell Dlg", 0, 0, 0x1
  33. Change it as:
    FONT 24, _T("Tahoma", 0, 0, 0x1
  34. Close the file
  35. When asked whether you want to save, click Yes
  36. To execute, press F5
     
    Boolean Algebra
  37. Performs some operations and click the Check button
  38. Close the dialog box and return to your programming environment
 
 
   
 

Home Copyright © 2010-2011 FunctionX, Inc.