CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: CCheckListBox

  1. #1
    Join Date
    May 1999
    Posts
    68

    CCheckListBox

    How do I use the CCheckListBox control. Please let me know step by step.


  2. #2
    Join Date
    Apr 1999
    Location
    Germany
    Posts
    418

    Re: CCheckListBox

    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

  3. #3
    Join Date
    May 1999
    Posts
    68

    Re: CCheckListBox

    dosen't seem to work!!!


  4. #4
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: CCheckListBox

    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/

  5. #5
    Join Date
    May 1999
    Posts
    68

    Re: CCheckListBox

    seems to give me assertion failure when I click on it. I guess i'm doing something wrong!!


  6. #6
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: CCheckListBox

    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/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured