Einzelnen Beitrag anzeigen

ATwardz

Registriert seit: 12. Mai 2003
205 Beiträge
 
Delphi 7 Professional
 
#10
  Alt 15. Mai 2003, 15:28
Ahhhh bei mir geht weder die eine noch die andere Lösung!

Ich habe ein testprogramm mit nur diesen Procedure erstellt!

Timer-Lösung!

Listet mir alle Ip's bis auf die Letzte auf, aber alle nur in die Listbox2!

BitBtn-Lösung!

Listet mir alle Ip's auf jedoch ebenfalls nur ind die Listbox2!

Mit F7 sieht man , das die onconnect Procedure nicht ausgeführt wird!
Ich weiss nit woran es liegt, vielleicht ist mein delphi kaputt oder verarscht mich einfach nur!

Delphi-Quellcode:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ScktComp, Buttons, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    ClientSocket1: TClientSocket;
    Timer1: TTimer;
    Button1: TButton;
    BitBtn1: TBitBtn;
    ListBox1: TListBox;
    ListBox2: TListBox;
    procedure ClientSocket1Connect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure ClientSocket1Disconnect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;
      ErrorEvent: TErrorEvent; var ErrorCode: Integer);
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    i:Integer;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ClientSocket1Connect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
  Form1.Caption:='Connected';
end;

procedure TForm1.ClientSocket1Disconnect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
  Form1.Caption:='Disconnected';
end;

procedure TForm1.ClientSocket1Error(Sender: TObject;
  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
  var ErrorCode: Integer);
begin
  Errorcode:=0;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
     ClientSocket1.Address:='192.168.0.'+inttostr(i);
     Try
     ClientSocket1.Open;
     if ClientSocket1.Socket.Connected then begin
      ListBox1.Items.Add(ClientSocket1.Host);
      ClientSocket1.Close;
     end else
      ListBox2.Items.Add(ClientSocket1.Address);
     finally
     ClientSocket1.Close;
     i:=i+1;
     if i=110 then timer1.Enabled:=False;
     end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
     i:=100;
     Timer1.Enabled:=true;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
var
i: Integer;
begin
     ListBox1.Clear;
     ListBox2.Clear;
     For i:=100 to 110 do begin
      ClientSocket1.host:='192.168.0.'+inttostr(i);
      Try
       ClientSocket1.Open;
       Application.ProcessMessages;
       if ClientSocket1.Socket.Connected then
        ListBox1.Items.Add(ClientSocket1.Host)
       else
        ListBox2.Items.Add(ClientSocket1.Host);
       ClientSocket1.Close;
      except
        beep;
      end;
     end;
end;


end.
Ich werde noch verrückt!
  Mit Zitat antworten Zitat