| 423 | |
| 424 | |
| 425 | CRect SListCtrl::GetItemRect(int nItem, int nSubItem) |
| 426 | { |
| 427 | if (!(nItem>=0 && nItem<GetItemCount() && nSubItem>=0 && nSubItem<GetColumnCount())) |
| 428 | return CRect(); |
| 429 | |
| 430 | CRect rcItem; |
| 431 | rcItem.top = m_nItemHeight*nItem; |
| 432 | rcItem.bottom = rcItem.top+m_nItemHeight; |
| 433 | rcItem.left = 0; |
| 434 | rcItem.right = 0; |
| 435 | |
| 436 | for (int nCol = 0; nCol < GetColumnCount(); nCol++) |
| 437 | { |
| 438 | SHDITEM hdi; |
| 439 | hdi.mask = SHDI_WIDTH|SHDI_ORDER; |
| 440 | |
| 441 | m_pHeader->GetItem(nCol, &hdi); |
| 442 | rcItem.left = rcItem.right; |
| 443 | rcItem.right = rcItem.left+hdi.cx.toPixelSize(GetScale()); |
| 444 | if (hdi.iOrder == nSubItem) |
| 445 | break; |
| 446 | } |
| 447 | |
| 448 | CRect rcList = GetListRect(); |
| 449 | // 变换到窗口坐标 |
| 450 | rcItem.OffsetRect(rcList.TopLeft()); |
| 451 | // 根据原点坐标修正 |
| 452 | rcItem.OffsetRect(-m_ptOrigin); |
| 453 | |
| 454 | return rcItem; |
| 455 | } |
| 456 | |
| 457 | ////////////////////////////////////////////////////////////////////////// |
| 458 | // 自动修改pt的位置为相对当前项的偏移量 |
no test coverage detected