How do I use the CCheckListBox control. Please let me know step by step.
Printable View
How do I use the CCheckListBox control. Please let me know step by step.
Hi Martini,
the first step is similar to a normal CListBox, you add one to a dialog in RessourceView. Then you add a member variable of type control to your dialog. Third, open the dialog's header file and look for the definition of this variable. Should be something like
CListBox m_ctlMyListBox;
And the last step is to change the word "CListBox" to "CCheckListBox". That's all. After that you can use the additional members of the CCheckListBox class in your code.
With changing the type of the member control variable you use the subclassing feature of MFC. Nice, isn't it? ;-)
HTH
Martin
dosen't seem to work!!!
In the Resource Editor, set the style of the ListBox to Owner Draw and Fixed.
Rail
Recording Engineer/Software Developer
Rail Jon Rogut Software
[email protected]
http://home.earthlink.net/~railro/
seems to give me assertion failure when I click on it. I guess i'm doing something wrong!!
My fault... You also have to check the Has Strings style.
From the MFC source code:
int CCheckListBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CListBox::OnCreate(lpCreateStruct) == -1)
return -1;
if ((GetStyle() & (LBS_OWNERDRAWFIXED | LBS_HASSTRINGS))
== (LBS_OWNERDRAWFIXED | LBS_HASSTRINGS))
SetItemHeight(0, CalcMinimumItemHeight());
return 0;
}
Sorry... that should fix it.. if it doesn't le'me know.
Rail
Recording Engineer/Software Developer
Rail Jon Rogut Software
[email protected]
http://home.earthlink.net/~railro/