![]() |
![]() ![]() ![]() ![]() |
|
Как сделать текстовый список всех доступных свойств перечисляемого типаDelphi , Компоненты и Классы , RTTI
Автор: Sen I need to get a list of strings (like a StringList) with the possible values for a TBrushStyle property (bsSolid, bsClear, bsHorizontal, for example). I want to build a ComboBox with this options. How can I set the property Items of my ComboBox directly with all the values from the enumerated type TBrushStyle? My ComboBox will be alike the Property Editor for this type. You can use runtime type information (RTTI) to do that. Below is an example:
uses
{...}, TypInfo
procedure BrushStylesAsStrings(AList: TStrings);
var
a: integer;
pInfo: PTypeInfo;
pEnum: PTypeData;
begin
AList.Clear;
pInfo := PTypeInfo(TypeInfo(TBrushStyle));
pEnum := GetTypeData(pInfo);
with pEnum^ do
begin
for a := MinValue to MaxValue do
AList.Add(GetEnumName(pInfo, a));
end;
end;
Метод получения списка доступных свойств перечисляемого типа TBrushStyle для создания комбо-бокса с возможными значениями, использует runtime type information (RTTI) и реализуется в процедуре BrushStylesAsStrings. Комментарии и вопросыПолучайте свежие новости и обновления по Object Pascal, Delphi и Lazarus прямо в свой смартфон. Подпишитесь на наш
|
||||
©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007 | ||||