VC多功能标签CLabelEx
2007-10-07 20:23:33 来源:WEB开发网核心提示:2、感应鼠标用的方法如下所示:在MouseMove里SetCapture()和ReleaseCapture();void CLabelEx::OnMouseMove(UINT nFlags, CPoint point){ // TODO: Add your message handler code here and/o
2、感应鼠标用的方法如下所示:
在MouseMove里SetCapture()和ReleaseCapture();
void CLabelEx::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_bOver) // Cursor is currently over control
{
CRect rect;
GetClientRect(rect);
if (!rect.PtInRect(point))
{
m_bOver = FALSE;
if(m_bAutoUnderLine) ///自动下划线
{
this->SetUnderLine(FALSE,RGB(0,0,0));
}
if(m_bHighLight) //自动高亮
{
///恢复原来的字体颜色
this->SetTextColor(m_crBackText);
}
RedrawWindow();
ReleaseCapture();
return;
}
}
else // Cursor has just moved over control
{
m_bOver = TRUE;
if(m_bAutoUnderLine)
{
this->SetUnderLine(TRUE,RGB(0,0,255));
}
if(m_bHighLight)
{
m_crBackText=m_crText;
this->SetTextColor(RGB(0,0,255));
}
RedrawWindow();
SetCapture();
::SetCursor(m_hHandCur);
}
CStatic::OnMouseMove(nFlags, point);
}
注:这种方法简单方便,但是有一个问题,看附带的工程,单击Label1弹出一个对话框后Label1无法恢复原状。我一直没解决这个问题.若谁知道请告知我 querw@sina.com
更多精彩
赞助商链接