我正在向有很多表单的应用程序发送消息 WM_COPYDATA,但我无法接收它。具有一种形式的简单应用程序可以正常工作。
我有这个主要形式的代码。未收到消息
private
procedure ReceiveMessage(var Msg: TWMCopyData); message WM_COPYDATA;
...
procedure TForm1.ReceiveMessage;
begin
ShowMessage(PAnsiChar(Msg.CopyDataStruct.lpData));
end;
我检查了应用程序和主窗体句柄。所以句柄看起来像:
Form1.Handle (main form) = 3348672
FindWindow result = Application.Handle = 7148290
FindWindowEx(Application.Handle,0,nil,nil) = 0
我在这里读到(德尔福:什么是Application.Handle?)在 Don 的回答中,发送到应用程序句柄的消息被重定向到主窗体,但在我的情况下它没有发生。如何接收消息?为什么消息不重定向到主窗体?
在 Delphi XE8、Windows 10 下测试