LRESULT CDrawHeader::DoLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { POINT point; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); m_ptLastLButtonDown = point; if (!m_bColumnResizing) { m_pAlmSum->SetCapture(TRUE, this); if (MouseOverColumnResizeArea(point)) { SetCursor(m_hColDivCursor); m_bColumnResizing = TRUE; } else { m_nColumnCatpture = GetColumn(point); CDCHandle dcHandle = m_pAlmSum->GetDC(); DoDraw(dcHandle); m_pAlmSum->ReleaseDC(dcHandle); } } if (m_bColumnResizing) { if (!GetResizeColumn(point, m_nResizingColumn, m_nDragDivideOffset)) return 1; CRect rect = m_pAlmSum->m_rect; CRect invertedRect(point.x - 1 - m_nDragDivideOffset, rect.top, point.x - m_nDragDivideOffset, rect.bottom); CDCHandle dcHandle = m_pAlmSum->GetDC(); dcHandle.InvertRect(&invertedRect); m_pAlmSum->ReleaseDC(dcHandle); } return 0; }
LRESULT CDrawHeader::DoLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { POINT point; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); m_pAlmSum->SetCapture(FALSE, this); if (m_bColumnResizing) { int nMinX = m_ptLastLButtonDown.x - m_nDragDivideOffset - m_pAlmSum->GetColumnWidth(m_nResizingColumn); int nXPos = max(m_ptLastMousePoint.x, nMinX); CRect rect = m_pAlmSum->m_rect; CRect invertedRect(nXPos - 1 - m_nDragDivideOffset, rect.top, nXPos - m_nDragDivideOffset, rect.bottom); CDCHandle dcHandle = m_pAlmSum->GetDC(); dcHandle.InvertRect(&invertedRect); m_pAlmSum->ReleaseDC(dcHandle); if (m_ptLastLButtonDown != point) { CPoint start; nXPos = max(point.x, nMinX); m_pAlmSum->SetColumnWidth(m_nResizingColumn, nXPos - m_ptLastLButtonDown.x + m_nDragDivideOffset + m_pAlmSum->GetColumnWidth(m_nResizingColumn)); m_pAlmSum->FireViewChange(); } m_bColumnResizing = FALSE; m_nResizingColumn = -1; } else if (m_nColumnCatpture != -1) { int nCol = GetColumn(point); if (nCol == m_nColumnCatpture) { if (m_pAlmSum->m_nSortField == m_pAlmSum->m_apColumns[nCol]->m_enumAlarmField && m_pAlmSum->m_nSecondSortField == (enumAlarmField)-1) { m_pAlmSum->m_bSortAscending = !m_pAlmSum->m_bSortAscending; } else { m_pAlmSum->m_nSortField = m_pAlmSum->m_apColumns[nCol]->m_enumAlarmField; m_pAlmSum->m_nSecondSortField = (enumAlarmField)-1; } CAlarm* pSelectAlarm = m_pAlmSum->GetSelectAlarm(); m_pAlmSum->ReSortAlarms(); m_pAlmSum->SelectAlarm(pSelectAlarm); m_nColumnCatpture = -1; } else { m_nColumnCatpture = -1; CDCHandle dcHandle = m_pAlmSum->GetDC(); DoDraw(dcHandle); m_pAlmSum->ReleaseDC(dcHandle); } } return 0; }
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 ; }