how to change the background color of a checkbox in a list control?
-
I have a list control CListCtrl with report view and the extend style of LVS_EX_CHECKBOXES. Then I try to change the back ground color of the list control, to black color for example. It's done by overriding OnNMCustomdraw() method. Everything works well except the background color of all checkboxes. Now I don't know how to fix this problem. Any suggestion should be appreciated.
-
I have a list control CListCtrl with report view and the extend style of LVS_EX_CHECKBOXES. Then I try to change the back ground color of the list control, to black color for example. It's done by overriding OnNMCustomdraw() method. Everything works well except the background color of all checkboxes. Now I don't know how to fix this problem. Any suggestion should be appreciated.
-
it's quite complicated, so I still not success, :(( but anyway, thanks for your help. I will look at this later
Did you see it I guess your problem is solved. :)
-
Did you see it I guess your problem is solved. :)
-
Not yet, Hamid, :( If I success, I will notify it here. And if you find something, plz let me know, :)
I did it, not very well but it works. Actually, I try to do similarly to XListCtrl All I did here: I have a class MyListCtr direved from CListCtrl. Then I override OnNMCustomdraw, try to draw the rectangualar with specificed color (black in my case). The problem is how to catch event mouse click, determine checkbox state and change the drawing. I cannot understand the way XListCtrl do, it seems to register a defined event WM_XLISTCTRL_CHECKBOX_CLICKED, but I'm not sure. And TRACE, what is TRACE macro? hehe So I did like this: use event NM_CLICK
void CMyDlg::OnNMClickListData(NMHDR *pNMHDR, LRESULT *pResult)
{
/* get check box state */
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;if (pNMListView->uOldState == 0 && pNMListView->uNewState == 0) return; // No change BOOL bPrevState = (BOOL)(((pNMListView->uOldState & LVIS\_STATEIMAGEMASK)>>12)-1); // Old check box state if (bPrevState < 0) // On startup there's no previous state bPrevState = 0; // so assign as false (unchecked) // New check box state BOOL bChecked=(BOOL)(((pNMListView->uNewState & LVIS\_STATEIMAGEMASK)>>12)-1); if (bChecked < 0) // On non-checkbox notifications assume false bChecked = 0; if (bPrevState == bChecked) // No change in check box return;
}
I'd tried some ways but not success until this. Actually, I found it somewhere else.