unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
Const
wm_My=wm_User+
300
;
type
TwmMy=
packed
record
Msg:
Cardinal
;
str:
array
[
0..10
]
of
char
;
WParam,LParam :
LongInt
;
end
;
type
TForm1 =
class
(TForm)
Button1: TButton;
procedure
Button1Click(Sender: TObject);
private
public
end
;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure
TForm1
.
Button1Click(Sender: TObject);
var
Windowname:hwnd;
mess:TWMMY;
begin
WindowName:=FindWindow(
PChar
(
0
),
'Destination'
);
mess
.
str:=
'123?321'
;
SendMessage(WindowName,wm_my,mess
.
WParam,mess
.
LParam);
end
;
end
.
Вторая принимает сообщение:
unit
target;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
const
wm_my=wm_user+
300
;
type
TwmMy=
packed
record
Msg:
Cardinal
;
str:
array
[
0..10
]
of
char
;
WParam,LParam:
LongInt
;
end
;
TDestination =
class
(TForm)
Label1: TLabel;
Label2: TLabel;
private
procedure
wmMy(
var
msg:TwmMy );message wm_my;
public
end
;
var
Destination: TDestination;
implementation
{$R *.dfm}
procedure
TDestination
.
wmMy(
var
msg:TwmMy);
var
p:
integer
;
begin
with
msg
do
begin
p:=pos(
'?'
,str);
Label2
.
Caption:=IntToStr(p);
end
;
end
;
end
.