动态创建NMStrmServ无法响应OnMsg

benbenfei 2004-04-01 08:10:03
动态创建一个NMStrmServ无法响应OnMsg事件。
我是照动态创建button的方法动态创建的一个NMStrmServ。动态创建的button可以响应OnClick事件。
请给出动态创建NMStrmServ能响应OnMsg事件的代码。
在线等待!
...全文
31 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
benbenfei 2004-04-01
  • 打赏
  • 举报
回复
我自己的代码如下,应该怎么改?
unit Unit1;

interface

uses
Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
ExtCtrls,Psock,NMSTRM,StdCtrls;

type
TForm1=class(TForm)
Button1:TButton;
Image1:TImage;
procedure FormClose(Sender:TObject;var Action:TCloseAction);
procedure StrmServMSG(Sender:TComponent;const sFrom:string;strm:TStream);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1:TForm1;
StrmC:TNMStrm;
StrmServ:TNMStrmServ;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender:TObject);
var
BmpStr:TMemoryStream;
begin
StrmC:=TNMStrm.Create(self);
StrmC.Port:=6711;
StrmC.Host:='127.0.0.1';
StrmServ:=TNMStrmServ.Create(self);
StrmServ.Port:=6711;
StrmServ.OnMSG:=StrmServMSG;
BmpStr:=TMemorystream.Create;
Image1.Picture.Bitmap.SaveToStream(BmpStr);
StrmC.PostIt(BmpStr);
BmpStr.Free;
end;

procedure TForm1.StrmServMSG(Sender:TComponent;const sFrom:string;strm:TStream);
begin
Showmessage('Get');
end;

procedure TForm1.FormClose(Sender:TObject;var Action:TCloseAction);
begin
StrmC.Free;
StrmServ.Free;
end;

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧