sendmessage无法跟踪进函数 - C++ Builder / Windows SDK/API
void __fastcall OnSendFileList(TMessage &Msg);
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_SENDFILELIST, TMessage, OnSendFileList)
VCL_MESSAGE_HANDLER(WM_SENDFILESTATUS, TMessage, OnSendFileStatus)
VCL_MESSAGE_HANDLER(WM_RECEIVEREPLY, TMessage, OnReceiveReplay)
VCL_MESSAGE_HANDLER(WM_BINDERROR, TMessage, OnBindError)
VCL_MESSAGE_HANDLER(WM_LISTENERROR, TMessage, OnListenError)
VCL_MESSAGE_HANDLER(WM_STARTLISTEN, TMessage, OnStartListen)
END_MESSAGE_MAP(TForm)
void __fastcall TfrmSendFile::OnStartListen(TMessage &Msg)
{
ShowMessage('a');
return;
}
我是这样定义的消息,但调试时,进不了函数里边,不知道为什么?
[解决办法]
//做了个测试没问题void __fastcall TForm1::Button5Click(TObject *Sender){ SendMessage((HWND)this->Handle ,WM_STARTLISTEN, 100, NULL );}//hconst DWORD WM_STARTLISTEN = WM_USER+ 100;class TForm1 : public TForm{__published: // IDE-managed Components TButton *Button5; void __fastcall Button5Click(TObject *Sender);private: // User declarations void __fastcall OnStartListen(TMessage &Msg); BEGIN_MESSAGE_MAP VCL_MESSAGE_HANDLER(WM_STARTLISTEN, TMessage, OnStartListen)END_MESSAGE_MAP(TForm)
[解决办法]
你要确认向Form窗口发送了WM_STARTLISTEN消息。