TNMStrm来传递图像(d5+pwin98+10M网卡)
procedure Tclientform.NMMSGServ1MSG(Sender: TComponent; const sFrom,
sMsg: String);
var
DeskTopDC: HDc;
bitmap:tbitmap;
jpegimage:tjpegimage;
DeskTopCanvas: TCanvas;
strm1:tstream;
DeskTopRect: TRect;
begin
if pos('getscreen',smsg)<>0 then
begin
DeskTopDC := GetWindowDC(GetDeskTopWindow);
DeskTopCanvas := TCanvas.Create;
bitmap:=tbitmap.Create ;
jpegimage:=tjpegimage.Create ;
strm1:=tmemorystream.Create ;
DeskTopCanvas.Handle := DeskTopDC;
DeskTopRect := Rect(0,0,Screen.Width,Screen.Height);
bitmap.Width :=screen.Width;// div 2 ;
bitmap.Height :=screen.Height;// div 2 ;
bitmap.Canvas.CopyRect(rect(0,0,bitmap.Width,bitmap.Height),DeskTopCanvas,DeskTopRect);
jpegimage.Assign (bitmap);
nmstrm1:=tnmstrm.Create(self);
jpegimage.SaveToStream (strm1);
try
with nmstrm1 do
begin
Host := copy(sfrom,pos('>',sfrom)+1,255);
Port := 801;
FromName := nmstrmserv1.LocalIP;
TimeOut := 10000;
ReportLevel := Status_Basic;
PostIt(strm1);
end;
except
nmstrm1.Destroy ;
bitmap.Free;
jpegimage.Free ;
strm1.Free ;
ReleaseDC(GetDeskTopWindow,DeskTopDC);
exit;
end;
nmstrm1.Destroy ;
bitmap.Free;
jpegimage.Free ;
strm1.Free ;
ReleaseDC(GetDeskTopWindow,DeskTopDC);
end
else
Memomsg.Lines.Add(copy(sFrom,1,pos('>',sfrom))+sMsg);
end;
--------
procedure Tclientform.NMStrmServ1MSG(Sender: TComponent;
const sFrom: String; strm: TStream);
var
jpegimage:tjpegimage;
begin
jpegimage:=tjpegimage.Create ;
try
jpegimage.LoadFromStream (strm);
frmclientscreen.Show;
frmclientscreen.Canvas.StretchDraw(frmclientscreen.clientrect,jpegimage);
except
jpegimage.Free ;
memomsg.Width :=clientform.ClientWidth ;
exit;
end;
jpegimage.Free ;
end;