Delphi subclass visual component and use it

后端 未结 3 559
情深已故
情深已故 2020-12-03 16:05

I would like to subclass TToolBar with another class called MyTToolBar so that I can override a method. I\'m new to Delphi, but after two hours of trying various methods, I

3条回答
  •  爱一瞬间的悲伤
    2020-12-03 16:13

    Create a unit for you class:

    Unit YourComponent;
    interface
    uses
     ....
    Type
     TYourNewClass=Class(ExistingClass)
       private
       ...
       protected
       ...   
       public
       ...
       published
      end;
    
      procedure Register;
    
    implementation
    
    .....
    
    procedure Register;
    begin
      RegisterComponents('YourPalette', [TYourNewClass]);
    end;
    

    create a new package (or open an own existing) and add you unit choose install on you Package.bpl.

提交回复
热议问题