Einzelnen Beitrag anzeigen

drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#1

Delphi flood text Protection

  Alt 4. Nov 2014, 22:22
hi i decided to add some flood protection to my chat application so i do something like this
Delphi-Quellcode:
begin
if IsFlood then
  begin
  ShowInfo('Anti-Flood', 20);
  Exit;
end;
end;
Delphi-Quellcode:
procedure TMAIN.ShowInfo(Text: string; Waiting: Integer);
var
  Rect: TRect;
begin
  GetWindowRect(self.Smilebtn.Handle, Rect);
  with pnlFlood do
    begin
      Caption := ' ' + Text + ' ';
      Width := self.Canvas.TextWidth(Text) + 40;
      Left := weblog.Left + 1;
      Top := weblog.Height - Height;
      if TB1.Visible then Top := Top-TB1.Height else Top := Top+TB1.Height;
      Visible := True;
      FloodpSay := 0;
      msgTmr.Enabled := True;
    end;
  FloodClose := Waiting;
end;
basically i have created a unit function called IsFlood and i adjust some visual alert to it here is my is flood unit

Delphi-Quellcode:
unit checkFlood;

  interface
  uses Windows;

  function IsFlood:Boolean;


  var
  LastFloodTime : Integer;
  floods:integer;

  implementation

 function IsFlood:Boolean;
  var
  i, x : integer;
  begin
    Result := False;
    i := trunc(GetTickCount/2);
    x := trunc((i - LastFloodTime)/4);
    Result := False;
if x < //detect flood// then Result := True;
    LastFloodTime := i;
  end;

end.
but i cant detect the fast typing ,, what iam doing wrong any help ?

Geändert von drama22 ( 5. Nov 2014 um 13:55 Uhr)
  Mit Zitat antworten Zitat