IWML Enums

IWML Enums

IWML properties can have enums. Delphi can put enums into namespaces, but namespace support is not available in DFM files.

Enum values are stored as global enum identifiers, not only within the context of the enum type that the values belong to. This causes frequent name conflicts.

As shown, there is an error when trying to reuse enum value names between two different enums. The exact error is:

E2004 Identifier redeclared: 'One'


Enums with namespaces were introduced several years ago to resolve this problem. DFM files and the IDE do not support namespaces and so namespaced enums can only be used in code and not for any properties that interact with the designer.

Prefix Fix

Because of conflicts, enums used in the designer use the old convention of using prefixes. For example, alLeft, alRight, etc for alignment.

Prefixing reduces the chance of conflict but especially with generated code cannot fully prevent clashes. If IntraWeb generated prefixes they would likely need to be very large and would overshadow the enum name itself. For example, selecting iw17StackOrientationHoriz or iw17StackOrientationVertical is cumbersome.

Enums as Strings

To work around this limitation, IntraWeb treats IWML enums as strings in Delphi.

IntraWeb classes that use IntraWeb’s string based enums do validate their values in property setters to prevent invalid values from being used.

IntraWeb also has a custom property editor to list values in the designer, just as an normal enum property editor.