Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.02.17;
Скачать: CL | DM;

Вниз

Получение доступа к свойствам формы по её имени   Найти похожие ветки 

 
Goblinus   (2004-02-05 21:20) [0]

Доброго всем времени суток!

Подскажите, пожалуйста, как можно получить доступ к свойствам формы, зная её имя (в рантайм. ессно). Т.е. нужно что то типа FindComponent, работающее с формами.

С уважением,
Goblinus.


 
Sam Stone ©   (2004-02-05 21:25) [1]

Если не ошибаюсь, то так:
ТипФормы(FindComponent("имя формы")).свойство


 
Юрий Зотов ©   (2004-02-05 21:29) [2]

> Sam Stone © (05.02.04 21:25) [1]
Увы, ошибаетесь. Советую посмотреть, что такое Owner.

> Goblinus (05.02.04 21:20)
Если ссылка на форму есть, то и искать ничего не надо - прямо через эту ссылку и действуйте. А если ссылки нет, то посмотрите TScreen.Forms.


 
Юрий Федоров ©   (2004-02-05 21:30) [3]

смотри unit TypInfo;
названия функций достаточно "говорящие", разберешься, надеюсь :-)


 
Юрий Федоров ©   (2004-02-05 21:33) [4]

Вот пример (по моему из RX)
type
TPropertyList = class
private
FList: PPropList;
FCount: Integer;
FSize: Integer;
function Get(Index: Integer): PPropInfo;
public
constructor Create(AObject: TObject);
destructor Destroy; override;
function Find(const AName: string): PPropInfo;
procedure Delete(Index: Integer);
property Count: Integer read FCount;
property Items[Index: Integer]: PPropInfo read Get; default;
end;

//==============================================================================

implementation

constructor TPropertyList.Create(AObject: TObject);
begin
FCount := 0;
FList := nil;
if AObject = nil then Exit;
if AObject.ClassInfo <> nil then
begin
FCount := GetPropList(AObject.ClassInfo, tkProperties, nil);
FSize := FCount * SizeOf(Pointer);
GetMem(FList, FSize);
GetPropList(AObject.ClassInfo, tkProperties, FList);
end
end;
//------------------------------------------------------------------------------
destructor TPropertyList.Destroy;
begin
if FList <> nil then FreeMem(FList, FSize);
end;

function TPropertyList.Find(const AName: string): PPropInfo;
var
I: Integer;
begin
for I := 0 to FCount - 1 do
with FList^[I]^ do
if SameText(Name, AName) then
begin
Result := FList^[I];
Exit;
end;
Result := nil;
end;

procedure TPropertyList.Delete(Index: Integer);
begin
Dec(FCount);
if Index < FCount then Move(FList^[Index + 1], FList^[Index],
(FCount - Index) * SizeOf(Pointer));
end;

function TPropertyList.Get(Index: Integer): PPropInfo;
begin
Result := FList^[Index];
end;


 
Юрий Федоров ©   (2004-02-05 21:36) [5]

Тьфу, я, похоже, неправильно понял вопрос :-(


 
Gero ©   (2004-02-05 22:32) [6]

Цикл по Screen.Forms


 
Goblinus   (2004-02-05 23:15) [7]

Всем спасибо, проблема решена.



Страницы: 1 вся ветка

Текущий архив: 2004.02.17;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.017 c
1-53641
h0use
2004-02-06 15:46
2004.02.17
Как в компоненет создавать about?


1-53450
lokid7
2004-02-06 17:11
2004.02.17
Взаимодействие между двумя классами


1-53570
Del2
2004-02-09 06:30
2004.02.17
выделение ячеек в Grid компонентах


1-53605
Grinder
2004-02-06 19:52
2004.02.17
Создание класса


1-53512
JediMaster
2004-02-05 17:02
2004.02.17
Поиск слова