LRESULT RingStatic::RingdowProc(HWND hWnd,RINGPARAMS param) { if(m_crHover != 0xFFFFFFFF) //是超链接 { SetMouseTrack(param); switch(param.uMsg) { case WM_MOUSEHOVER: m_crTextColor = m_crHover; if(m_fontHover.GetFont()) m_fontHover.SetWindowFont(m_hWnd); if(SendMessage(m_parent->Handle(),WM_LINKHOVER,(WPARAM)m_hWnd,0) == 0) UpdateWindow();//InvalidateRect(m_hWnd,NULL,TRUE); break; case WM_MOUSELEAVE: m_crTextColor = m_crNormal; if(m_font.GetFont() && m_fontHover.GetFont()) m_font.SetWindowFont(m_hWnd); if(SendMessage(m_parent->Handle(),WM_LINKLEAVE,(WPARAM)m_hWnd,0) == 0) UpdateWindow();//InvalidateRect(m_hWnd,NULL,TRUE); break; case WM_SETCURSOR: if(m_cursor) SetCursor(m_cursor); return TRUE; } } return RingControls::RingdowProc(m_hWnd,param); }
//焦点改变 void CxResLibImgList::OnFocusChanged( int nItem, BOOL bFocus ) { if ( nItem == -1 ) return; SetItemState(nItem, 0, LVIS_FOCUSED); if (bFocus) SetItemState(nItem, LVIS_FOCUSED, LVIS_FOCUSED); RedrawItems(nItem, nItem); if (bFocus) { CResLibData * pBase = reinterpret_cast< CResLibData * > ( GetItemData( nItem ) ); if (pBase == NULL) { return; } //CRect rc; //this->GetItemRect(nItem, &rc, LVIR_BOUNDS); //CPoint pt = rc.TopLeft(); //::ClientToScreen(this->GetSafeHwnd(), &pt); //pt.Offset(rc.Width()/2, rc.Height()/2); //rc.MoveToXY(pt); //CString strTip; //strTip.Format( "名称:%s\r\n作者:%s\r\n时间:%s\r\n版本:%s\r\n描述:%s" // , pBase->m_sName.c_str() // , pBase->m_sAuthor.c_str() // , pBase->m_sCreatTime.c_str() // , pBase->m_sVersions.c_str() // , pBase->m_sDsec.c_str() // ); //m_ToolTip.SetTextMargin (TEXT_MARGIN); //m_ToolTip.SetFont ( &theApp.m_font ); //m_ToolTip.Track (rc, strTip); } else { m_ToolTip.Deactivate(); Invalidate(); //CMenu * pPopup = m_RMenu.GetSubMenu(0); //MENUINFO mi; //memset(&mi, NULL, sizeof( MENUINFO )); //mi.cbSize = sizeof(mi); //m_RMenu.GetMenuInfo(&mi); } m_bMouseTracked = FALSE; SetMouseTrack( m_bMouseTracked, GetSafeHwnd() ); }
void CxResLibImgList::OnMouseMove(UINT nFlags, CPoint point) { SetMouseTrack( m_bMouseTracked, GetSafeHwnd(), g_dwToolTipDelay ); LVHITTESTINFO hti; memset(&hti, NULL, sizeof(LVHITTESTINFO)); hti.flags = LVHT_ABOVE; GetCursorPos(&(hti.pt)); ScreenToClient(&hti.pt); int nItem = -1; //检测 Item 是否选中 //当图片文字区域过长时,ListCtrl返回的区域会明显大于真实区域。 //此处可以考虑用循环遍历真实绘图区来判断。 nItem = HitTest(&hti); //焦点有变化 if (m_nLastFocusItem != nItem) { if (m_nLastFocusItem >= 0) OnFocusChanged(m_nLastFocusItem, FALSE); if (nItem >= 0) OnFocusChanged(nItem, TRUE); } m_nLastFocusItem = nItem; if (m_nLastFocusItem == -1) { m_bMouseTracked = FALSE; } if (m_bDragLayer == TRUE && nFlags == MK_LBUTTON) { m_bDragLayer = FALSE; m_ToolTip.Deactivate(); Invalidate(); DragLayer(); } Invalidate(); //CxListCtrl::OnMouseMove(nFlags, point); }
LRESULT CCxLoginBar::OnMouseHover(WPARAM wp,LPARAM lp) { //当此消息产生时,盘旋跟踪停止。如果需要进一步的鼠标盘旋跟踪,应用程序应当再次调用TrackMouseEvent。 m_bMouseTracked = FALSE; SetMouseTrack( m_bMouseTracked, GetSafeHwnd(), g_dwToolTipDelay ); CPoint ptGlobal; ::GetCursorPos(&ptGlobal); CPoint ptClient = ptGlobal; ScreenToClient(&ptClient); int iBtn = HitTest(ptClient); // 根据光标位置获取按钮ID CString strTip = ""; if (iBtn==0) { CString str; if (theApp.m_LoginData.m_strTicket.IsEmpty()) strTip = "用户名:单机版"; else strTip = "用户名:" + theApp.m_LoginData.m_strRealName; } else if (iBtn==1) { if (theApp.m_LoginData.m_strTicket.IsEmpty()) strTip = "登录"; else strTip = "注销"; } else return 0; CSize strSize = GetDC()->GetTextExtent(strTip); CRect rc(0,0,strSize.cx,strSize.cy); ptGlobal.x += g_ToolTipOffset.x; ptGlobal.y += g_ToolTipOffset.y; rc.MoveToXY(ptGlobal); m_ToolTip.SetTextMargin (TEXT_MARGIN + 2); m_ToolTip.SetFont ( &theApp.m_font ); m_ToolTip.Track (rc, strTip); return 0; }
void CCxLoginBar::OnMouseMove(UINT nFlags, CPoint point) { SetMouseTrack( m_bMouseTracked, GetSafeHwnd(), g_dwToolTipDelay ); CBCGPToolBar::OnMouseMove( nFlags, point ); }