| 发表于:2007-05-11 11:37:32 楼主 |
我写了如下代码,可是就是不显示,请高手帮个忙,看一下: 我写了个类叫做cmybutton,继承cbutton的,然后,在cmybutton中添加了如下代码: class cmybutton : public cbutton { // construction public: cmybutton(); // attributes public: ctooltipctrl tipctrl;//定义提示控件 // operations public: // overrides // classwizard generated virtual function overrides //{{afx_virtual(cmybutton) public: virtual bool pretranslatemessage(msg* pmsg);//重载函数 //}}afx_virtual // implementation public: virtual ~cmybutton(); // generated message map functions protected: //{{afx_msg(cmybutton) afx_msg void onmousemove(uint nflags, cpoint point);//加了鼠标移动事件 //}}afx_msg declare_message_map() }; #include "mybutton.h " // cmybutton cmybutton::cmybutton() { tipctrl.create(this); tipctrl.addtool(this); tipctrl.setdelaytime(ttdt_initial, 0); tipctrl.settiptextcolor(rgb(255,0,0)); } cmybutton::~cmybutton() { } begin_message_map(cmybutton, cbutton) //{{afx_msg_map(cmybutton) on_wm_mousemove() //}}afx_msg_map end_message_map() ///////////////////////////////////////////////////////////////////////////// // cmybutton message handlers bool cmybutton::pretranslatemessage(msg* pmsg) { // todo: add your specialized code here and/or call the base class if(tipctrl.m_hwnd!=null)tipctrl.relayevent(pmsg); return cbutton::pretranslatemessage(pmsg); } void cmybutton::onmousemove(uint nflags, cpoint point) { // todo: add your message handler code here and/or call default cstring pos; pos.format( "%d,%d ",point.x,point.y); tipctrl.updatetiptext(pos,this); cbutton::onmousemove(nflags, point); } 调试了一下,当鼠标经过按钮时pretranslatemessage和onmousemove都触发了,但是就是不显示提示.等待中....... |
|
|
|
|