| 发表于:2007-08-10 10:00:444楼 得分:0 |
用trackmouseevent和wm_mouseleave: 1: .h文件声明变量 class cstaticlayer { bool m_binwindow ; } 2:声明消息宏 #define on_wm_mouseleave() \ { wm_mouseleave , 0, 0, 0, afxsig_vv, \ (afx_pmsg)(afx_pmsgw) \ (static_cast < void (afx_msg_call cwnd::*)(void) > (onmouseleave)) }, 3:消息映射 begin_message_map(cstaticlayer, cstatic) on_wm_mouseleave() end_message_map() 4:变量初始化 cstaticlayer::cstaticlayer() { m_binwindow = false; } 5:wm_mousemove里trackmouseevent void cstaticlayer::onmousemove(uint nflags, cpoint point) { if( !m_binwindow ) { trackmouseevent tme; m_binwindow = true; tme.cbsize = sizeof( trackmouseevent ); tme.dwflags = tme_leave; tme.hwndtrack = m_hwnd ; trackmouseevent( &tme ) ; modifystyleex(0, ws_ex_clientedge); } } 6:wm_mouseleave消息处理函数 void cstaticlayer::onmouseleave( ) { m_binwindow = false; modifystyleex( ws_ex_clientedge,0 ); return ; } | | |
|