Hi
How can I find a component by its name which is on a form by its name.
ie
var frm_name='frm1'; and cmp_name=' pan1';
i have tried code below but the component is not found, the form is found though.
function FindFormByName(const AName: string): TForm;
var
i: Integer;
begin
for i := 0 to Screen.FormCount - 1 do
begin
Result := Screen.Forms[i];
if (Result.Name = AName) then
Exit;
end;
Result := nil;
end;
...
var frm:tform;
pnl:tpanel;
begin
frm:=FindFormByName('Frm1');
if frm<>nil then
begin
pnl:=frm.findcomponent('Pan1');
if pnl=nil then showmessage('Pan1 not found on Frm1')
else
begin
....
end;
end;