Findcomponent in script
Hi,
I want to access some components of my form via the script. I want to use the findcomponent option, but it complains findcomponent is unknown. So I add my own myFindComponentfunction, but I fail to convert it in then callMethod function
function CallMethod(Instance: TObject; ClassType: TClass; const
MethodName: string; var Params: Variant): Variant;
if uppercase(MethodName) = uppercase('MyFindComponent') then
begin
if MyFindComponent(Params[0])<>nil then
result :=(MyFindComponent(Params[0]));
exit;
end;
end;
Delphi complains cannot convert variant to Tcomponent.
Is there another possibility ?
I want to access some components of my form via the script. I want to use the findcomponent option, but it complains findcomponent is unknown. So I add my own myFindComponentfunction, but I fail to convert it in then callMethod function
function CallMethod(Instance: TObject; ClassType: TClass; const
MethodName: string; var Params: Variant): Variant;
if uppercase(MethodName) = uppercase('MyFindComponent') then
begin
if MyFindComponent(Params[0])<>nil then
result :=(MyFindComponent(Params[0]));
exit;
end;
end;
Delphi complains cannot convert variant to Tcomponent.
Is there another possibility ?
Comments
You can cast it to Integer
result :=integer(MyFindComponent(Params[0]));
It work