我做了一个继承自TWinControl的ActiveX控件,在控件中声明了一个属性PicCount,同时在类声明中加入了FCOU:Integer;来接收该属性,其读写函数如下
function TWinControl.GetPicCount:Integer;
begin
    Result:=FCou;
end;procedure TWinControl.Set_PicCount(Value :Integer);
begin
    FCou:=Value;
end;
但是在应用时,直接在属性栏给属性PicCount赋值后,控件无法正确接收属性值,只有在程序中动态加入赋值如(PicCount:=3)时,控件才能正确接收,请问大侠们该如何解决?

解决方案 »

  1.   

    更正一下,我的问题中的代码是这个
    function TWinControl1X.GetPicCount:Integer;
    begin
        Result:=FCou;
    end;procedure TWinControl1X.Set_PicCount(Value :Integer);
    begin
        FCou:=Value;
    end;
      

  2.   

    TComponentState = set of (csLoading, csReading, csWriting, csDestroying,
        csDesigning, csAncestor, csUpdating, csFixups, csFreeNotification,
        csInline, csDesignInstance);
    自己找;
      

  3.   

    你試試:
    property PicCount: integer read ... write... stored true;
      

  4.   

    to aiirii(ari) 你的方法我试过了,还是不行啊
    to  ihihonline 怎么设置运行期啊,能详细点吗?谢谢
      

  5.   

    property PicCount: integer read ... write...  default 5;在构造函数中加
      FCou:=5;
      

  6.   

    to chiperliu 可是我是想让使用控件的人设置这个属性啊,如果在设计时将它的值改变,在运行时却又变回来了,真苦恼
      

  7.   

    你错了,Create是在你放这个控件的时候调的,当使用控件的人改变它的值时,会自动调用Set_PicCount改变它. 你试试就知道了
      

  8.   

    我让你重载Create只是写入它的default值,仅仅在属性的申明处default 5是不够的
      

  9.   

    to cipherliu 我知道你的意思。可是我的意思是当使用控件的人在控件的属性列表中修改这个属性值后,在运行时用shoumessage(inttostr(PicCount))显示它时,结果是初始值,比如在载Create只是写入它的default值是5,然后我在属性列表中将它改设为3 那么运行时显示的还是5,不知道我的意思是否表达清楚,你可以试一下,在d5,d7下我都试过
      

  10.   

    TComponentState = set of (csLoading, csReading, csWriting, csDestroying,
        csDesigning, csAncestor, csUpdating, csFixups, csFreeNotification,
        csInline, csDesignInstance);
    自己找;