Autor Beitrag
Xenar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 07.08.05 13:04 
Hallo,

ich rufe aus einem Thread, in meinem Hauptthread ein Befehl auf, der in meinem Formular vom Hauptthread, eine Labelfarbe ändert.
In der Schleife, aus der ich aufrufe, befindet sich ein sleep, dass mir wohl die Tatsache verursacht, dass mein Label nicht die Farbe ändert.

Habe mal versucht folgendes in einer Prozedur, die regelmäßig gestartet wird, einzubauen: Application.ProcessMessages;

Klappt aber auch nicht.

What Can I do? :?

Ciao Xenar
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: So 07.08.05 13:08 
ohne Quellcode kann man da schlecht helfen,

Das sleep sollte nicht das Problem sein, dass dadurch die Farbe nicht mehr geändert werden kann.

Zeig mal bitte die Schleife.

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
CK_CK
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

Win 2000, Win XP Prof
Delphi 2006 Enterprise
BeitragVerfasst: So 07.08.05 13:14 
Hi!
Erstmal zumThema "Sleep":
Mach' das doch lieber so (Fenster reagiert während des Wartens noch...):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure Delay(Dauer: Integer);
var
  i: Integer;
begin
  i := GetTickCount;
  while (GetTickCount-i)<Dauer do Application.ProcessMessages;
end;

Aufrufen tust du's dann wie Sleep:
ausblenden Delphi-Quelltext
1:
Delay(2500);					

(2500 nur als Beispielwert...)

Die Labelfarbe änderst du z.B. so:
ausblenden Delphi-Quelltext
1:
2:
Label1.Color := clRed;
Label1.Font.Color := clGreen;


Wenn sich nichts ändert, check doch mal deine Prozedur nach, ob sie überhaupt bei der Farbänderung "ankommt"...

CK_CK

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt.


Zuletzt bearbeitet von CK_CK am So 07.08.05 13:15, insgesamt 1-mal bearbeitet
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 07.08.05 13:15 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
if (B[6] = Form1.Istwert[6]) and (A[6] = Form1.Sollwert[6]) then
  begin  
    Form1.Steuern;  //     <---------In der prozedur wird eine Labelfarbe geändert, passiert aber nichts
    if (Form1.Freigabe = 1and (Form1.Notaus = 0then
      begin
        Form1.Ausschalten;
        Form1.AuschaltenLabel.Font.Color:= ClRed;
        Form1.AuschaltenLabel.Caption:= 'Notabschatlung';
        sleep(500);
        Form1.IstwertAnzeige.Text:= inttostr(Form1.Istwert[6]);
      end;


Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt.
CK_CK
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

Win 2000, Win XP Prof
Delphi 2006 Enterprise
BeitragVerfasst: So 07.08.05 13:17 
Dann zeig doch mal die "Form1.Steuern" - Prozedur...

CK_CK
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: So 07.08.05 13:19 
und das was du gepostet hast befindet sich innerhalb einer schleife?

wenn ja schrieb einfach zu Form1.Steuern ein Application.ProcessMessages hinzu

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 07.08.05 13:20 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.Steuern;
  var
  Bit, Byte, Low: Integer;
  begin
    vAntrieb[1]:= 0;
    Bit:= 4;
    Byte:= 2;
    Low:= 1;
    PortsSetzen(Bit, Byte, Low);
    Bit:= 5;
    Byte:= 2;
    Low:= 1;
    PortsSetzen(Bit, Byte, Low);
    RechtsA.Color:= clRed;           //<----Label änderung die nicht geht
    LinksA.Color:= clRed;            //<---- " "
  end;


Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt.
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: So 07.08.05 13:22 
wie eben schon erwähnt schreib in der prozedut steuern, nach der labeländerung eifnach ein application.prozessmessages rein

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 07.08.05 13:25 
Habe ich rein geschrieben, passiert aber nichts!
Label bleibt grün und wird nicht rot. Hat es vielleicht damit was zu tun, dass Form1.Steuern aus einer anderen Thread-Unit aufgerufen wird?
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: So 07.08.05 13:28 
in dem quelltext seh ich keinen fehler...
sicher das auch die funktion Steuern aufgerufen wird?

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 07.08.05 13:32 
Ja wird aufgerufen, den die Prozedure "Portssetzen(Bit, Byt....)" wird ausgeführt. Hat die Prozedure vielleicht noch eine Störende Ursache?
CK_CK
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

Win 2000, Win XP Prof
Delphi 2006 Enterprise
BeitragVerfasst: So 07.08.05 13:36 
Setz' doch mal nach
ausblenden Delphi-Quelltext
1:
2:
RechtsA.Color:= clRed;           //<----Label änderung die nicht geht
LinksA.Color:= clRed;            //<---- " "

Folgendes:
ausblenden Delphi-Quelltext
1:
ShowMessage('Bin bei der Änderung angekommen!!!');					


Und guck mal, ob die Nachricht erscheint...

CK_CK

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 07.08.05 13:44 
Jo jetzt kommt das erstaunliche! Die Nachricht kommt (in einem sehr komichen Format), wenn ich auf ok klicke, ändert sich das label....

ohne shomessage wieder das selbe wie vorher es bleibt grün
Dargor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 59

Win2k SP4, WinXP Pro SP1
D6 Pers
BeitragVerfasst: So 07.08.05 13:50 
Versuch nach der Änderung der Farben mal ein RechtsA.Repaint und ein LinksA.Repaint, und danach am besten noch ein Application.ProcessMessages.
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 07.08.05 14:02 
Hi, leider auch erfolgslos.

:( :? :shock:
CK_CK
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

Win 2000, Win XP Prof
Delphi 2006 Enterprise
BeitragVerfasst: So 07.08.05 14:12 
Ist mit deinem PC sonst alles in Ordnung? :D

Aber im Ernst: Was meinst du mit komischem Format?

CK_CK

//EDIT: Schreib doch anstatt des ShowMessage mal Application.ProcessMessages; hin... (gleiche Stelle)
Oder, noch bessere Idee: Lad' das ganze Programm hoch, wenn wir's sehen dürfen... ;)
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 07.08.05 14:20 
Das Fenster war größer als der Bildschirm anzeigen konnte, vermutlich Endlos, habe das Ende nicht gefunden :D
CK_CK
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

Win 2000, Win XP Prof
Delphi 2006 Enterprise
BeitragVerfasst: So 07.08.05 14:23 
Hmmm, die Schleife...
Könntest du da aus versehen irgendetwas Rekursiv programmiert haben?
(Prozedur ruft sich selbst auf...)

Und: Wenn nach der ShowMessage alles wieder geht, dann nimm doch stattdessen irgendeinen Befehl, den keiner merkt (z.B. Form1.Caption := 'Gewünschte Caption';) Der Befehl wird dann ausgeführt, keiner merkt's und die Farbe öndert sich...

CK_CK
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 07.08.05 14:36 
So ich danke Euch für die Hilfe, ich habe alles noch mal genaustens durchforstet und habe den Fehlehr gefunden.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
if (B[6] = Form1.Istwert[6]) and (A[6] = Form1.Sollwert[6]) then  
  begin    
    Form1.Steuern;  //     <---------In der prozedur wird eine Labelfarbe geändert, passiert aber nichts  
    if (Form1.Freigabe = 1and (Form1.Notaus = 0then  
      begin  
        Form1.Ausschalten;  
        Form1.AuschaltenLabel.Font.Color:= ClRed;  
        Form1.AuschaltenLabel.Caption:= 'Notabschatlung';  
        sleep(500);  
        Form1.IstwertAnzeige.Text:= inttostr(Form1.Istwert[6]);  
      end;


Ich habe einen Thread der permanent alles einschaltet sobald ist und sollwert sich unterscheidet, mit Form1.Auschalten wird dieser mit beendet. Wenn dieser steuert macht er meine labels grün. Ich habe jetzt das Steuern nach dem Auschalten eingefügt :oops: :oops: :oops: :oops: :oops:

Sorry für die schwere geburt

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
CK_CK
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

Win 2000, Win XP Prof
Delphi 2006 Enterprise
BeitragVerfasst: So 07.08.05 14:46 
Macht doch nichts, hab' gerne mitgerätselt... ;)

CK_CK