怎么判断Tshape当前形状
如何判断Tshape当前形状
界面有很多tshape
我想判断当前控件tshape的style是不是stRoundRect 值
用if (FControl as Tshape).Shape=stRoundRect then
编译没有问题,执行时就报错exception class EInvalidCast with message 'Invalid class typecast'.
------解决方案--------------------
是不是代码写的不对?
下面的代码可以正确执行的啊
procedure TForm1.Button1Click(Sender: TObject);
var
mm: TObject;
nn: TShape;
begin
nn := TShape.Create(Application);
nn.Shape := stRoundRect;
nn.Parent := Form1;
nn.Show;
mm := TObject(nn);
if TShape(mm).Shape=stRoundRect then
showmessage('aa');
end;
界面有很多tshape
我想判断当前控件tshape的style是不是stRoundRect 值
用if (FControl as Tshape).Shape=stRoundRect then
编译没有问题,执行时就报错exception class EInvalidCast with message 'Invalid class typecast'.
------解决方案--------------------
是不是代码写的不对?
下面的代码可以正确执行的啊
procedure TForm1.Button1Click(Sender: TObject);
var
mm: TObject;
nn: TShape;
begin
nn := TShape.Create(Application);
nn.Shape := stRoundRect;
nn.Parent := Form1;
nn.Show;
mm := TObject(nn);
if TShape(mm).Shape=stRoundRect then
showmessage('aa');
end;