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''''; end;
if MsgNum = MSG_VIEW_MODE then begin Stat[0] := ''''View Mode Set''''; end;
if MsgNum = MSG_COMP_MODE then begin Stat[0] := ''''Compression Mode Set''''; end;
if MsgNum = MSG_PRIORITY_MODE then begin Stat[0] := ''''Priority Mode Set''''; end;
if MsgNum = MSG_PROCESS_LIST then begin if ProcForm = nil then ProcForm := TProcListForm.Create(Self); (ProcForm as TProcListForm).SetList(Data); ProcForm.Show; Stat[0] := ''''Received Process List''''; end;
if MsgNum = MSG_DRIVE_LIST then begin if FileForm = nil then FileForm := TFilesForm.Create(Self); (FileForm as TFilesForm).SetDriveList(Data); FileForm.Show;
Stat[0] := ''''Received Drive List''''; end;
if MsgNum = MSG_DIRECTORY then begin Assert(FileForm <> nil); (FileForm as TFilesForm).SetDirData(Data); FileForm.Show;
Stat[0] := ''''Received Directory''''; end;
if MsgNum = MSG_FILE then begin Assert(FileForm <> nil); Stat[0] := ''''Received File''''; (FileForm as TFilesForm).SetFileData(Data); end;
if MsgNum = MSG_REMOTE_LAUNCH then begin Stat[0] := ''''Launched File: '''' + Data; end; end;
procedure TClientForm.Image1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ScaleXY(X, Y); if but = 2 then begin // Only do this for Right Clicks SendMsg(MSG_CLICK, IntToByteStr(LastX) + IntToByteStr(LastY) + IntToByteStr(1 {Single}) + IntToByteStr(but), ClientSocket1.Socket); end; AddMove(x, y); end;
procedure TClientForm.ClickTimerTimer(Sender: TObject); var s : string; MoveObj : TMoveObj; i : integer; begin ClickTimer.Enabled := False;
if (MoveList.Count < 5) or (NumClick = 2) then begin // This is a Click or Double-click SendMsg(MSG_CLICK, IntToByteStr(LastX) + IntToByteStr(LastY) + IntToByteStr(NumClick) + IntToByteStr(but), ClientSocket1.Socket); end else begin // This is a "drag" operation s := IntToByteStr(but) + IntToByteStr(MoveList.Count); for i := 0 to MoveList.Count-1 do begin MoveObj := MoveList[i]; s := s + IntToByteStr(MoveObj.X) + IntToByteStr(MoveObj.Y) + IntToByteStr(MoveObj.time); end; SendMsg(MSG_DRAG, s, ClientSocket1.Socket); end; end;
procedure TClientForm.SendButClick(Sender: TObject); begin SendText(SendEdit.Text); end;
procedure TClientForm.SendCRButClick(Sender: TObject); begin SendText(SendEdit.Text + #13); end;
procedure TClientForm.SendText(const Text: string); begin SendMsg(MSG_KEYS, Text, ClientSocket1.Socket); end;
procedure TClientForm.Log1Click(Sender: TObject); begin Log1.Checked := not Log1.Checked;
UpdateLogVis; end;
procedure TClientForm.UpdateLogVis; begin LogList.Visible := Log1.Checked; Splitter1.Visible := Log1.Checked;
if Log1.Checked then LogList.Left := Splitter1.Left - 1; end;
procedure TClientForm.Log(const s: string); begin LogList.ItemIndex := LogList.Items.Add(s); end;
procedure TClientForm.CommStat1Click(Sender: TObject); begin CommStat1.Checked := not CommStat1.Checked; StatPanel.Visible := CommStat1.Checked; end;
procedure TClientForm.EnableButs; var b : boolean; begin b := ClientSocket1.Active; Connect1.Enabled := not b; Disconnect1.Enabled := b; end;
procedure TClientForm.WMSysCommand(var Message: TWMSysCommand); begin if (Message.CmdType and $FFF0 = SC_MINIMIZE) then Application.Minimize else inherited; end;
function TClientForm.CanSendMenuMsg: boolean; begin Result := ClientSocket1.Active; end;
procedure TClientForm.PauseChange(Sender: TObject); var d : integer; begin d := 0; (Sender as TMenuItem).Checked := True;
if Sender = N005sec1 then d := 50; if Sender = N010sec1 then d := 100; if Sender = N050se