delphi - Delphi:最小化应用程序时Windows消息失败
问题描述
我有一个要求,我必须将值从 application1 传递到 application2。从以下链接获得了解决方案:
发件人的示例代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
WM_MY_MESSAGE = WM_USER + 1;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
h: HWND;
begin
h := FindWindow(nil, 'My Second Window');
if IsWindow(h) then
SendMessage(h, WM_MY_MESSAGE, 123, 520);
end;
end.
接收器示例代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
const
WM_MY_MESSAGE = WM_USER + 1;
type
TForm1 = class(TForm)
private
{ Private declarations }
protected
procedure WndProc(var Message: TMessage); override;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WndProc(var Message: TMessage);
begin
inherited;
case Message.Msg of
WM_MY_MESSAGE:
ShowMessageFmt('The other application sent the data %d and %d.', [Message.WParam, Message.LParam]);
end;
end;
end.
但是当标题为“我的第二个窗口”的应用程序最小化时,这不能正常工作。任何帮助表示赞赏。
解决方案
推荐阅读
- javascript - 谷歌地图在javascript中放大和缩小两次
- opencl - 在 OpenCL 上,我们可以假设连续写入是原子的吗?
- php - Symfony,在运行时更改数据库
- c# - HTTP 错误 500.52 - URL 重写模块错误。名称属性
- python - 整数值之间的条件前向填充
- laravel - 无法在 laravel 上使用 swagger 生成文档
- mysql - 动态数据透视表列mysql
- reactjs - 在 Firefox 中反应输入失去焦点
- javascript - 在将数组元素转换为字符串时附加逗号
- ruby - 即使捆绑程序已成功安装,也无法找到 gemfile