怎么给edit增加 mousewheel事件
如题.........
[解决办法]
有多个方法可以实现,我的方法:
1.定义(在unit1.h中)
public:// User declarations
__fastcall TForm1(TComponent* Owner); //原有的
void __fastcall OnEditMouseWell(Messages::TMessage &Message); //增加
Classes::TWndMethod OldEdit1WndProc; //增加
2.实现:
void __fastcall TForm1::OnEditMouseWell(Messages::TMessage &Message)
{
if (Message.Msg == WM_MOUSEWHEEL)
::MessageBox(NULL,"OK","Message",0); //测试
else
OldEdit1WndProc(Message);
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
OldEdit1WndProc=Edit1->WindowProc;
Edit1->WindowProc=OnEditMouseWell;
////这个是对某一edit来实现的,要所有的,可以循环对所有edit赋值,也可以用BEGIN_MESSAGE_MAP macro
[解决办法]
楼主可以参考这篇文章http://www.cnblogs.com/tecsoon/archive/2009/3/4.html
[解决办法]
用BEGIN_MESSAGE_MAP也很简单:
在Form的.h中加
public: // User declarations __fastcall TForm1(TComponent* Owner);protected: void __fastcall OnEditMouseWell(TMessage &Message);BEGIN_MESSAGE_MAP MESSAGE_HANDLER(WM_MOUSEWHEEL, TMessage, OnEditMouseWell)END_MESSAGE_MAP(TForm)
[解决办法]
BCB当然也支持BEGIN_MESSAGE_MAP的,HELP中就有例子
[解决办法]
没看我上面的?改为
void __fastcall WndProc(Messages::TMessage &Msg);