Microsoft Developer Network > 포럼 홈 > Visual C++ General > How to solve this CCheckListBox problem?
질문하기질문하기
 

질문How to solve this CCheckListBox problem?

  • 2009년 11월 4일 수요일 오후 2:50shantou chen 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Hello Visual C++ Experts,

    We have a native Visual C++ application that uses CCheckListBox. Under some situations, we want to make each items of the CCheckListBox CHECKED and DISABLED so that user cannot edit them (We cannot disable the CCheckListBox because the scroll bar will be disabled.)

    The problem we have is that when an item is disabled, the text is greyed but the Check Mark is still black. It gives users an impression that it is editable.

    I read the implementation code in WinCtrl3.cpp and saw that the CheckBox is not drawn in DrawItem function. So I cannot fix this problem by overriding DrawItem.

    How to solve this problem?

    Thanks.

    Shantou

모든 응답

  • 2009년 11월 4일 수요일 오후 3:22Scott McPhillipsMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    See the code for CCheckListBox::OnChildNotify.  It is called just before DrawItem.  It draws the check and can be overridden.
  • 2009년 11월 4일 수요일 오후 5:42shantou chen 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Scott,

    Thank you for your suggestion.

    I looked into OnChildNotify and got following impressions:

    For WM_DRAWITEM message, it calls PreDrawItem, and then PreDrawItemNonThemed. The actual code to draw CheckBox is in PreDrawItemNoThemed which copies a Check Mark bitmap to the target location. So I need to override OnChildNotify to call my own PreDrawItem and PreDrawItemNonThemed. 

    I have following questions:
       1. How do I find out the bitmap AFX_IDB_CHECKLISTBOX_95. I would like to see if it contains a disabled and checked bitmap.
       2. The class derived from CCheckListBox cannot use the _AFX_CHECKLIST_STATE object defined in WinCtrl3.cpp.

    Do you have any suggestions to those questions?

    Thanks.

    Shantou

  • 2009년 11월 4일 수요일 오후 11:52Scott McPhillipsMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    The MFC resources, including that bitmap, are in afxres.rc

    Don't know about question 2.