Главная страницаОбратная связьКарта сайта

Как установить значение свойства компонента по имени

Автор: Jeff Overcash
WEB-сайт: http://www.lmc-mediaagentur.de

You can use RTTI to do this. Here is how to change a particular component:

procedure TForm1.BtnClick(Sender: TObject);
var
  p: PPropInfo;
  f: TFont;
begin
  f := TFont.Create;
  {Setup the font properties}
  f.Name := "Arial";
  p := GetPropInfo(Sender.ClassInfo, "Font");
  if Assigned(p) then
    SetOrdProp(Sender, p, Integer(f));
  f.Free;
end;

To get at all the forms loop through the Screen global variable. For each form loop through its Components list calling the above procedure (or something close). If you only create your components at design time that is it. If you create some at runtime and the owner is not the form, then for each component loop through its Components list recursively to get at all the owned components.


Обсудить статью на форуме


Если Вас заинтересовала или понравилась информация по разработке на Delph - "Как установить значение свойства компонента по имени", Вы можете поставить закладку в социальной сети или в своём блоге на данную страницу:

Так же Вы можете задать вопрос по работе этого модуля или примера через форму обратной связи, в сообщение обязательно указывайте название или ссылку на статью!
   


Copyright © 2008 - 2024 Дискета.info