Delphi Faq
базы даных
графика и игры
интернет и сеть
компоненты и классы
мультимедиа
ос и железо
программа и интерфейс
рабочий стол
синтаксис
технологии
файловая система
 
 



на главную
Как установить значение строкового или целого поля если оно присутствует
I am building a routine that checks our forms for validity before deploying them. I would like to use some kind of structure that tests if a component type has access to a certain property, something like: " if (self.Controls[b] has Tag) then ...". Can anyone offer suggestions?

Here's an example of setting a string property for a component if it exists and another for an integer property:

procedure SetStringPropertyIfExists(AComp: TComponent; APropName: string;
AValue: string);
var
PropInfo: PPropInfo;
TK: TTypeKind;
begin
PropInfo := GetPropInfo(AComp.ClassInfo, APropName);
if PropInfo <> nil then
begin
TK := PropInfo^.PropType^.Kind;
if (TK = tkString) or (TK = tkLString) or (TK = tkWString) then
SetStrProp(AComp, PropInfo, AValue);
end;
end;

procedure SetIntegerPropertyIfExists(AComp: TComponent; APropName: string;
AValue: Integer);
var
PropInfo: PPropInfo;
begin
PropInfo := GetPropInfo(AComp.ClassInfo, APropName);
if PropInfo <> nil then
begin
if PropInfo^.PropType^.Kind = tkInteger then
SetOrdProp(AComp, PropInfo, AValue);
end;
end;

Магазин Conquest предлагает к продаже швейцарские часы Oris
пиротехника форум пиротехника петарды