void CMyPropertyPage2::OnClickListtablegrid(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
CString msg;
NMITEMACTIVATE * m_plv=(NMITEMACTIVATE*)pNMHDR;
long mouse_x,mouse_y;
//msg.Format("%d[%d]",pNMListView->iSubItem, m_plv->ptAction.x);
//long i=pNMListView->iSubItem ; //取列号
mouse_x=m_plv->ptAction.x;
mouse_y=m_plv->ptAction.y;
//判断是第几行
RECT m_rect;
long itemrow,itemcol,i;
for(i=m_listtablegrid.GetTopIndex( );i<m_listtablegrid.GetItemCount( );i++)
{
m_listtablegrid.GetItemRect(i,&m_rect,0);
if((m_rect.top <=mouse_y)&&(m_rect.bottom >=mouse_y))
{
itemrow=i;
break;
}
}
itemcol=pNMListView->iSubItem;
msg.Format("%d[%d]",itemcol, itemrow+1);
//itemrow=m_listtablegrid.GetHotItem();//no use
//itemrow=m_listtablegrid.GetSelectionMark();//nouse too must in col 0
CString oldmsg=m_listtablegrid.GetItemText (itemrow,itemcol);
if(oldmsg!="*")
{
msg = "*";
m_selectdatarray[itemrow*m_oldcols+itemcol]=1;
}
else
{
msg="";
m_selectdatarray[itemrow*m_oldcols+itemcol]=0;
}
m_listtablegrid.SetItemText (itemrow,itemcol,msg);
oldmsg=msg;
*pResult = 0;
}
本文地址:http://com.8s8s.com/it/it2468.htm