其实对WM_MOUSEHOVER消息的处理,因为WindowImplBase基类中对此消息未处理,所以在自己的窗口类中实现:
.h文件中加入
1 LRESULT OnMouseHover( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
.cpp文件加入实现
1 LRESULT CLoginWnd::OnMouseHover( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) 2 { 3 POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; 4 CControlUI* pHover = m_PaintManager.FindControl(pt); 5 if( pHover == NULL ) return 0; 6 /*演示悬停在下载列表的图标上时,动态变换下载图标状态显示*/ 7 if(pHover->GetName() == _T("testbtn")) 8 { 9 MessageBox(NULL, _T("鼠标在某控件例如按钮上悬停后,对目标控件操作,这里改变了状态图标大小"), _T("DUILIB DEMO"), MB_OK); 10 ((CButtonUI *)pHover)->ApplyAttributeList( 11 _T("normalimage="file='downlist_pause.png' dest='15,9,32,26'"")); 12 } 13 return 0; 14 }