CCheckListBox有虚假的垂直滚动条

时间:2017-01-09 20:05:07

标签: mfc

我似乎无法解决与CCheckListBox有关的问题。

这是填充列表框的方法:

void CPublishersDatabaseDlg::InitAssignmentsListBox()
{
    UINT uIDs[] = 
    {
        IDS_STR_SOUND,
        IDS_STR_PLATFORM,
        IDS_STR_MICROPHONE,
        IDS_STR_ATTENDANT,
        IDS_STR_MIDWEEK_MEETING,
        IDS_STR_CBS_CONDUCTOR,
        IDS_STR_CBS_READER,
        IDS_STR_ASSIGN_CHAIRMAN,
        IDS_STR_PRAYER,
        IDS_STR_STUDENT,
        IDS_STR_DEMONSTRATIONS
    };

    WPARAM eTypes[] = 
    {
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_Sound, -1),
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_PlatformAttendant, -1),
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_Mike, -1),
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_Attendant, -1),
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_OCLM, -1),
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_ConductorCBS, -1),
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_ReaderCBS, -1),
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_Chairman, -1),
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_Prayer, -1),
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_Student, -1),
        MAKEWPARAM(MSAToolsLibrary::AssignmentType_Demonstration, -1)

    };

    for (int i = 0; i < 11; i++)
    {
        CString strAssignment = _T("");

        if (strAssignment.LoadString(uIDs[i]))
        {
            int i = m_lbAssignments.AddString(strAssignment);
            m_lbAssignments.SetItemData(i, static_cast<DWORD_PTR>(eTypes[i]));
        }
    }

    int iNumCustomAssign = theApp.GetNumberSetting(_T(""), ASSIGN_COUNT, 0);
    for (int iAssign = 0; iAssign < iNumCustomAssign; iAssign++)
    {
        CString strAssign, strDescription, strSection;

        strAssign.Format(ASSIGN_TEMPLATE, iAssign);
        strSection.Format(SECTION_TEMPLATE, (LPCTSTR)strAssign);
        strDescription = theApp.GetStringSetting(strSection, ASSIGN_DESCRIPTION_KEY, strAssign);

        if (strDescription != ASSIGN_DELETED) // Skip deleted custom assignments
        {
            int i = m_lbAssignments.AddString(strDescription);
            m_lbAssignments.SetItemData(i, MAKEWPARAM(MSAToolsLibrary::AssignmentType_Custom, iAssign));
        }
    }
}

我已正确遵循说明并将列表框设置为 OwnerDraw HasString

除了垂直滚动之外,它似乎运作良好:

Vertical scroll issue

看到突出显示的黄色区域?垂直卷轴是假的。如果我试图点击它,应用程序崩溃。

但如果我使用鼠标滚轮向下滚动,那么垂直条就会消失。

如何让垂直滚动条正确,就像它是常规的CListBox一样?

我已经看到此相关question,但我的资源有WS_VSCROLL

LISTBOX         IDC_LIST_PUBLISHER_ASSIGNMENTS,177,149,286,110,LBS_SORT | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP

我不知道如何解决这个怪癖。

0 个答案:

没有答案