📄 关于clistctrl控件中增加checkbox后,检测check状态的问题.txt
字号:
请教:关于CListCtrl控件中增加CheckBox后,检测check状态的问题:相关:CListCtrl中增加了CheckBox(MyCtrl.SetExtendedStyle(LVS_EX_CHECKBOXES) ),运行时Item的左侧会出现一个Check框,鼠标点击,其状态会变化,但是不会影响CListCtrl中Item的选中状态。 我的问题是:我在用鼠标点击改变了一个Item的Check状态时,怎样得到这个
上一篇:一个比较菜的问题 CTreeCtrl 下一篇:如何在CListCtrl显示文件中的文件,并根据文件本身的类型来显示图标请教:关于CListCtrl控件中增加CheckBox后,检测check状态的问题
摘自:请教:关于CListCtrl控件中增加CheckBox后,检测check状态的问题
相关:CListCtrl中增加了CheckBox(MyCtrl.SetExtendedStyle(LVS_EX_CHECKBOXES) ),运行时Item的左侧会出现一个Check框,鼠标点击,其状态会变化,但是不会影响CListCtrl中Item的选中状态。
我的问题是:我在用鼠标点击改变了一个Item的Check状态时,怎样得到这个Item的Index?
---------------------------------------------------------------
LVN_ITEMCHANGING
LVN_ITEMCHANGED
state image is changed
Bits 12 through 15 of this member specify the state image index. The state image is displayed next to an item's icon to indicate an application-defined state. If these bits are zero, the item has no state image. To isolate these bits, use the LVIS_STATEIMAGEMASK mask. To set the state image index, use the INDEXTOSTATEIMAGEMASK macro. The state image index specifies the index of the image in the state image list that should be drawn. The state image list is specified with the LVM_SETIMAGELIST message.
---------------------------------------------------------------
void CAboutDlg::OnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
*pResult = 0;
}
响应LVN_ITEMCHANGED事件,缺省的pNMListView中就包含了这个index信息
---------------------------------------------------------------
void CTest6Dlg::OnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
//pNMListView中包含了你点击的行列值,如下
int iItem = pNMListView->iItem;
int iSubItem = pNMListView->iItem;
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -