Первый модуль (посылает сообщение):
Код:
unit send;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Spin;
type
TForm1 = class(TForm)
Button1: TButton;
SpinEdit1: TSpinEdit;
SpinEdit2: TSpinEdit;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
globalVar1, globalVar2 : integer;
implementation
{$R *.dfm}
const
MyMsg = WM_USER;
procedure TForm1.Button1Click(Sender: TObject);
begin
globalVar1 := SpinEdit1.Value; // set globalVar1
globalVar2 := SpinEdit2.Value; // set globalVar1
PostMessage (FindWindow('TForm1'{class name},'MyWaitMsg' {window title}),
MyMsg, globalVar1, globalVar2);
end;
end.
Второй - принимает:
Код:
unit wait;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
MyMsg = WM_USER;
type
TForm1 = class(TForm)
Memo1: TMemo;
private
{ Private declarations }
procedure OnMyMsg (var a : TMessage); message MyMsg;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.OnMyMsg (var a : TMessage);
begin
Memo1.Lines.Add('Var1 = '+intToStr(a.WParam)+', Var2 = '+intToStr(a.LParam))
end;
end.
Wind XP, Delphi 7.
Если хотите - напишите в ЛС свой email: вышлю все файлы. Про функции PostMessage и т.д. см.
MSDN.
Желаю успеха!