VaR
T: tbitbtn;
Begin
T: = tbitbtn. Create (NiL );
T. Name: = 'bitbtn100 ';
T. Parent: = self; // breakpoint
End;
When one trace is performed, the following function is degraded (the sub-class overwrites the function ):
Tbitbtn. createhandle;
Tbutton. createwnd;
Tbitbtn. createparams
However, the subclass will not discard the features provided by the parent class. All of them add a small part of features to the results before or after the execution of the parent class function to form a Sandwich Style.
Let's take a look at what tbitbtn has added:
Procedure tbitbtn. createhandle;
VaR
State: tbuttonstate;
Begin
If enabled then // The status of the Add button
State: = bsup
Else
State: = bsdisabled;
Inherited createhandle;
Tbuttonglyph (fglyph). createbuttonglyph (State); // Add a button Image
End;
Procedure tbutton. createwnd;
Begin
Inherited createwnd;
Factive: = fdefault; // added to determine whether the instance is active
End;
Procedure tbitbtn. createparams (VAR Params: tcreateparams );
Begin
Inherited createparams (Params );
With Params do style: = style or bs_ownerdraw; // adds the self-painting status.
End;
The feature of a virtual function is that it will be dropped to the subclass to execute the function with the same name.