方法一WindowProc
void __fastcall myWindowProc(Messages::TMessage &Message); //增加
Classes::TWndMethod OldWindowProc; //增加
void __fastcall TForm1::myWindowProc(Messages::TMessage &Message)
{
if (Message.Msg == WM_MOUSEWHEEL)
{
//::MessageBox(NULL,"OK","Message",0); //测试
Caption = Now();
}
else
OldWindowProc(Message);
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
OldWindowProc=Edit1->WindowProc;
Edit1->WindowProc=myWindowProc;
}
方法二 MESSAGE_MAP
class TForm1 : public TForm
{
__published: // IDE-managed Components
TEdit *Edit1;
private: // User declarations
void __fastcall OnEditMouseWell(TMessage &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_MOUSEWHEEL, TMessage, OnEditMouseWell)
END_MESSAGE_MAP(TForm) //TForm 换成TEdit
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
void __fastcall TForm1::OnEditMouseWell(TMessage &Message)
{
if(String(ActiveControl->ClassName())=="TEdit") //所有的Edit
Caption = Now(); //测试
//TForm::Dispatch(&Msg);
}
方法三 重载 WndProc
private: // User declarations
void __fastcall WndProc(Messages::TMessage &Message);
void __fastcall TForm1::WndProc(Messages::TMessage &Message)
{
if (Message.Msg == WM_MOUSEWHEEL && Message.WParam )
{
Caption = Now();
}
TForm::WndProc(Message);
}