您的位置:程序门 -> vc/mfc -> 基础类



modifystyleex的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


modifystyleex的问题
发表于:2007-08-09 20:46:13 楼主
我从cstatic派生出自己的一个cmystatic

在onmousemove消息中处理
crect       rect;      
getclientrect(&rect);      
if(rect.ptinrect(point))//鼠标进入控件区域    
{      
setcapture();      
::setcursor(::loadcursor(null,makeintresource(idc_hand)));
modifystyleex(0,   ws_ex_clientedge);
}      
else//鼠标离开倥件区域  
{      
releasecapture();    
modifystyleex(ws_ex_clientedge,   0);
}      
为什么我的modifystyleex执行完了之后   不起作用呢???
发表于:2007-08-09 22:35:261楼 得分:0
onmousemove默认条件下static控件不会处理,
需要加入wm_nchitest的处理
让处理函数返回htclient
发表于:2007-08-10 00:39:192楼 得分:0
因为你执行不到else里面。鼠标离开了就接收不到鼠标消息。
可以使用trackmouseevent和wm_mouseleave消息。
发表于:2007-08-10 08:42:353楼 得分:0
设断点跟下..
发表于: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   ;
}


快速检索

最新资讯
热门点击