Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#4

AW: Typ einer Objektinstanz prüfen

  Alt 20. Apr 2011, 09:00
Also entweder mit "is", wobei "is" auch "true" bei der Überprüfung auf Elternklassen liefert:

Delphi-Quellcode:
if Button is TButton then // true

if Button is TWinControl then //true

if Button is TObject then // true

if Button is TListbox then // false
oder per ClassType:

Delphi-Quellcode:
if Button.ClassType = TButton then // true

if Button.ClassType = TWinControl then // false

if Button.ClassType = TObject then // false

if Button.ClassType = TListbox then // false
Oder wenns unbedingt sein muss auch über den Classname. Ist aber meiner Meinung nach die hässlichste Methode!
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat