映射NM_CLICK消息,
int nUpdateNoticeID =0;
int nNoticeListIndex = -1;
bool bIsAbleGetFocus = true;
void CClassDlg::OnNMClickListNotice(NMHDR *pNMHDR,LRESULT *pResult)
{
int temp = m_list.GetItemCount();
int m_nIndex = m_list.GetSelectionMark();
if(m_nIndex < 0)
return;
int nTempID = atoi(m_list.GetItemText(m_nIndex,0));
if(m_nIndex != nNoticeListIndex)
{
nUpdateNoticeID = nTempID;
nNoticeListIndex = m_nIndex;
bIsAbleGetFocus = true;
}
else
{
if(bIsAbleGetFocus )
nUpdateNoticeID =0;
else
nUpdateNoticeID = nTempID;
bIsAbleGetFocus = !bIsAbleGetFocus;
}
if(nUpdateNoticeID) //如果为“修改”状态,nUpdateNoticeID为待修改的ID号
......
else //如果为“发送”状态
......
算法功能:未点击列表时,默认状态为“发送”;点击了一条,状态变为“修改”,若再点击它,状态又变为“发送”,若点击其它的一条,状态仍为“修改”,只是目标ID号改变。