Autor Beitrag
cscp
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: Fr 31.12.04 18:08 
Also folgendes: Ich hab ein Form auf dem mehrere Edits sind. Dann ist da noch ein Panel... So jetzt will ich denn man ein Edit entert... also beim onEnter im Panel eine Beschreibung für das Edit einblenden lassen... also in der onEnter Prozedur steht dann panel.caption='blablabla'... so das funktioniert auch wenn ich es bei jedem Edit einzeln mache...
meine FRAGE:
kann ich auch eine allgemeine Prozedur schreiben die praktisch auf jedes onEnter hört... die dann z.b. so aussieht

if source=edit1 then description='bla1';
if source=edit2 then description='bla2';

usw...
hoffe ihr habt mich verstanden!
danke für eure hilfe!
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: Fr 31.12.04 18:13 
wenn du deine Edits durchnummeriert hast, dann könnte dir das Stichwort FindComponent weiterhelfen.

_________________
We are, we were and will not be.
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Fr 31.12.04 18:19 
Du kannst eine OnEnter Methode für alle TEdit's schreiben.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    procedure OnEditEnter(Sender: TObject);  // manuell hinzufügen
  private
  ...
  public
  ...
  end;

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.OnEditEnter(Sender: TObject);
begin

  if Sender = Edit1 then
    ShowMessage('ABC');

end;


Und im Objekt-Inspektor fügst du bei den Edit's das OnEnter Ereignis hinzu.

_________________
Ciao, Sprint.
cscp Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: Fr 31.12.04 18:26 
suuuper vielen vielen Dank für eure schnelle Hilfe!!! DANKE! :D
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Sa 01.01.05 01:31 
Sprint hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
if Sender = Edit1 then
    ShowMessage('ABC');



Dann aber besser direkt Typ-abhängig :

ausblenden Delphi-Quelltext
1:
if Sender is TEdit then					

_________________
Gruß
Hansa
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: Sa 01.01.05 01:47 
Vielleicht hilft Dir auch Application.OnActiveControlChanged weiter.

_________________
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.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 01.01.05 08:51 
FindComponent ist doch immer noch das beste, einfach in ne Schleife packen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
for X := 1 to 10 do  // Wenn du 10 Edits hast.
begin
  if Source = TEdit(FindComponent('Edit' + IntToStr(X))) then
    Description := 'Bla' + IntToStr(X);
end;

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Sa 01.01.05 15:26 
hansa hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
if Sender is TEdit then					

Sender ist in diesem Fall immer TEdit. Von daher kann man sich die Abfrage mit "is" sparen.

_________________
Ciao, Sprint.
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: Sa 01.01.05 16:30 
hmmmmmm...feiner befehl das findcomponent ... erspart mir künftig sicher einige zeilen pointercode :mrgreen: