void CGridCellCheck::OnClick(CPoint PointCellRelative) { // PointCellRelative is relative to the topleft of the cell. Convert to client coords PointCellRelative += m_Rect.TopLeft(); if (GetCheckPlacement().PtInRect(PointCellRelative)) { m_bChecked = !m_bChecked; GetGrid()->InvalidateRect(m_Rect); } // Bail if cell is read-only CCellID cell = GetGrid()->GetCellFromPt(PointCellRelative); if(cell.row > -1 && cell.col > -1) { if (!GetGrid()->IsCellEditable(cell)) return; } // GetCheckPlacement returns the checkbox dimensions in client coords. Only check/ // uncheck if the user clicked in the box // if (GetCheckPlacement().PtInRect(PointCellRelative)) // { // m_bChecked = !m_bChecked; // GetGrid()->InvalidateRect(m_Rect); // } }
// Override draw so that when the cell is selected, a drop arrow is shown in the RHS. BOOL CGridCellCheck::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd /*=TRUE*/) { BOOL bResult = CGridCell::Draw(pDC, nRow, nCol, rect, bEraseBkgnd); #ifndef _WIN32_WCE // Store the cell's dimensions for later m_Rect = rect; CRect CheckRect = GetCheckPlacement(); rect.left = CheckRect.right; // enough room to draw? // if (CheckRect.Width() < rect.Width() && CheckRect.Height() < rect.Height()) { // Do the draw pDC->DrawFrameControl(GetCheckPlacement(), DFC_BUTTON, (m_bChecked)? DFCS_BUTTONCHECK | DFCS_CHECKED : DFCS_BUTTONCHECK); // } #endif return bResult; }
void CGridCellCheck::OnClick(CPoint PointCellRelative) { // PointCellRelative is relative to the topleft of the cell. Convert to client coords PointCellRelative += m_Rect.TopLeft(); // GetCheckPlacement returns the checkbox dimensions in client coords. Only check/ // uncheck if the user clicked in the box if (GetCheckPlacement().PtInRect(PointCellRelative)) { m_bChecked = !m_bChecked; GetGrid()->InvalidateRect(m_Rect); } }