int FilterListCtrl::HitTestEx(CPoint &point, int *col) const { if (col) *col = 0; int row = HitTest(CPoint(0, point.y), NULL); if ((GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT) return row; int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount(); for(int top = GetTopIndex(), bottom = GetBottomIndex(); top <= bottom; top++) { CRect r; GetItemRect(top, &r, LVIR_BOUNDS); if (r.top <= point.y && point.y < r.bottom) { for (int colnum = 0; colnum < nColumnCount; colnum++) { int colwidth = GetColumnWidth(colnum); if (point.x >= r.left && point.x <= (r.left + colwidth)) { if(col) *col = colnum; return top; } r.left += colwidth; } } } return -1; }
BOOL CDropListBox::Expand(PLIST_ITEM pItem, UINT nCode) { if(pItem == NULL) { return FALSE; } BOOL bResult = FALSE; if(nCode == LBE_COLLAPSE) { bResult = Collapse(pItem); } else if(nCode == LBE_EXPAND) { bResult = Expand(pItem); } else if(nCode == LBE_TOGGLE) { if(pItem->state & ACBIS_COLLAPSED) { bResult = Expand(pItem); } else { bResult = Collapse(pItem); } } if(bResult) { SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); if( m_pDropWnd->GetScrollBarPtr()->GetScrollInfo( &info, SIF_ALL|SIF_DISABLENOSCROLL ) ) { info.nPage = GetBottomIndex() - GetTopIndex(); info.nMax = GetCount()-1; info.nMin = 0; m_pDropWnd->GetScrollBarPtr()->SetScrollInfo( &info ); } } return bResult; }
CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint) { if (GetSelectedCount() <= 0) { return nullptr; } CRect cSingleRect, cCompleteRect(0, 0, 0, 0); GetClientRect(cSingleRect); int nWidth = cSingleRect.Width(); // Start and Stop index in view area int nIndex = GetTopIndex() - 1; int nBottomIndex = GetBottomIndex(); // Determine the size of the drag image (limited for // rows visible and Client width) while ((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex) { GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS); /* CRect r; GetItemRect(nIndex, r, LVIR_LABEL); cSingleRect.left = r.left; */ if (cSingleRect.left < 0) { cSingleRect.left = 0; } if (cSingleRect.right > nWidth) { cSingleRect.right = nWidth; } cCompleteRect |= cSingleRect; } // // Create bitmap in memory DC // CClientDC cDc(this); CDC cMemDC; CBitmap cBitmap; if (!cMemDC.CreateCompatibleDC(&cDc)) { return nullptr; } if (!cBitmap.CreateCompatibleBitmap(&cDc, cCompleteRect.Width(), cCompleteRect.Height())) { return nullptr; } CBitmap* pOldMemDCBitmap = cMemDC.SelectObject(&cBitmap); // Here green is used as mask color cMemDC.FillSolidRect(0, 0, cCompleteRect.Width(), cCompleteRect.Height(), RGB(0, 255, 0)); // Paint each DragImage in the DC nIndex = GetTopIndex() - 1; while ((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex) { CPoint pt; CImageList* pSingleImageList = CreateDragImage(nIndex, &pt); if (pSingleImageList) { GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS); pSingleImageList->Draw(&cMemDC, 0, CPoint(cSingleRect.left - cCompleteRect.left, cSingleRect.top - cCompleteRect.top), ILD_MASK); pSingleImageList->DeleteImageList(); delete pSingleImageList; } } cMemDC.SelectObject(pOldMemDCBitmap); // // Create the image list with the merged drag images // CImageList* pCompleteImageList = DEBUG_NEW CImageList; pCompleteImageList->Create(cCompleteRect.Width(), cCompleteRect.Height(), ILC_COLOR | ILC_MASK, 0, 1); // Here green is used as mask color pCompleteImageList->Add(&cBitmap, RGB(0, 255, 0)); // // as an optional service: // Find the offset of the current mouse cursor to the image list // this we can use in BeginDrag() // if (lpPoint) { lpPoint->x = cCompleteRect.left; lpPoint->y = cCompleteRect.top; } return pCompleteImageList; }