B
berg
Unregistered / Unconfirmed
GUEST, unregistred user!
server:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DdeMan;
type
TForm1 = class(TForm)
DdeServerConv1: TDdeServerConv;
DdeServerItem1: TDdeServerItem;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure Edit1Change(Sender: TObject);
procedure DdeServerItem1PokeData(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Edit1Change(Sender: TObject);
begin
// 将Edit1组件中的内容发送向客户机端
DdeServerItem1.Text:=Edit1.Text;
end;
procedure TForm1.DdeServerItem1PokeData(Sender: TObject);
begin
// 根据回传数据改变Edit2组件中的显示内容
Edit2.Text:=DdeServerItem1.Lines.Strings[0];
end;
end.
client:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DdeMan;
type
TForm2 = class(TForm)
DdeClientConv1: TDdeClientConv;
DdeClientItem1: TDdeClientItem;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Button3: TButton;
procedure DdeClientItem1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
procedure TForm2.DdeClientItem1Change(Sender: TObject);
begin
// 响应DDE服务器端数据的改变:
Edit2.Text:=DdeClientItem1.Text;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
DdeClientConv1.PokeDataLines(DdeClientItem1.DdeItem, Memo1.Lines);
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
DdeClientConv1.CloseLink(); // 关闭链接
end;
procedure TForm2.Button3Click(Sender: TObject);//手动来连接
begin
ddeclientconv1.connectmode:=ddemanul;
DdeClientItem1.DdeConv:=DdeClientConv1;
// 设置链接,指定DDE服务:
ddeclientconv1.DdeService:='project1';
ddeclientconv1.DdeTopic:='ddeserverconv1';
DdeClientItem1.DdeItem:='DdeServerItem1'; // 指定DDE主题
ddeclientconv1.OpenLink;
end;
end.
我的手动连接这样做对吗?
为什么每当我关闭连接后,在打开连接是没什么反应的呢?(点击button2后再点
击button3没什么反应)请指点!谢谢!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DdeMan;
type
TForm1 = class(TForm)
DdeServerConv1: TDdeServerConv;
DdeServerItem1: TDdeServerItem;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure Edit1Change(Sender: TObject);
procedure DdeServerItem1PokeData(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Edit1Change(Sender: TObject);
begin
// 将Edit1组件中的内容发送向客户机端
DdeServerItem1.Text:=Edit1.Text;
end;
procedure TForm1.DdeServerItem1PokeData(Sender: TObject);
begin
// 根据回传数据改变Edit2组件中的显示内容
Edit2.Text:=DdeServerItem1.Lines.Strings[0];
end;
end.
client:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DdeMan;
type
TForm2 = class(TForm)
DdeClientConv1: TDdeClientConv;
DdeClientItem1: TDdeClientItem;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Button3: TButton;
procedure DdeClientItem1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
procedure TForm2.DdeClientItem1Change(Sender: TObject);
begin
// 响应DDE服务器端数据的改变:
Edit2.Text:=DdeClientItem1.Text;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
DdeClientConv1.PokeDataLines(DdeClientItem1.DdeItem, Memo1.Lines);
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
DdeClientConv1.CloseLink(); // 关闭链接
end;
procedure TForm2.Button3Click(Sender: TObject);//手动来连接
begin
ddeclientconv1.connectmode:=ddemanul;
DdeClientItem1.DdeConv:=DdeClientConv1;
// 设置链接,指定DDE服务:
ddeclientconv1.DdeService:='project1';
ddeclientconv1.DdeTopic:='ddeserverconv1';
DdeClientItem1.DdeItem:='DdeServerItem1'; // 指定DDE主题
ddeclientconv1.OpenLink;
end;
end.
我的手动连接这样做对吗?
为什么每当我关闭连接后,在打开连接是没什么反应的呢?(点击button2后再点
击button3没什么反应)请指点!谢谢!