2011-09-23 64 views

回答

3

可以使用TShape组件的画布属性来绘制数,访问此受保护的财产,你必须创建派生类T形,并发布该属性或只使用一个interposer class

type 
    TShape = class(ExtCtrls.TShape); //interposer class 

    TForm1 = class(TForm) 
    Shape1: TShape; 
    Button1: TButton; 
    procedure Button1Click(Sender: TObject); 
    private 
    public 
    end; 

var 
    Form1: TForm1; 

implementation 

{$R *.dfm} 

procedure TForm1.Button1Click(Sender: TObject); 
begin 
    Shape1.Canvas.Font.Name :='Arial';// set the font 
    Shape1.Canvas.Font.Size :=20;//set the size of the font 
    Shape1.Canvas.Font.Color:=clBlue;//set the color of the text 
    Shape1.Canvas.TextOut(10,10,'1999'); 
end; 
+0

嗨RRUK ...我没有得到TShape的Canvas属性。是那个属性可用..? – rakesh

+0

请仔细阅读答案,画布是一个受保护的属性,在示例代码中检查此行TShape = class(ExtCtrls.TShape);''。 – RRUZ

+0

我完全没有读完抱歉......感谢您的建议。 :) – rakesh

1

将它上面的的TLabel并使其背景透明(透明=真)。如果编辑文本对齐需要(阵营:= taCenter)

相关问题