首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

怎么创建支持鼠标滚轮事件的edit控件

2012-03-28 
如何创建支持鼠标滚轮事件的edit控件根据这个来做 http://www.cnblogs.com/tecsoon/archive/2009/03/04/14

如何创建支持鼠标滚轮事件的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,删除原有控件)
[解决办法]

探讨
谢谢,改成这样确实可以了,但用新的控件运行时鼠标滚轮操作会提示错误.

热点排行