Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Typ wie TFontStyles selber erstellen (https://www.delphipraxis.net/143530-typ-wie-tfontstyles-selber-erstellen.html)

Basti1991 17. Nov 2009 20:56


Typ wie TFontStyles selber erstellen
 
Hallo Zusammen!

Ich such einen Weg, wie ich soetwas wie TFontStyles selber machen kann.
Das heisst, ich will konkret folgendes können:

Code:
...
var MyType: TMyType;
begin
  MyType := [subtyp1, subtyp2, ...];
end;
Habe mir schon mal gedacht, dass die "subtypes" bestimmt soetwas wie Enumeratoren sind, also etwas in der art definiertes:

Code:
type TAnyType = (subtyp1, subtyp2, subtyp2);
Konkret würde das bedeuten, dass ich etwas in der Art wie TFontStyles selber erstellen wil (ich nutz das für Attribute eines Selbstdefinierten Objekts, das hat nicts mit Fonts zu tun! Ich würde es nur gerne genauso bedienen)

Damit meine ich, dass man ja TFontStyles so handhabt:

Code:
AFontStyles := [fsBold, fsItalic];
das fsBold, etc. sollte bei mir der TAnyType Enumerator ja schon sein, aber wie bekomme ich das jetzt so hin, dass ich die aneinander Reihen kann wie bei FontStyles?

Vielen Dank und Grüße,
Sebastian

Basti1991 17. Nov 2009 20:58

Re: Typ wie TFontStyles selber erstellen
 
Ach so ein mist^^ jezz hab ich das einfach mal stupide probiert und eine Variable vom Typ TAnytype erstellt und einfach mal

Delphi-Quellcode:
myvar := [subtyp1, subtyp2];
gemacht. Kam nen fehler, de rmich darauf brachte, das ein solcher Datentyp so erstellt wird:

Delphi-Quellcode:
Tneuertyp = SET of TAnyType
dann klappt die Nummer^^ Sorry also, vllt hilft das hier nochmal jemandem anderst ;)

Zacherl 17. Nov 2009 21:01

Re: Typ wie TFontStyles selber erstellen
 
Das geht folgendermaßen:

Delphi-Quellcode:
type
  TValues = (val1, val2, val3);
  TValueSet: set of TValues;


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:03 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz