Einzelnen Beitrag anzeigen

Spurius

Registriert seit: 19. Aug 2003
294 Beiträge
 
Delphi 7 Professional
 
#5

Re: stream wird nicht versendet

  Alt 13. Apr 2004, 21:02
Hallo,
erstmal Danke für die Antwort. ICh bekomme allerdings eine Zugriffsverletztung bei
Adresse 000... Lesen von 000....
Hier der Code:
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdTCPConnection, IdTCPClient, IdBaseComponent, IdComponent,
  IdTCPServer, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    server: TIdTCPServer;
    client: TIdTCPClient;
    Button1: TButton;
    Memo1: TMemo;
    Button2: TButton;
    Image1: TImage;
    Image2: TImage;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure serverExecute(AThread: TIdPeerThread);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
      procedure updateimg2;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Stream2: TMemoryStream;
implementation

{$R *.dfm} 


procedure TForm1.FormCreate(Sender: TObject);
begin
server.Active := true;
memo1.Lines[0] := '';
Stream2 := TMemorystream.Create;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
client.Connect();
end;

procedure TForm1.serverExecute(AThread: TIdPeerThread);
begin
Stream2.Clear;
Athread.Connection.ReadStream(Stream2);
AThread.Synchronize(UpdateImg2);
end;

procedure TForm1.updateimg2;
begin
 Stream2.Seek(0, soFromBeginning);
 Image2.Picture.Bitmap.LoadFromStream(Stream2);
 Stream2.Free;
end;

procedure TForm1.Button2Click(Sender: TObject);
Var Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
Image1.Picture.Bitmap.SaveToStream(Stream);
Client.WriteStream(Stream, true, true);
Stream2.Free;
end;

end.
Gruß
Spurius
  Mit Zitat antworten Zitat