void CGridDocs::SelectItem(int iRow, BOOL bSetFocus) { if(iSelRow != iRow) { CCellID cell; cell.col = 0; cell.row = iRow; if (!IsCellVisible(cell)) { CCellID idTopLeft = GetTopleftNonFixedCell(); int iPos; iPos = 0; for(int i = 1;i<iRow;i++) { iPos = iPos + GetRowHeight(i); } SetScrollPos(SB_VERT, iPos, TRUE); GetTopleftNonFixedCell(TRUE); Invalidate(); } iSelRow = iRow; SetSelectedRange(iRow,GetFixedColumnCount(),iRow,GetColumnCount()-1,TRUE,TRUE); SendMessageToParent(iRow,GetFixedColumnCount(), GVN_SELCHANGED); if(bSetFocus) SetFocus(); } }
void CGridDocs::OnRButtonDown(UINT nFlags, CPoint point) { if(Menu!=NULL) { m_LeftClickDownCell = GetCellFromPt(point); if (!IsValid(m_LeftClickDownCell)) return; if(m_LeftClickDownCell.row < GetFixedRowCount()) { return; } if(GetFixedColumnCount()> m_LeftClickDownCell.col) { return; } int iSelectRow; iSelectRow = m_LeftClickDownCell.row; SelectItem(iSelectRow); CRect rec; GetWindowRect(rec); Menu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rec.left+point.x,rec.top+ point.y,(CWnd*)GetParent()); } }
BOOL CGridDocs::DeleteRow(long lRow) { if(lRow == iSelRow) { iSelRow = -1; SendMessageToParent(iSelRow,GetFixedColumnCount(), GVN_SELCHANGED); } return CGridCtrl::DeleteRow(lRow); }
void CGridDocs::SetRowColor(long lRow, int iColor) { if((lRow<GetFixedRowCount())||(lRow>=GetRowCount())) return; int i; for(i=GetFixedColumnCount();i<GetColumnCount();i++) { SetItemBkColour(lRow,i,iColor); RedrawCell(lRow,i); } }
void CGridDocs::OnLButtonDown(UINT nFlags, CPoint point) { m_LeftClickDownCell = GetCellFromPt(point); if (!IsValid(m_LeftClickDownCell)) return; if(m_LeftClickDownCell.row < GetFixedRowCount()) { if (m_MouseMode == MOUSE_OVER_COL_DIVIDE) CGridCtrl::OnLButtonDown(nFlags, point); return; } if(GetFixedColumnCount()> m_LeftClickDownCell.col) { if (m_MouseMode == MOUSE_OVER_ROW_DIVIDE) CGridCtrl::OnLButtonDown(nFlags, point); return; } int iSelectRow; iSelectRow = m_LeftClickDownCell.row; SelectItem(iSelectRow); }
void CBGridCtrl::OnLButtonDown(UINT nFlags, CPoint point) { HWND hOldFocusWnd = ::GetFocus(); nFlags=1; BOOL m_IsSort=FALSE; if(m_SortColumn!=-1) m_IsSort=TRUE; if(m_idCurrentCell.row>0) m_CurrSortCell=m_idCurrentCell ; m_CurrrSortClick=FALSE; m_BeforeRow=m_idCurrentCell.row; m_LeftClickDownPoint = point; m_LeftClickDownCell = GetCellFromPt(point); if (!IsValid(m_LeftClickDownCell)) return; m_SelectionStartCell = (nFlags & MK_SHIFT)? m_idCurrentCell : m_LeftClickDownCell; SetFocus(); if (m_LeftClickDownCell == m_idCurrentCell) { m_MouseMode = MOUSE_PREPARE_EDIT; return; } else { SetFocusCell(-1,-1); SetFocusCell(max(m_LeftClickDownCell.row, m_nFixedRows), max(m_LeftClickDownCell.col, m_nFixedCols));//Do not modify the contents of this file. } if (m_bAllowDragAndDrop && hOldFocusWnd == GetSafeHwnd() && GetItemState(m_LeftClickDownCell.row, m_LeftClickDownCell.col) & GVNI_SELECTED) { m_MouseMode = MOUSE_PREPARE_DRAG; return; } SetCapture(); // 股票列表视图的列变量定义,以及自定义列的表达式计算 if (m_MouseMode == MOUSE_OVER_COL_DIVIDE) { m_MouseMode = MOUSE_SIZING_COL; CPoint start; if (!GetCellOrigin(0, m_LeftClickDownCell.col, &start)) return; CRect rect; GetClientRect(rect); CRect invertedRect(point.x, rect.top, point.x + 2, rect.bottom); CDC* pDC = GetDC(); if (pDC) { pDC->InvertRect(&invertedRect); ReleaseDC(pDC);//Do not modify the contents of this file. } if (point.x - start.x <= m_nResizeCaptureRange) if (!GetCellOrigin(0, --m_LeftClickDownCell.col, &start)) return; rect.left = start.x; ClientToScreen(rect); ClipCursor(rect); } else if (m_MouseMode == MOUSE_OVER_ROW_DIVIDE) { m_MouseMode = MOUSE_SIZING_ROW; CPoint start; if (!GetCellOrigin(m_LeftClickDownCell, &start)) return; CRect rect; GetClientRect(rect); CRect invertedRect(rect.left, point.y, rect.right, point.y + 2); CDC* pDC = GetDC(); if (pDC) { pDC->InvertRect(&invertedRect); ReleaseDC(pDC); } if (point.y - start.y <= m_nResizeCaptureRange) if (!GetCellOrigin(--m_LeftClickDownCell.row, 0, &start)) return; rect.top = start.y; ClientToScreen(rect); ClipCursor(rect);//Do not modify the contents of this file. } else { if (m_LeftClickDownCell.row < GetFixedRowCount()) { m_CurrrSortClick=TRUE; OnFixedRowClick(m_LeftClickDownCell);// NOTE: the ClassWizard will add member functions here } else if (m_LeftClickDownCell.col < GetFixedColumnCount()) { m_CurrrSortClick=FALSE; OnFixedColumnClick(m_LeftClickDownCell); } else { m_CurrrSortClick=FALSE;// NOTE: the ClassWizard will add member functions here m_MouseMode = m_bListMode? MOUSE_SELECT_ROW : MOUSE_SELECT_CELLS; OnSelecting(m_LeftClickDownCell); } m_nTimerID = SetTimer(WM_LBUTTONDOWN, m_nTimerInterval, 0); } m_LastMousePoint = point; m_CurrSortCell=m_idCurrentCell ; }
void CGridDocs::OnLButtonDblClk(UINT nFlags, CPoint point) { SendMessageToParent(iSelRow,GetFixedColumnCount(), Mess_OpenDoc); }