[서버쪽 소스]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DdeMan;
type
TForm1 = class(TForm)
Timer1: TTimer;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
DdeServerConv1: TDdeServerConv;
DdeServerItem1: TDdeServerItem;
DdeServerItem2: TDdeServerItem;
DdeServerItem3: TDdeServerItem;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure DdeServerItem1Change(Sender: TObject);
procedure DdeServerItem2Change(Sender: TObject);
procedure DdeServerItem3Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
uTemp1,uTemp2,uTemp3 : String;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
// Timer1.Interval := 500;
// Timer1.Enabled := True;
Timer1Timer(Sender);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Randomize;
Edit1.Text := IntToStr(random(100) + random(10));
Edit2.Text := IntToStr(random(100) + random(20));
Edit3.Text := IntToStr(random(100) + random(30));
DdeServerItem1.Text := Edit1.Text;
DdeServerItem2.Text := Edit2.Text;
DdeServerItem3.Text := Edit3.Text;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled := False;
end;
procedure TForm1.DdeServerItem1Change(Sender: TObject);
begin
Edit1.Text := DdeServerItem1.Text;
end;
procedure TForm1.DdeServerItem2Change(Sender: TObject);
begin
Edit2.Text := DdeServerItem2.Text;
end;
procedure TForm1.DdeServerItem3Change(Sender: TObject);
begin
Edit3.Text := DdeServerItem3.Text;
end;
end.
[클라이언트 쪽 소스]
unit Client;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DdeMan, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
StatusBar1: TStatusBar;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Edit3: TEdit;
DdeClientConv1: TDdeClientConv;
DdeClientItem1: TDdeClientItem;
DdeClientItem2: TDdeClientItem;
DdeClientItem3: TDdeClientItem;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure DdeClientConv1Open(Sender: TObject);
procedure DdeClientItem1Change(Sender: TObject);
procedure DdeClientItem2Change(Sender: TObject);
procedure DdeClientItem3Change(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); //DDE연결버튼
begin
DdeClientConv1.CloseLink;
if DdeClientConv1.SetLink('DDE_APP','DdeServerConv1') then
begin
StatusBar1.SimpleText := 'DDE 서버와 연결되었습니다.';
DdeClientConv1.OpenLink;
end
else
StatusBar1.SimpleText := '연결에 실패했습니다.';
end;
procedure TForm1.Button2Click(Sender: TObject); //DDE해제버튼
begin
DdeClientConv1.CloseLink;
end;
procedure TForm1.DdeClientConv1Open(Sender: TObject);
begin
DdeClientItem1.DdeItem := 'DdeServerItem1';
DdeClientItem2.DdeItem := 'DdeServerItem2';
DdeClientItem3.DdeItem := 'DdeServerItem3';
end;
procedure TForm1.DdeClientItem1Change(Sender: TObject);
begin
Edit1.Text := DdeClientItem1.Text;
end;
procedure TForm1.DdeClientItem2Change(Sender: TObject);
begin
Edit2.Text := DdeClientItem2.Text;
end;
procedure TForm1.DdeClientItem3Change(Sender: TObject);
begin
Edit3.Text := DdeClientItem3.Text;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
// TheData: PChar;
TheData: array[0..79] of Char;
begin
// DdeClientConv1.PokeData(DdeClientItem1.DdeItem ,StrPCopy(TheData, Edit1.Text));
DDEClientConv1.PokeData(DDEClientItem1.DDEItem,StrPCopy(TheData, Edit1.Text));
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
DdeClientItem1Change(Sender);
DdeClientItem2Change(Sender);
DdeClientItem3Change(Sender);
end;
end.