当前位置:编程学习 > Delphi >>

这个DELPHI小程序哪里错了?请高们帮忙看看

unit Unit1; inte易做图ce uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, IdTCPServer, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, ExtCtrls; type TForm1 = class(TForm) Image1: TImage; Image2: TImage; IdTCPClient1: TIdTCPClient; IdTCPServer1: TIdTCPServer; BitBtn1: TBitBtn; procedure BitBtn1Click(Sender: TObject); procedure IdTCPServer1AfterCommandHandler(ASender: TIdTCPServer; AThread: TIdPeerThread); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.BitBtn1Click(Sender: TObject); var temp:TMemoryStream; begin Temp:=TMemoryStream.Create; //将图像文件保存到内存流 Image1.Picture.Graphic.SaveToStream(Temp); //发送图像信息 IdTCPCLIENT1.Connect(); IdTCPCLIENT1.WriteStream(Temp); IdTCPCLIENT1.Disconnect(); Temp.Free; end; procedure TForm1.IdTCPServer1AfterCommandHandler(ASender: TIdTCPServer; AThread: TIdPeerThread); const TempImagefile='d:\test.bmp'; //设置的临时图像文件 var t:TMemoryStream; begin t:=TMemoryStream.Create; AThread.Connection.ReadStream(t,-1,True); //从连接中取得流式数据 t.SaveToFile(TempImageFile); Image2.Picture.LoadFromFile(TempImageFile); t.Free; end;
答案:procedure TForm1.Button1Click(Sender: TObject);
var
  temp:TMemoryStream;
begin
  Temp:=TMemoryStream.Create;
  //将图像文件保存到内存流
  Image1.Picture.Graphic.SaveToStream(Temp);
  //发送图像信息
  IdTCPCLIENT1.Connect();

  IdTCPClient1.OpenWriteBuffer;

  IdTCPCLIENT1.WriteStream(Temp);

  IdTCPClient1.CloseWriteBuffer;

  IdTCPCLIENT1.Disconnect();
  Temp.Free;
end; 

你的文件最后也没有
end.
还有接收部分也有问题。

上一个:已经用delphi做好了一个应用系统的软件编写,如何进行封装,有哪些步骤?
下一个:delphi如何实现直接实时播放话筒的声音,而不用录音

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,