CListCtrl Checkbox Readonly

I have a CListCtrl that displays a checkbox in the left column. I want to programatically check and uncheck these checkboxes but not allow the user to do so.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't think there is an API to do this.

If you are using the standard (IE4) LVS_EX_CHECKBOXES style, just trap the user click and set the check to whatever is stored in your data structure i.e. programmatically undo the users action.

Alternatively, implement the checkboxes your self (as state icons). Then you have complete control.
As abancroft says, there is no API to do this: you must do it yourself

void CProduzMainDlg::OnItemChangedListMatr(NMHDR* pNMHDR, LRESULT* pResult)
      /* If the event is not fired because of any change in individual items then the oldstate and
      newstate members of pNMListView are not used.  So check for that.*/
      if ((!pNMListView->uOldState && !pNMListView->uNewState) || bCheckingFromCode)
      int matr = pNMListView->iItem;
      if (matr == -1)
      bCheckingFromCode = true;
      m_listMatr.SetCheck(matr, FALSE);
      bCheckingFromCode = false;

Look at this code...
bCheckingFromCode is a member of the dialog class (or view or whatever) and is used because a SetCheck fires an LVM_ITEMCHANGED, so if u don't do this you loop and loop forever.

Change the SetCheck call whit something appropriate to u (e.g. check the item state and set or reset the check)

Hope this helps

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.