property Caption: TCaption .... default 'Form1';

解决方案 »

  1.   

    有个第三方组件有一句如下:
    property Style: TXXButtonStyle read FStyle write SetStyle default bsNormal;现在我想继承它,但Style属性我要让它变为bsModern,写代码如下:
    property Style: TXXButtonStyle read FStyle write SetStyle default bsModern;中间这段“TXXButtonStyle read FStyle write SetStyle”应该如何更改?
    是否要把原组件中的代码都要抄过来?
    我觉得既然是继承而来,那应该不必大量抄代码的吧?
      

  2.   

    default 只是用在属性编辑器中
    用 在Create()中写才安全
    具体你看看标准控件是怎么写的不就ok了
    我重写vcl的时候就是直接看Delphi的Source
      

  3.   

    如下,我这样也试过,但出错:
    constructor TMyButton.Create(aOwner: TComponent);
    begin
      inherited;
      Height := 26;
      Width := 76;  style:=bsModern;
    end;
    出错信息如下:
    Undeclared identifier:'bsModern'
    应该怎么改正?
      

  4.   

    uses
      ????;  bsModern
    //~~~~~~~F1就就知道是啥单元了
      

  5.   

        bsNormal
    //  ~~~~~~~~Ctrl+鼠标左键就知道它的兄弟了
      

  6.   

    我觉得好奇怪啊!
    bsModern这个东东是在unit2中的,
    在unit1中已经use了unit2,我在自己的pas文件中已经use了unit1。
    不是说继承有连续性吗?为何又连续不了啦?另外:我现在在自己的pas文件中use unit1,unit2;
    这样可以编译通过。
    但是在应用这个自制组件时,不能加到窗体上,出错信息为“没有parent form”
    这又是什么意思啊???怪怪怪?