Marco D.
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Sa 17.12.05 17:48
Also ich will eine RemoteControl hinkriegen (Fernsteuern eines anderen PCs im LAN):
Also erstmal muss der Bildschirm übertragen werden, die Mauskkordinaten bekomme ich dann alleinne hin
Eigentlich funktioniert das ja, bloß in 90% aller Fälle bekomme ich die Meldung "EInvalidOperation - Zeichnen auf Bild/Leinwand nicht möglich".
Also hier der Code des Servers, der den Fehler auslöst:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68:
| unit main;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPServer, ScktComp, XPMan, ExtCtrls,jpeg;
type TForm1 = class(TForm) XPManifest1: TXPManifest; ServerSocket1: TServerSocket; IdTCPServer1: TIdTCPServer; Image1: TImage; procedure FormCreate(Sender: TObject); procedure IdTCPServer1Execute(AThread: TIdPeerThread); procedure IdTCPServer1Connect(AThread: TIdPeerThread); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); begin
with image1 do begin left:=0; top:=0; height:=screen.height; width:=screen.width; end; end;
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread); Var BILD:TFilestream; SizeOfIncomingStream: integer; begin BILD := TFileStream.Create(ExtractFilePath(ParamStr(0)) + 'bild.bmp', fmCreate or fmShareExclusive); with AThread.Connection do begin try SizeOfIncomingStream := ReadInteger; ReadStream(BILD,SizeOfIncomingStream); finally BILD.Free; disconnect; end; end; Image1.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'bild.bmp'); end;
procedure TForm1.IdTCPServer1Connect(AThread: TIdPeerThread); begin showmessage('verbunden'); end;
end. |
Ich weiß auch nicht in welcher Zeile der Fehler auftritt, das ist total komisch.
Und der Code des Clients:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98:
| unit main;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ScktComp, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, ExtCtrls, jpeg;
type TForm1 = class(TForm) Label1: TLabel; Memo1: TMemo; ClientSocket1: TClientSocket; TCPClient1: TIdTCPClient; Image1: TImage; Timer1: TTimer; procedure Timer1Timer(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure MakeScreenShot(const ATarget: TBitmap); var DesktopDC: HDC; begin DesktopDC := CreateDC('DISPLAY', nil, nil, nil); try ATarget.PixelFormat := pfDevice; ATarget.Width := Screen.Width; ATarget.Height := Screen.Height; BitBlt(ATarget.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, DesktopDC, 0, 0, SRCCOPY); finally DeleteDC(DesktopDC); end; end;
Procedure BmpToJpg(const Filename: String; Quality: TJPEGQualityRange=100); var Bmp: TBitmap; Jpg: TJpegImage; begin Bmp:=TBitmap.Create; Jpg:=TJpegImage.Create; try Bmp.LoadFromFile(Filename); Jpg.CompressionQuality:=Quality; Jpg.Assign(Bmp); Jpg.SaveToFile(ChangeFileExt(Filename, '.jpg' )); finally Jpg.Free; Bmp.Free; end; end;
procedure TForm1.Timer1Timer(Sender: TObject); VAR BILD:TFilestream; begin MakeScreenShot(Image1.Picture.BitMap); Image1.Picture.SaveToFile(ExtractFilePath(ParamStr(0)) + 'bild.bmp'); With tcpClient1 do Begin BILD:=TFileStream.Create(ExtractFilePath(ParamStr(0)) + 'bild.bmp', fmOpenRead or fmShareDenyWrite); with tcpClient1 do begin try Connect; OpenWriteBuffer; try WriteStream(BILD, true, true, 0); CloseWriteBuffer; except CancelWriteBuffer; raise; end; finally disconnect; BILD.Free; end; end; end; end;
end. |
Ihr seid meine letzte Hilfe weil ich da echt nicht weiter weiß 
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|