两端C++BUILDER代码
1、消息映射
void __fastcall KeyUPFunc(TWMKeyUp &Msg)
{
ShowMessage("a");
}
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_KEYUP,TWMKeyUp,KeyUPFunc)
END_MESSAGE_MAP(TForm)
//都写到.h文件
2、通过OnMessage来处理消息
void __fastcall AppMessage(tagMSG &Msg, bool &Handled); //.h文件
void __fastcall TForm1::AppMessage(tagMSG &Msg, bool &Handled)
{
if (Msg.message == WM_KEYUP)
{
ShowMessage("按了键盘");
Handled = false;
}
/* for all other messages, Handled remains False so that other message handlers can respond */
}
.cpp文件