|
用delphi实现冰河的远程屏幕操作功能(16) LastCPS := cps; end else begin if Length(s) > 0 then Stat[0] := 'Received: ' + IntToStr(Length(CurMsg)); end;
while IsValidMessage(CurMsg) do begin s := TrimFirstMsg(CurMsg); ProcessMessage(s, Socket); end; end;
procedure TClientForm.ProcessMessage(const Msg: string; Socket: TCustomWinSocket); var MsgNum : integer; Data : string; bmp : TBitmap; R : TRect; begin Move(Msg[1], MsgNum, sizeof(integer)); if MsgNum <> MSG_STAT_MSG then Log(Format('%-7s #%0.2d %6.0n bytes %s', ['Recv', MsgNum, Length(Msg)+0.0, LastCPS]));
Data := Copy(Msg, 9, Length(Msg));
if MsgNum = MSG_STAT_MSG then begin Stat[0] := Data; exit; end;
Dec(NeedReply); if NeedReply = 0 then begin StopAnim; end;
if MsgNum = MSG_LOGON then begin if Data <> '0' then begin Stat[0] := 'Log on SUCcessful'; if ClientConnectForm.StartScreenBox.Checked then SendMsg(MSG_REFRESH, '', ClientSocket1.Socket); end else begin Stat[0] := 'Invalid PassWord!'; MessageDlg('Invalid PassWord!', mtWarning, [mbOK], 0); end; end;
if MsgNum = MSG_REFRESH then begin Stat[0] := 'Decompressing'; SaveString(Data, 'Temp2.txt'); UnCompressBitmap(Data, Image1.Picture.Bitmap); Stat[0] := 'Ready'; end;
if MsgNum = MSG_SCREEN_UPDATE then begin bmp := TBitmap.Create; Stat[0] := 'Decompressing'; UnCompressBitmap(Data, bmp); R := Rect(0, 0, bmp.Width, bmp.Height); with Image1.Picture.Bitmap.Canvas do begin CopyMode := cmSrcInvert; CopyRect(R, bmp.Canvas, R); end; Stat[0] := 'Ready'; bmp.Free; end;
if MsgNum = MSG_SEVER_DELAY then begin Stat[0] := 'Server Delay Set';
|