Mam problem i nigdzie w internecie nie moge znaleźć odpowiedzi. Mianowicie chodzi o klasę TMemoryStream.
Gdy ładuje bitmapę do FStream wszystko gra. Lecz po przesłaniu jej z serwera do klienta otrzymuje komunikat:
---------------------------
Debugger Exception Notification
---------------------------
Project Screen.exe raised exception class EOutOfMemory with message 'Out of memory'.
---------------------------
Break Continue Help
---------------------------
A Windows(Vista) pokazuje mi takie coś
---------------------------
Screen
---------------------------
Out of memory.
---------------------------
OK
---------------------------
Przycisk w kliencie, który ma odebrać bitmapę:
procedure TForm1.Button1Click(Sender: TObject);
begin
IdTCPClientScreen.IOHandler.Writeln('SCREEN');
IdTCPClientScreen.IOHandler.ReadStream(FStream); //FStream zadeklarowane w private i utworzone w OnCreate formy. Tak samo w drugim kodzie...
FStream.Position := 0;
Screen.Picture.Bitmap.LoadFromStream(FStream); //Screen - komponent TImage
end;
Kod serwera:
procedure TForm2.IdTCPServerScreenExecute(AContext: TIdContext);
var
lCMD: String;
Can: TCanvas;
B : TBitmap;
begin
lCmd := Trim(AContext.Connection.IOHandler.ReadLn);
if AnsiSameText(lCMD, 'DISCONNECT SERVER 2') then
begin
AContext.Connection.IOHandler.WriteLn('Rozłączono');
AContext.Connection.Disconnect;
end;
if AnsiSameText(lCMD, 'SCREEN') then
begin
try
{ tworzenie zmiennej }
Can := TCanvas.Create;
{ przechwycenie uchwytu ekrnau }
Can.Handle := GetWindowDC(GetDesktopWindow);
{ tworzenie bitmapy }
B := TBitmap.Create;
B.Width := Screen.Width;
B.Height := Screen.Height;
B.Canvas.CopyRect(Rect(0, 0, Screen.Width, Screen.Height),
Can,
Rect (0, 0, Screen.Width, Screen.Height));
B.SaveToStream(FStream);
finally
Can.Free;
B.Free;
end;
FStream.Position := 0;
AContext.Connection.IOHandler.Write(FStream);
end;
end;
Serwer nie pokazuje żadnych błędów. Na czm polega problem? Potrzebuje szybkiej pomocy, bo nie długo kończy mi się licencja na program.