13,825
社区成员
发帖
与我相关
我的任务
分享
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Panel1->WindowProc = NewProc ;//Panel1 是一个TPanel
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NewProc(TMessage &Message)
{
if (Message.Msg == CM_MOUSELEAVE)
{
Panel1->Caption = "鼠标离开";
}
else if (Message.Msg == CM_MOUSEENTER)
{
Panel1->Caption = "鼠标进入";
}
Panel1->Dispatch(&Message) ;
}
private: // User declarations
TWndMethod FPanelWndProc;
void __fastcall NewProc(TMessage &Message);
.cpp文件
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
FPanelWndProc = Panel1->WindowProc;
Panel1->WindowProc = NewProc;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NewProc(TMessage &Message)
{
FPanelWndProc(Message);
if (Message.Msg == CM_MOUSELEAVE)
{
Panel1->Caption = "鼠标离开";
}
else if (Message.Msg == CM_MOUSEENTER)
{
Panel1->Caption = "鼠标进入";
}
}
void __fastcall TForm1::Panel1MouseLeave(TObject *Sender)
{
Panel1->Caption = "鼠標離開";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Panel1MouseEnter(TObject *Sender)
{
Panel1->Caption = "鼠標進入";
}