I'm trying to dynamically create a CCheckListBox in C++ MFC, but for some reason it automatically sorts the entries alphabetically, which affects the subsequent code. The code used to create it is:
m_List = new(CCheckListBox);
m_List->Create(LBS_HASSTRINGS | LBS_OWNERDRAWFIXED | WS_CHILD | BS_CHECKBOX | WS_VISIBLE , CRect(20, 20, 180, 180), this, 1248);
and the following function adds strings to the checklistbox from a CEdit.
void CCheckListBoxDlg::addEntry()
{
CString strTemp;
m_Entry->GetWindowTextW(strTemp);
m_List->AddString(strTemp);
}
Note that this does not have the LBS_SORT or LBS_STANDARD properties, yet is sorting anyway. The same code uses CListBox (from which CCheckListBox inherits) without this problem.
What I have tried:
I have recreated this from a blank MFC app to confirm that nothing else in the code is responsible for this, and that the CCheckListBox is sorting at the point of entry.
EDIT:
GitHub link. Contains a form with a CCheckListBox, a CEdit and a CButton that adds the contents of the CEdit to the CCheckListBox.
I have also tried to use ModifyStyle/Ex to remove the LBS_SORT property that it shouldn't have, but this has no effect.