1번째 방법
---------------------------------------------------
const
WM_USER_SHOWMSG = WM_USER + 1234;
for i := 0 to Application.ComponentCount - 1 do
begin
if Application.Components[i] is TForm then
begin
if Application.Components[i].Name = 'Form2' then
SendMessage(TForm(Application.Components[i]).Handle, WM_USER_SHOWMSG, 1000, 0 );
end;
end;
2번재 방법
-----------------------------------------------------
const
WM_USER_SHOWMSG = WM_USER + 1234;
For I:= 0 to Screen.FormCount - 1 do
Begin
IF Screen.Forms[I].Name = 'Form2' then
begin
SendMessage(TForm(Screen.Forms[I]).Handle, WM_USER_SHOWMSG, 1000, 0 );
end;
end;
받는쪽 처리
protected
procedure WndProc(var message:TMessage); Override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{
메시지 주고 받기 샘플
2006.07.18 신원진.키란디아
kyrandia@empal.com
}
var
iCnt: Integer = 0;
const
WM_USER_SHOWMSG = WM_USER + 1234;
procedure TForm1.WndProc(var message:TMessage);
begin
inherited WndProc(Message);
Case Message.Msg of
WM_USER_SHOWMSG:
begin
if (Message.WParam = 1000) then
begin
Panel1.Caption := '신호를 받았습니다.' + ' (' + IntToStr(iCnt) + ')';
Inc(iCnt);
end;
end;
end;
end;