![]() |
Button.Caption "einfrieren"?
Hallo liebes Forum,
Gibt es in Delphi einen Befehl, mit dem man die Caption eines Buttons "einfrieren", also dass die Caption "unantastbar" und unter gar keinen Umständen zu ändern ist? LG Robin |
AW: Button.Caption "einfrieren"?
Hallo und willkommen in der DP :dp:
Als erstes leider ein Mini Anpfiff. Crossposts bitte in Zukunft gegenseitig verlinken damit Antworten nicht doppelt gegeben werden bzw. ein Forum die Lösung schon hat im anderen noch darüber geschwitzt wird. 8-) Crosspost: ![]() Zum Thema: Kannst du dein Anliegen etwas genauer definieren ? Wenn du in deinem Programm die Caption nicht änderst bleibt sie auch so. Oder meinst du von Extern ? Wer sollte so etwas versuchen ? |
AW: Button.Caption "einfrieren"?
Zitat:
Aber was hält dich davon ab dieses selbst auf den Button zu zeichnen? ![]() gruss |
AW: Button.Caption "einfrieren"?
Edit: Ich möchte, dass sobald ein Button die richtige Caption (also die richtige Zahl [1-9]) hat, die Caption nicht mehr von den anderen Buttons geändert werden kann.
Ich gebe euch mal meinen Quellcode... ^^
Delphi-Quellcode:
LG Robin
unit Unit2;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Button5: TButton; Button6: TButton; Button7: TButton; Button8: TButton; Button9: TButton; Timer1: TTimer; Label1: TLabel; Label2: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Button9Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin RANDOMIZE; Button1.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); end; procedure TForm1.Button2Click(Sender: TObject); begin RANDOMIZE; Button2.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); end; procedure TForm1.Button3Click(Sender: TObject); begin RANDOMIZE; Button3.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); end; procedure TForm1.Button4Click(Sender: TObject); begin RANDOMIZE; Button4.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); end; procedure TForm1.Button5Click(Sender: TObject); begin RANDOMIZE; Button5.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); end; procedure TForm1.Button6Click(Sender: TObject); begin RANDOMIZE; Button6.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); end; procedure TForm1.Button7Click(Sender: TObject); begin RANDOMIZE; Button7.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); end; procedure TForm1.Button8Click(Sender: TObject); begin RANDOMIZE; Button8.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); end; procedure TForm1.Button9Click(Sender: TObject); begin RANDOMIZE; Button9.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); end; procedure TForm1.Timer1Timer(Sender: TObject); begin if Button1.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button1.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button2.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button3.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button4.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button5.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button6.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); if Button7.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button8.Caption=Button9.Caption then Button9.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button1.Caption then Button1.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button2.Caption then Button2.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button3.Caption then Button3.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button4.Caption then Button4.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button5.Caption then Button5.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button6.Caption then Button6.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button7.Caption then Button7.Caption:=IntToStr(Random(9)+1); if Button9.Caption=Button8.Caption then Button8.Caption:=IntToStr(Random(9)+1); end; end. |
AW: Button.Caption "einfrieren"?
Dann hab ich da wohl was falsch verstanden..
BOahhh so viele, jedemenge Button. ;) gruss |
AW: Button.Caption "einfrieren"?
Ähmmm... ok. :roll:
Versuche mal zu beschreiben (Stichpunkte) wie dein Programm arbeiten soll. Bevor das nicht klar ist, können wir schlecht helfen. |
AW: Button.Caption "einfrieren"?
Japp, sehe ich auch so. Dann kann man auch gleich Logik und Darstellung trennen, denn Buttons sind ja nicht dazu da, irgendwelche Daten vorzuhalten, sondern um ein Ereignis auszulösen. Und wenn man doch unbedingt Daten darin verwalten will/muss, eignet sich die Tag-Eigenschaft wohl eher dazu, zumal sie auch noch zufällig nummerisch ist.
|
AW: Button.Caption "einfrieren"?
Zitat:
|
AW: Button.Caption "einfrieren"?
Zitat:
Wobei wenn eine zahl zwischen 1 und 9 auftritt diese nicht mehr geändert werden soll. Nur geraten. gruss |
AW: Button.Caption "einfrieren"?
Zitat:
Delphi-Quellcode:
wohl an Zahlen herauskommen...
Random(9)+1
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:31 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz