CCheckListBox Class

Provides the functionality of a Windows checklist box.

class CCheckListBox : public CListBox

Members

Public Constructors

Name

Description

CCheckListBox::CCheckListBox

Constructs a CCheckListBox object.

Public Methods

Name

Description

CCheckListBox::Create

Creates the Windows checklist box and attaches it to the CCheckListBox object.

CCheckListBox::DrawItem

Called by the framework when a visual aspect of an owner-draw list box changes.

CCheckListBox::Enable

Enables or disables a checklist box item.

CCheckListBox::GetCheck

Gets the state of an item's check box.

CCheckListBox::GetCheckStyle

Gets the style of the control's check boxes.

CCheckListBox::IsEnabled

Determines whether an item is enabled.

CCheckListBox::MeasureItem

Called by the framework when a list box with an owner-draw style is created.

CCheckListBox::OnGetCheckPosition

Called by the framework to get the position of an item's check box.

CCheckListBox::SetCheck

Sets the state of an item's check box.

CCheckListBox::SetCheckStyle

Sets the style of the control's check boxes.

Remarks

A "checklist box" displays a list of items, such as filenames. Each item in the list has a check box next to it that the user can check or clear.

CCheckListBox is only for owner-drawn controls because the list contains more than text strings. At its simplest, a checklist box contains text strings and check boxes, but you do not need to have text at all. For example, you could have a list of small bitmaps with a check box next to each item.

To create your own checklist box, you must derive your own class from CCheckListBox. To derive your own class, write a constructor for the derived class, then call Create.

If you want to handle Windows notification messages sent by a list box to its parent (usually a class derived from CDialog), add a message-map entry and message-handler member function to the parent class for each message.

Each message-map entry takes the following form:

ON_Notification( id, memberFxn )

where id specifies the child window ID of the control sending the notification and memberFxn is the name of the parent member function you have written to handle the notification.

The parent's function prototype is as follows:

afx_msg void memberFxn**( );**

There is only one message-map entry that pertains specifically to CCheckListBox (but see also the message-map entries for CListBox):

  • ON_CLBN_CHKCHANGE   The user has changed the state of an item's checkbox.

If your checklist box is a default checklist box (a list of strings with the default-sized checkboxes to the left of each), you can use the default CCheckListBox::DrawItem to draw the checklist box. Otherwise, you must override the CListBox::CompareItem function and the CCheckListBox::DrawItem and CCheckListBox::MeasureItem functions.

You can create a checklist box either from a dialog template or directly in your code.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CListBox

CCheckListBox

Requirements

Header: afxwin.h

See Also

Reference

CListBox Class

Hierarchy Chart

CListBox Class

Concepts

MFC Sample TSTCON