[CListCtrl]在滑鼠指標移過儲存格上方後,顯示底線

目前算只完成一半,因為字跟欄位有個距離,目前還沒辦法動態取得。
ON_WM_MOUSEMOVE()

一樣也是在CListCtrl::OnMouseMove()內處理。
     CRect rect1, rectParent; 
this->GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, rect1);   
this->GetWindowRect(&rectParent);   
CString cstrDisplayString =    this->GetItemText(nItem, nSubItem);   
int nStrWidth = this->GetStringWidth(cstrDisplayString);   
unsigned int nCurNumOfWorkArea = this->GetNumberOfWorkAreas();  
if ( point.x < rect1.right && point.x > rect1.left && point.y < rect1.bottom && point.y > rect1.top )       
{   
//Clean previous line   
if ( !this->m_PreRect.IsRectEmpty() )   
{   
CDC *pcdc = this->GetDC();   
CPen cp(PS_SOLID, 1, RGB(255,255,255));   
pcdc->SelectObject(cp.m_hObject);   
pcdc->MoveTo(this->m_PreRect.left, this->m_PreRect.bottom);   
pcdc->LineTo(this->m_PreRect.right, this->m_PreRect.bottom);   
this->m_PreRect.SetRectEmpty();   
}   
//Draw line   
CDC *pcdc = this->GetDC();   
CPen cp(PS_SOLID, 1, RGB(255,0,0));   
pcdc->SelectObject(cp.m_hObject);   
pcdc->MoveTo(rect1.left, rect1.bottom);  
pcdc->LineTo((rect1.left + nStrWidth), rect1.bottom);   
this->m_PreRect.SetRect(rect1.left, rect1.top, (rect1.left+nStrWidth), rect1.bottom);   
}else {  
         CDC *pcdc = this->GetDC();   
CPen cp(PS_SOLID, 1, RGB(255,255,255));   
pcdc->SelectObject(cp.m_hObject);   
pcdc->MoveTo(this->m_PreRect.left, this->m_PreRect.bottom);   
pcdc->LineTo(this->m_PreRect.right, this->m_PreRect.bottom);   
this->m_PreRect.SetRectEmpty();   
} 

this->ReleaseDC(pcdc);

No comments:

Post a Comment

Build docker image from multiple build contexts

Build docker image from multiple build contexts ...