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::DoMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { POINT point; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); UINT nFlags = wParam; if (!(nFlags & MK_LBUTTON)) { if (MouseOverColumnResizeArea(point) && m_nColumnCatpture == -1) { SetCursor(m_hColDivCursor); } else { SetCursor(LoadCursor(NULL, IDC_ARROW)); } } if (nFlags & MK_LBUTTON) { if (m_bColumnResizing) { //SetCursor(m_hColDivCursor); CRect rect = m_pAlmSum->m_rect; CDCHandle dcHandle = m_pAlmSum->GetDC(); int nMinX = m_ptLastLButtonDown.x - m_nDragDivideOffset - m_pAlmSum->GetColumnWidth(m_nResizingColumn); int nXPos = max(m_ptLastMousePoint.x, nMinX); CRect oldInvertedRect(nXPos - 1 - m_nDragDivideOffset, rect.top, nXPos - m_nDragDivideOffset, rect.bottom); dcHandle.InvertRect(&oldInvertedRect); nXPos = max(point.x, nMinX); CRect newInvertedRect(nXPos - 1 - m_nDragDivideOffset, rect.top, nXPos - m_nDragDivideOffset, rect.bottom); dcHandle.InvertRect(&newInvertedRect); m_pAlmSum->ReleaseDC(dcHandle); } else if (m_nColumnCatpture != -1) { int nCol = GetColumn(point); if (nCol != m_nColumnCatpture) { m_nColumnCatpture = -1; CDCHandle dcHandle = m_pAlmSum->GetDC(); DoDraw(dcHandle); m_pAlmSum->ReleaseDC(dcHandle); m_pAlmSum->SetCapture(FALSE, this); } } } m_ptLastMousePoint = point; 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; }