Descobrir Events Programados em Um Componente
Ola para tdos,
estou com o seguinte necessidade:
preciso descobrir, em runtime, quais eventos um determinado componente tem.
Ex:
tenho um TButton e quero saber quais eventos o TButton tem, independente de estar em uso ou nao.
Alguma luz ?
[]´s
estou com o seguinte necessidade:
preciso descobrir, em runtime, quais eventos um determinado componente tem.
Ex:
tenho um TButton e quero saber quais eventos o TButton tem, independente de estar em uso ou nao.
Alguma luz ?
[]´s
Iluvatar
Curtidas 0
Respostas
Iluvatar
26/04/2007
bom...achei oq eu queria...vou colocar em baixo para quem tiver a necessidade.
coloque 2 listbox e 1 botao, coloque a rotina no botao. Ela vai retornar os eventos do TForm no listBox1 e os eventos programados no listBox2.
uses TYPINFO;
var
Count, Loop: Integer;
List: PPropList;
method : TMethod;
begin
Count := GetPropList(TypeInfo(TForm), tkMethods, nil) ;
GetMem(List, Count * SizeOf(PPropInfo)) ;
try
GetPropList(TypeInfo(TForm), tkMethods, List) ;
for Loop := 0 to Pred(Count) do
begin
Listbox1.Items.Add(List[Loop]^.Name) ;
method := GetMethodProp(Form1, List[Loop]^.Name) ;
if Assigned(method.Code) and Assigned(method.Data) then
begin
ListBox2.Items.Add(List[Loop]^.Name) ;
end;
end;
finally
FreeMem(List, Count * SizeOf(PPropInfo))
[]´s
coloque 2 listbox e 1 botao, coloque a rotina no botao. Ela vai retornar os eventos do TForm no listBox1 e os eventos programados no listBox2.
uses TYPINFO;
var
Count, Loop: Integer;
List: PPropList;
method : TMethod;
begin
Count := GetPropList(TypeInfo(TForm), tkMethods, nil) ;
GetMem(List, Count * SizeOf(PPropInfo)) ;
try
GetPropList(TypeInfo(TForm), tkMethods, List) ;
for Loop := 0 to Pred(Count) do
begin
Listbox1.Items.Add(List[Loop]^.Name) ;
method := GetMethodProp(Form1, List[Loop]^.Name) ;
if Assigned(method.Code) and Assigned(method.Data) then
begin
ListBox2.Items.Add(List[Loop]^.Name) ;
end;
end;
finally
FreeMem(List, Count * SizeOf(PPropInfo))
[]´s
GOSTEI 0