我是刚刚接触delphi的,我以前是做pb的,在pb中有这么几个控件一是standard visual(创建标准可视化控件)一个是:custom visual(创建自定义控件)。创建好了这些控件后我的工程中就有了这个组建,我只要
加到工程文件中去就可以和合作伙伴共同享用了。这个组建可以让让我的工程中其他用到该组建的都是一样的风格,我只要改改该组建,其他的就都改变了。比喻说,我现在在工程里创建了一个名为:lb_button的组建。
我的工程中所有的窗体都用到了他,现在我想改变一下其风格,我只要改变lb_button组建就可以了。这样就能保证风格一致性,也就是我们所说的继承嘛!我不知道delphi中也是否有这样类似的东东!还请大家多多
指教!!!!!!

解决方案 »

  1.   

    其实delphi里的frame有类似的功能,不过没你要求的那样在工程里继承
    关注此帖
      

  2.   

    你可以从当前VCL的类型来继承然后自己构造一个,放在工程的某个Unit里面就可以了,举个例子给你:
    {这个是我前几天做监控,用来模拟网管接入点的}
    TAP = Class(TSpeedButton)   //网管接入点
            private
                    FState:boolean;
                    FDeviceIP:string;
                    FDeviceAddr:string;
                    FMoveable:Boolean;
                    FDeviceStyle:byte;
                    function GetCenterX:integer;
                    function GetCenterY:integer;
            protected        public
                    constructor Create(AOwner: TComponent); override;
                    destructor Destroy; override;
                    property CenterX:integer read GetCenterX;
                    property CenterY:integer read GetCenterY;
                    property State:boolean read FState write FState default true;
                    property DeviceIP:string read FDeviceIP write FDeviceIP;        //网管接入点IP地址
                    property DeviceAddr:string read FDeviceAddr write FDeviceAddr;  //网管接入点物理位置
                    property DeviceStyle:byte read FDeviceStyle write FDeviceStyle; //设备类型
                    property Moveable:Boolean read FMoveable write FMoveable default False;//是否可以移动
                    function AlarmCheck(DeviceIP:string):string;                   //查询告警信息:命令编号10
                    procedure APCheck(DeviceIP:string);                            //网管接入点参数查询
                    procedure APSet(APSytle:byte;APsign,APname,APIP,CenterIP,gateIP,maskIP,Mac,GAPsign:string;set1:byte);                                      //网管接入点参数设置
            end;
    --------------------------------------------------
    工程中都使用新写的这个,想要修改的时候,就修改UnitAP.pas(我放在这里的)这个文件的内容,重新编译就可以了,不知道这是不是你要的东西...