比如对于某列加入CGridCellButton控件之后,此时需要点击此控件做一系列的操作:
ON_NOTIFY(NM_CLICK, IDC_GRID, OnClick)
afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);
void CMainFrame::OnClick(NMHDR* pNMHDR, LRESULT* pResult)
{
GV_DISPINFO *pgvDispInfo = (GV_DISPINFO *)pNMHDR;
GV_ITEM *pgvItem = &pgvDispInfo->item;
NM_GRIDVIEW* pItem = (NM_GRIDVIEW*)pNMHDR;
if (pItem->iColumn == 4)
{
CGridCellButton *pButton = (CGridCellButton*)m_Grid.GetCell(pItem->iRow, pItem->iColumn);
if (pButton == NULL) return;
m_Grid.SetEditable(FALSE);
AfxMessageBox(L"点击按钮");
}
}