![]() |
|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
|||
|
|||
![]() Приветствую!
Что-то не возьму в толк, как сделать "красиво": Есть два типа объектов с одинаковыми свойствами, объекты заносятся в TObjectList. Вопрос - как мне сделать приведение типов, не дублируя код со свойствами и не используя явное приведение? Вот пример: Код:
procedure TSettForm.SetProperty (Prop, Str: string); var bufbtnlist: TObjectList; begin if (bufbtnlist.Items[iindex-1] as TObject).ClassName = 'TBtnProp' then with (bufbtnlist.Items[iindex-1] as TBtnProp) do begin if Prop = 'Hint' then Hint:= Str; if Prop = 'LeftURL' then LeftURL:= Str; if Prop = 'RightURL' then RightURL:= Str; if Prop = 'LeftHotKeys' then LeftHotKeys:= Str; if Prop = 'RightHotKeys' then RightHotKeys:= Str; end; if (bufbtnlist.Items[iindex-1] as TObject).ClassName = 'TMySpeedBtn' then with (bufbtnlist.Items[iindex-1] as TMySpeedBtn) do begin if Prop = 'Hint' then Hint:= Str; if Prop = 'LeftURL' then LeftURL:= Str; if Prop = 'RightURL' then RightURL:= Str; if Prop = 'LeftHotKeys' then LeftHotKeys:= Str; if Prop = 'RightHotKeys' then RightHotKeys:= Str; end; end; Последний раз редактировалось Admin, 21.12.2010 в 13:02. |