在DLL库中封装的函数
function PA(Parent: Twincontrol);
var
i: integer;
lbl: TLabel;
begin
Result := False;
for i := 0 to Parent.ControlCount - 1 do
begin
if Parent.Controls[i].Name = 'lblName' then
begin
if TObject(Parent.Controls[i]) is TLabel then // A
begin
lbl := TLabel (Parent.Controls [i]);
Result := True;
end;
.....
....
....
Break;
end;
end;
end; 执行到A处,无论条件是否符合,程序都会跳出不再执行
但把同样的函数写在一个普通单元文件里能正确执行
为什么在DLL里不行呢?
function PA(Parent: Twincontrol);
var
i: integer;
lbl: TLabel;
begin
Result := False;
for i := 0 to Parent.ControlCount - 1 do
begin
if Parent.Controls[i].Name = 'lblName' then
begin
if TObject(Parent.Controls[i]) is TLabel then // A
begin
lbl := TLabel (Parent.Controls [i]);
Result := True;
end;
.....
....
....
Break;
end;
end;
end; 执行到A处,无论条件是否符合,程序都会跳出不再执行
但把同样的函数写在一个普通单元文件里能正确执行
为什么在DLL里不行呢?
if Controls[1].ClassType=TLabel then
if Parent.Controls[i].ClassType=TLabel then 行不