这是代码:
procedure DisableContrlOL(const cArray : array of string; ReEnable : boolean = False);
// can be called from VKP / RAW / Generation clicks
var
AComponent: TComponent;
CompListDis, CompListEna : TStringList;
begin
CompListDis := TStringList.Create;
CompListEna := TStringList.Create;
for i := Low(cArray) to High(cArray) do begin
AComponent := FindComponent(cArray[i]);
if Assigned(AComponent) then
if (AComponent is TControl) then begin
if TControl(AComponent).Enabled then
CompListEna.Add(TControl(AComponent).Name)
else
CompListDis.Add(TControl(AComponent).Name);
ShowMessage(TControl(AComponent).Name);
if ReEnable then begin // if reenabling needed, then all whi
if not TControl(AComponent).Enabled then
TControl(AComponent).Enabled := True;
end else if (TControl(AComponent).Enabled) then
TControl(AComponent).Enabled := False;
end;
end;
end;
我觉得不需要再解释了。ShowMessage 正确显示了每个组件的名称,但在 StringLists 中没有添加任何内容。为什么?
更新:由于问题变得非常疯狂,我确实确认了答案,这对我有所帮助。
我知道我确实写的东西很不清楚,但我很有限,因为这些代码行是商业项目的一部分,是我的爱好和内心的东西。主要问题已在 6 小时前发现,但 Rob 只是想扩展整个问题 :D 不,无意冒犯,伙计,没关系。我很高兴收到如此愿意和有帮助的帖子。再次感谢。