Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Checkbox in ctrlList

447 views
Skip to first unread message

gregorio

unread,
May 15, 2003, 10:45:43 AM5/15/03
to
I have a list with check box
m_ctrList.SetExtendedStyle(LVS_EX_GRIDLINES |
LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);

How can I disable only one or more than one box?

Ivan

unread,
May 16, 2003, 4:41:59 AM5/16/03
to
Here's a revised copy of what I posted some time ago on this topic:

I made all checkboxes disabled using following code:

in msgmap of the parent dialog (you could also use reflection and put it to
CListCtrl derivative)

ON_NOTIFY(LVN_ITEMCHANGING, IDC_LISTCTRL, OnItemChanging)

and the handler itself:

void CMyDlg::OnItemChanging(NMHDR* pNMHDR, LRESULT* pResult) {
if(m_bReadOnly) {
LPNMLISTVIEW pL = (LPNMLISTVIEW)pNMHDR;
unsigned state = (pL->uOldState ^ pL->uNewState) & 0xF000;
if(state) {
*pResult = true;
return;
}
}
*pResult = false;
}

It checks the change in image attribute of any checkbox and cancels it. The
notification is also fired when the change is done programaticaly
(SetCheck), but it
cannot be cancelled. You also get item id in the structure so you can
disable checkboxes selectively.

Ivan

"gregorio" <gregori...@hsi.ch> wrote in message
news:0ad701c31af0$a9a08b50$a601...@phx.gbl...

gregorio

unread,
May 16, 2003, 5:10:34 AM5/16/03
to
The method you suggest works well but I'd like the
checkbox was drawed with disabled style to prevent the
user try to click it

>.
>

Ivan

unread,
May 16, 2003, 5:18:19 AM5/16/03
to
Then you have to use your own image list and implement the logic about
picking the right picture from it yourself. Have a look at listcontrol
notifications.

Ivan

"gregorio" <gregori...@hsi.ch> wrote in message

news:0b2701c31b8b$0244c010$a101...@phx.gbl...

jiangsheng

unread,
May 18, 2003, 5:48:25 AM5/18/03
to
Simulate checkbox by using state images and handle item click and space
state toggle yourself.

"gregorio" <gregori...@hsi.ch> 写入邮件
news:0ad701c31af0$a9a08b50$a601...@phx.gbl...

0 new messages