相关疑难解决方法(0)

使用他的ClassType转换TObject?

我怎样才能使我的代码工作?:)我试图制定这个问题,但经过几次失败的尝试后,我认为你们会更快地发现问题,而不是阅读我的"解释".谢谢.

setCtrlState([ memo1, edit1, button1], False);
Run Code Online (Sandbox Code Playgroud)

_

procedure setCtrlState(objs: array of TObject; bState: boolean = True);
var
  obj: TObject;
  ct: TClass;
begin
  for obj in objs do
  begin
    ct := obj.ClassType;


    if (ct = TMemo) or (ct = TEdit) then
      ct( obj ).ReadOnly := not bState;        // error here :(

    if ct = TButton then
      ct( obj ).Enabled:= bState;        // and here :(

  end;
end;
Run Code Online (Sandbox Code Playgroud)

delphi tobject

5
推荐指数
2
解决办法
4446
查看次数

标签 统计

delphi ×1

tobject ×1