Главная страница
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.018 c
3-53403
MV
2004-01-26 15:44
2004.02.17
По повоу Set term ... в IBExpert. Надо или нет?


14-53737
}|{yk
2004-01-28 14:36
2004.02.17
Дайджесты на CD


1-53626
edicon
2004-02-06 22:57
2004.02.17
Скопировать директорию...


1-53520
olookin
2004-02-05 13:44
2004.02.17
Представление числа в двоичном виде


11-53441
Mikel
2003-06-03 12:38
2004.02.17
TreeView