class PACKAGE TProgressBarLabel : public TProgressBar
{
private:
TLabel *FLabel;
int FRatio;
void __fastcall SetTextFont(TFont *v);
protected:
void __fastcall PaintWindow(HDC DC);//重载TWinControl的PaintWindow事件,
public:
__fastcall TProgressBarLabel(TComponent* Owner);
__fastcall ~TProgressBarLabel();
void __fastcall SetStep(int v);
__published:
__property TLabel *Text={read=FLabel,write=FLabel};
};
上面这样一个控件,在设计窗体时,Text的属性能设,
但是运行时仍回初始的状态,为什么?
我的构造函数如下,是不是下面有问题,但我看别的控件也和我一样先在构造函数里生成所有要的对象啊?
__fastcall TProgressBarLabel::TProgressBarLabel(TComponent* Owner)
: TProgressBar(Owner)
{
FLabel=new TLabel(this);
FLabel->Parent =this;
FLabel->Caption="0%";
FRatio=0;
}