Autor Beitrag
PeterKiers
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26


D7
BeitragVerfasst: Mo 14.03.05 15:03 
Hallo liebe Leute!



Ich bin derzeit mit einem Programm beschäftigt,dass eine Anzahl Servers
controliert(Pingen).
Ich habe eine Stringgrid mit einer Menge Server-namen
darin, und mein Programm läuft durch die Cellen um die Server-namen zu
controlieren.
Aber mein Programm kontroliert auch die leeren Cellen !
Ich habe 4 Reihen in meiner Stringgrid, wovon die vierte Reihe
nur halb gefühllt ist, doch mein Programm kontroliert auch
de leeren Cellen von der vierte Reihe.
Weiss vieleicht jemand von euch, wie man dass Problem auflösen kann, so
dass mein Programm nur die Cellen kontroliert die angefüllt sind mit Text?


Im voraus, vielen Dank!

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
procedure TFormServers.FormCreate(Sender: TObject);
begin
  // beter constructor Create i.p.v. OnCreate, eigenlijk
  ProgressBar1.Smooth := True;
  StartWaiting;
end;

procedure TFormServers.CheckCurrentServer;
begin
  with GridServers do
    CheckServer(Cells[Col,Row]);
end;

function TFormServers.IsWaiting: Boolean;
begin
  Result := ProgressBar1.Position < ProgressBar1.Max;
end;

procedure TFormServers.ContinueWaiting;
begin
  ProgressBar1.StepIt;
end;

procedure TFormServers.Timer1Timer(Sender: TObject);
begin
  if IsWaiting then
    ContinueWaiting
  else  begin
    CheckCurrentServer;
    NextServer;
  end;
end;

procedure TFormServers.StartWaiting;
begin
  ProgressBar1.Position := ProgressBar1.Min;  FirstServer;end;

procedure TFormServers.NextServer;
begin
  with GridServers do
  if Col < Pred(ColCount) then Col := Succ(Col)
  else if Row < Pred(RowCount) then
    begin
      Col := FixedCols;
      Row := Succ(Row);
    end
  else StartWaiting;
end;

procedure TFormServers.FirstServer;
begin
  with GridServers do
  begin
    Row := FixedRows;
    Col := FixedCols;
  end;
end;

procedure TFormServers.CheckServer(const AServer: string);
begin
  Caption := 'Checking Server: ' +  AServer + ' ...';
end;


Oder in OnDrawCell:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
procedure TForm1.GridServersDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  Kleur: TColor;
begin
  with (Sender as TStringGrid) do
  begin
    if gdFixed in State then Kleur := FixedColor
    else if IsWaiting then Kleur := Color
    else if gdFocused in State then Kleur := clYellow
    else if gdSelected in State then Kleur := clLime
    else Kleur := Color;
    with Canvas do
    begin
      Brush.Color := Kleur;
      Font.Color := clBlack;
      FillRect(Rect);
      if not IsWaiting and (gdFocused in State) then
      begin
       Draw(Rect.Left, Rect.Top, Image1.Picture.Graphic);
       Rect.Left := Rect.Left + Image1.Width +2;
       end;
       TextOut(Rect.Right - TextWidth(Cells[ACol, ARow]) - 2,
              Rect.Top + 2, Cells[ACol, ARow]);

    end;
  end;
end;


Peter Kiers

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt(2.Beitrag) und Beiträge zusammengefasst
EUOCheffe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124



BeitragVerfasst: Mo 14.03.05 17:16 
Sieht so aus als ob die NextServer Funkton für die Auswahl der Zelle verantwortlich ist. Die aktuelle Auswahl wird in Col und Row gespeichert. D.h. bevor du eine Zelle endgültig selektierst, solltest du prüfen, ob die Zelle überhaupt einen gültigen String enthält. Vielleicht irgendwie so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TFormServers.NextServer;
begin  
  with GridServers do  
  if Col < Pred(ColCount) then Col := Succ(Col)  
  else if Row < Pred(RowCount) then  
    begin  
      Col := FixedCols;  
      Row := Succ(Row);  
    end  
  else begin
    StartWaiting;
    Exit;
  end;
  
  if GridServers.Cells[Col,Row]='' then
    NextServer;  
end;

Das muss natürlich auch noch funktionieren, wenn das allerletzte Element leer ist und du wieder zum Anfang springen oder abbrechen solltest (darum hab ich mal das Exit hinzugefügt). Falls es noch nicht ganz stimmt, musst du es halt richtig anpassen.
PeterKiers Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26


D7
BeitragVerfasst: Mo 14.03.05 19:21 
Ich hab deine Code probiert es läuft bis den letzten String mit Text, danach hört es
auf. Selbst hab alles versucht was möglich ist aber es functioniert nicht.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Procedure TForm1.NextServer;
begin
  with GridServers do
  if Row < Pred(RowCount)then Row :=
  Succ (Row)
    else if Col < Pred(ColCount)then
    begin
     Row := FixedRows;
     Col := Succ(Col);
     end else
     begin
     StartWaiting;

     if GridServers.Cells[Row,Col]= '' then
     NextServer;
     end;
end;


Peter

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 14.03.05 20:55 
Warum machst Du das nicht einfach so hier???

ausblenden Delphi-Quelltext
1:
2:
3:
4:
For X := 0 to SG.ColCount - 1 do
    For Y := 0 To SG.RowCount - 1 do
        If SG.Cells[X,Y] <> '' Then 
            StartWaiting(SG.Cells[X,Y]);


Wobei StartWaiting als ersten Parameter die IP des anzupingenden Servers entgegennimmt.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
PeterKiers Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26


D7
BeitragVerfasst: Mo 14.03.05 21:09 
Ich möchte gerne wissen in welche Prozedur ich dein Text hinzufügen soll.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 14.03.05 21:54 
Der Quelltext kommt in die TForm1.NextServer-Prozedure rein. Nicht vergessen X und Y als Integer dort lokal zu deklarieren.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
PeterKiers Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26


D7
BeitragVerfasst: Mo 14.03.05 22:00 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Procedure TForm1.NextServer;
var
X, Y:Ingeger;
begin
  with GridServers do
  if Row < Pred(RowCount)then Row :=
  Succ (Row)
    else if Col < Pred(ColCount)then
    begin
     Row := FixedRows;
     Col := Succ(Col);
    end else
     begin
     For X := 0 to GridServers.ColCount - 1 do
      For Y := 0 To GridServers.RowCount - 1 do
       If GridServers .Cells[X,Y] <> '' Then 
        StartWaiting(Cells[X,Y]);
 end;
end;



TOO MANY ACTUAL PARAMETERS !!!

Moderiert von user profile iconMotzi: Delphi-Tags hinzugefügt.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 14.03.05 22:59 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Procedure TForm1.NextServer;
var
 X, Y:Ingeger;
begin
 with GridServers do
  For X := 0 to ColCount - 1 do
   For Y := 0 To RowCount - 1 do
    If Cells[X,Y] <> '' Then 
     StartWaiting(Cells[X,Y]);
end;


Bitte den Kommentar in meinem ersten Post beachten:


user profile iconBenBE hat folgendes geschrieben:
Wobei StartWaiting als ersten Parameter die IP des anzupingenden Servers entgegennimmt.


D.h. konkret, dass du deine Prozedure StartWaiting so ergänzen musst, dass sie die Server-IP über die Parameter liest.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
PeterKiers Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26


D7
BeitragVerfasst: Di 15.03.05 07:11 
Danke,aber es functioniert nicht.

Peter Kiers
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 15.03.05 08:17 
Bitte geb immer exakte Fehlerbeschreibungen mit an, da man mit "Es funktioniert nicht." nicht allzuviel anfangen kann ...

Evtl. den Source deiner StartWaiting-Procedure mal kurz senden...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 15.03.05 08:22 
hallo peter, es gibt auch holländische delphi-foren, vielleicht tust du dir da etwas leichter !
www.google.nl/search...oeken&lr=lang_nl

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
PeterKiers Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26


D7
BeitragVerfasst: Do 17.03.05 13:48 
Ich habe das Problem schon selbst gelöst.

Vielen Dank für die Hilfe

procedure TFormServers.NextServer;
begin
with GridServers do
if Row < Pred(RowCount) then Row := Succ(Row)
else if Col < Pred(ColCount) then
begin
Row := FixedRows;
Col := Succ(Col);
end;
with GridServers do
begin
if (Cells[Col,Row] <> '') then
else
StartWaiting;
end;
end;

Peter