如何创建支持鼠标滚轮事件的edit控件
根据这个来做 http://www.cnblogs.com/tecsoon/archive/2009/03/04/1403114.html
.h 文件
class PACKAGE TWedit : public TEdit
{
private:
TMouseWheelEvent fMouseWheel ;
TMouseWheelUpDownEvent fMouseWheelUp ; //鼠标轮上滚事件
TMouseWheelUpDownEvent fMouseWheelDown ; //鼠标轮下滚事件
protected:
public:
__fastcall TWedit(TComponent* Owner);
void __fastcall WndProc(Messages::TMessage &Msg);
__published:
__property TMouseWheelEvent OnMouseWheel = { read = fMouseWheel, write= fMouseWheel };
__property TMouseWheelUpDownEvent OnMouseWheelUp ={ read = fMouseWheelUp, write = fMouseWheelUp } ;
__property TMouseWheelUpDownEvent OnMouseWheelDown ={ read= fMouseWheelDown, write = fMouseWheelDown } ;
};
.cpp 文件
void __fastcall WndProc(Messages::TMessage &Msg)
{
TPoint MousePoint ;
Boolean Handled ;
TShiftState shift ;
if(Msg.Msg==WM_MOUSEWHEEL)
{
MousePoint.x = LOWORD(Msg.LParam);
MousePoint.y = HIWORD(Msg.LParam);
Handled = False ;
if(Msg.WParam > 0 ) //上滚
{
fMouseWheelUp(self,shift,MousePoint,Handled) ;
}
}
}
现在的问题,编译提示错误 call to undefined function 'fMouseWheelUp' ;
[解决办法]
看了一下你的程序,你的Tedit继承错了,用了QStdCtrls单元的(CLX类,那是在Unix/Linux下用的)
重新做一遍.在选Ancestor type时选
TEdit( StdCtrls )//第二个Tedit
然后将你的程序贴入重新编译安装应该可以了
(先在你的项目中删除QWEedit,并builder,删除原有控件)
[解决办法]