Autor Beitrag
schuetzejanett
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: So 26.11.06 09:04 
Hallo,

ich soll für die Schule ein Primzahlenprogramm schreiben was je nachdem welche Zahl ich in ein editfeld eingebe überprüft ob es eine primzahl ist und auf dem button dann ausgibt ist eine Primzahl oder ist keine primzahl. dabei soll die textfarbe des buttons bei einer Primzahl blau sein und bei keiner rot sein.

Das überprüfen ob primzahl oder nicht und die änderung der caption des buttons funktionieren nur die änderung der textfarbe des buttons klappt nicht. ich weiß aber nicht warum dann sobald ich etwas was anderes von font ändere zb. die größe klappts.
Was mache ich falsch?

Hier mein Quellcode für das Button click ereignis

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:
procedure TPrakt8Form.butOKClick(Sender: TObject);
var zahl , code : integer;
    erg : boolean;
begin
 val (EZahl.Text, zahl, code);
 if code <> 0 then
   begin
    ShowMessage('Bitte nur Ganzzahlen eingeben!');
    EZahl.setFocus;
    exit;
   end
 else
  begin
      zahl := abs(zahl);
      erg := prim(zahl);
  end;
  if erg = true then
    begin
      butOK.Caption := 'ist eine Primzahl';
      butOK.Font.Color := clBlue
    end
  else
    begin
      butOK.Caption := 'ist keine Primzahl';
      butOK.Font.Color := clRed;
    end;
end;


Und nun noch eine andere frage wenn ich die zahl in dem textfeld editiere soll die buttontextfarbe wieder schwarz werden . Nun meine frage bei welches ereignis tritt beim editieren ein ? On change oder ist es schon bei on enter?

Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: So 26.11.06 09:42 
Die Font Farbe verändern bei Button geht nicht, nimm als Alternative den BitBtn der kanns.
OnChange

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
schuetzejanett Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: So 26.11.06 09:52 
Danke jetzt funktionierts