Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
menampilkan upload dan download Traffic pada project
#1
karena banyak yang bertanya di chat fb skrg biar gampang saya tulis disini aja sekalian .. langsung saja ..

[Image: updl.png]

yang dibutuhkan :

-2 label
-timer

ubah name label menjadi downText dan UploadText

lalu masukan code berikut pada var cari diatas {$R *.dfm}
lengkapnya

Code:
var
  Form1: TForm1;
  Download : Integer;
  Upload : Integer;

klik 2x pada timer dan masukan code dibawah

Code:
downText.Caption :=  FormatFloat('Down: ##0.## KB/s',download/1024);
UploadText.Caption :=  FormatFloat('Up: ##0.## KB/s',upload/1024);
download:= 0;
upload:= 0;


sisipkan code dibawah pada request dan respon

request :
Code:
upload:= upload+Length(AThread.NetData);

respons
Code:
download:= download+Length(AThread.NetData);

contoh lengkapnya seperti ini

Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPServer,
  IdMappedPortTCP;

type
  TForm1 = class(TForm)
    CP1: TIdMappedPortTCP;
    downText: TLabel;
    UploadText: TLabel;
    Timer: TTimer;
    procedure CP1Execute(AThread: TIdMappedPortThread);
    procedure CP1OutboundData(AThread: TIdMappedPortThread);
    procedure TimerTimer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Download : Integer;
  Upload : Integer;

implementation

{$R *.dfm}

procedure TForm1.CP1Execute(AThread: TIdMappedPortThread);
begin
upload:= upload+Length(AThread.NetData);
end;

procedure TForm1.CP1OutboundData(AThread: TIdMappedPortThread);
begin
download:= download+Length(AThread.NetData);
end;

procedure TForm1.TimerTimer(Sender: TObject);
begin
  downText.Caption :=  FormatFloat('Down: ##0.## KB/s',download/1024);
  UploadText.Caption :=  FormatFloat('Up: ##0.## KB/s',upload/1024);
  download:= 0;
  upload:= 0;
end;

end.
[Only registered and activated users can see links Click here to register]
Reply
#2
sangat bermanfaat. thanks
adi, proud to be a member of ForNesia Family since Feb 2014.
Reply
#3
koq cuman tampil 0kb trus y,,
ndk jalan om,,
adika, proud to be a member of ForNesia Family since Feb 2014.
Reply
#4
gan bagaimana mau buat meter digital sperti ini..


penampakan
Show ContentSpoiler:
[Image: fornesia_2.gif]
Reply
#5
nambah component lagi tuh om, digilabel

banyak kok, dari yg free sampe yg berbayar.
stupIDiot, proud to be a member of ForNesia Family since Feb 2014.
Reply
#6
sangat bermanfaat mas infonya Smile

btw kalo di terapin di launcer bisa ndak yaa mas..??
[Only registered and activated users can see links Click here to register] | [Only registered and activated users can see links Click here to register]

Sombong Dikit Gak Papa.... Penting Masih Selalu Lancar Aman Jaya Sentosa Sejahtera Suka Menabung wah
Reply
  


Possibly Related Threads…
Thread Author Replies Views Last Post
  Coding Menampilkan IP di Project suryadewa 4 846 04-28-2016, 09:51 PM
Last Post: shenjai47
  Membuat Warna Trafik pada Project suryadewa 14 1,290 10-14-2015, 06:54 PM
Last Post: raditya