哪位有XE3的试一下 谢谢!!!
__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) ;
}
以上代码 在CB6里完全正常 可是换到XE3里 无法拦截这两个消息,请问是什么问题呢?
[解决办法]
.h文件
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 = "鼠标进入";
}
}