Autor Beitrag
marvin190
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 55

Win XP, SuSe Linux 10.1
Delphi 3/5/2005 Personal; C++ Builder 6
BeitragVerfasst: Do 22.06.06 21:03 
Hallo zusammen!

Gibt es eine Möglichkeit unter Delphi bei Zugriff oder Änderung einer Variabele irgendein Procedure auszuführen oder eine Function?

Ähnlich des OnChange Ereignisses bei Edit-Feldern?

Danke schonmal!

_________________
Mfg Marvin
Carpe Diem! - Genieße den Tag! - [gr. Horaz]
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: Do 22.06.06 21:14 
2 Möglichkeiten:

1. Die Variable in einem Object (Klasse) kapseln und per Property abfragen\setzen. Dann wird beim Schreiben immer der Setter ausgeführt.

2. Mit einem Guard Page Exception Handler das Daten-Segment der Variable markieren und bei einer Guard Page Exception die gewünschte Routine aufrufen (wenn der Zugriff wirklich auf die Variable ging).

Die erste Lösung ist zu empfehlen, die zweite ist mit Kanonen auf Spatzen geschossen, funktioniert aber auch :P

_________________
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.
fidionael
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 232

Win XP SP2, Ubuntu 6.06
Delphi 7 PE, Delphi 3 Prof
BeitragVerfasst: Do 22.06.06 21:15 
Nun ja, du könntest den Zugriff auf die Variable über eine Property kapseln:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
type
  TBeispiel = class(TObject)
  private
    BspVar: Integer;
  protected
    procedure SetBspVar(Value: Integer);
  public
    property Variable: Integer read BspVar write SetBspVar;
  end;

Hoffe das hilft dir. Mfg

Edit1: Mist, zu langsam ;)