Autor Beitrag
mTDario
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Mo 02.03.09 15:57 
hey Delphi-Programmierer
ich würde gerne die Caption eines Knopfs ändern sobald ich darauf klicke.
Also z.b.
ausblenden Delphi-Quelltext
1:
2:
if (bt_knopf.click and player.play) = true then bt_knopf.caption := 'Aus';
if (bt_knopf.click and player.pause) = true then bt_knopf.caption := 'Ein';

Problem ist das sowohl das .click als auch .play sowie .pause nicht von typ boolean sind eine Lösung wäre sehr nett.

Danke mTDario


Moderiert von user profile iconGausi: Topic aus Sonstiges (Delphi) verschoben am Mo 02.03.2009 um 16:04
Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 02.03.09 16:04 
Hallo und :welcome: in der Entwickler-Ecke,

Das sollte in etwa so gehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if {hier geht meine Glaskugel grade nicht} then 
     bt_knopf.caption := 'Aus'
  else
    bt_knopfcaption := 'Ein';
end;


Das ganze wäre dann das OnClick-Event des Buttons, evtl. mit anderen Bezeichnungen. Ich denke aber, dass du dir noch ein paar Grundlagen aneignen solltest, z.B. im Crashkurs.

_________________
We are, we were and will not be.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 02.03.09 16:06 
Hallo und :welcome: im Forum!

bt_knopf.click ist eine Prozedur. Was willst du mit der Abfrage erreichen? Der Vergleich "= true" ist auch falsch.

Delphi ist genau wie Windows ereignisbasiert. Das heißt du reagierst in dem Ereignis OnClick auf das Klicken des Knopfes. Ich nehme an du benutzt den TMediaPlayer? Dann ginge das so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.bt_knopfClick(Sender: TObject);
begin
  if player.Mode = mpPlaying then
  begin
    player.Pause;
    bt_knopf.Caption := 'An';
  end
  else
  ...