如果不让父类的属性出现在属性编辑器中? TLine = class(TGraphicControl)父类中有height、width等属性,我不想让这些属性显示在我新组件的属性编辑器中,怎么实现?因为我已经通过其他属性控制了height和width属性,就不想让这些出现在编辑器中。谢谢先! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 TGraphicControl公开Left,Width等属性是因为IDE需要这些属性以使得你的组件可以放到From上用鼠标托托拉拉。如果你不打算把你的组件以可视化的方式工作那么就从TComponent派生吧。 如果从TComponent继承,那很多代码都要自己去写,那岂不累死。因为只读属性是不会出现在属性编辑器中的,所以你把height、width属性重设为只读,以TButton为例:unit MyButton;interfaceuses Classes, Controls, StdCtrls;type TMyButton = class(TButton) private function GetHeight: Integer; public procedure SetHeight(const Value: Integer); published property Height: Integer read GetHeight; end; procedure Register;implementationprocedure Register;begin RegisterComponents('test', [TMyButton]);end;function TMyButton.GetHeight: Integer;begin Result := TButton(Self).Height;end;procedure TMyButton.SetHeight(const Value: Integer);begin TButton(Self).Height := Value;end;end. 这样TMyButton控件的Height属性就不会出现在属性编辑器中了,但是如果因为Height是只读属性,所以你必须用Public的方法SetHeight来设置Height属性。 to dctony() ,按照你的方法,当我把控件放到窗体上时候,就出现stack overlow的提示,还让我关闭工程,重新启动delphi Sql經典問題,高手們給指點指點 灾难性故障 怎样传递控件?通过TWinControl吗? 求救,怎么知道进程用了多少CPU??? delphi中如何取消窗口最大化 可是AVI文件怎么做,大家知道吗?请教了,谢谢 还有什么大的技术论坛?我实在受不了CSDN了。 关于sendmessage,如何得到对方程序窗口内容?up有分。谢谢 可否在打印时,自动进行分类汇总? 用Delphi开发网站的问题。。。。。。 帮忙!!dbgrid显示网格的问题!!急急急!! 就这么一句都没法执行,一旦执行,cpu就占到99%左右,然后就是等待,没结果,咋弄?
因为只读属性是不会出现在属性编辑器中的,所以你把height、width属性重设为只读,以TButton为例:
unit MyButton;interfaceuses
Classes, Controls, StdCtrls;type
TMyButton = class(TButton)
private
function GetHeight: Integer;
public
procedure SetHeight(const Value: Integer);
published
property Height: Integer read GetHeight;
end; procedure Register;implementationprocedure Register;
begin
RegisterComponents('test', [TMyButton]);
end;function TMyButton.GetHeight: Integer;
begin
Result := TButton(Self).Height;
end;procedure TMyButton.SetHeight(const Value: Integer);
begin
TButton(Self).Height := Value;
end;end.