The statement reads as follows:
Tcustompanel =class(Tcustomcontrol)PrivateFfullrepaint:boolean; Fparentbackgroundset:boolean; procedureCmctl3dchanged (varMessage:tmessage);messagecm_ctl3dchanged; protected procedureCreateParams (varParams:tcreateparams);Override; procedurePaint;Override; Property color default clbtnface;//Set default color, if not change its color, not stored in DFM PropertyFullrepaint:booleanReadFfullrepaintWriteFfullrepaintdefaultTrue; PropertyParentcolordefaultFalse; procedureSetparentbackground (Value:boolean);Override; Public PropertyParentbackgroundstoredFparentbackgroundset; Constructor Create(aowner:tcomponent);Override; functionGetcontrolsalignment:talignment;Override; End;
When you place a tpanel on a form, you have:
Object Panel1:tpanel $ 232193153' Panel1'2 End
The equivalent of this time the color default is Clbtnface. If I change its color in the design period, it will be stored as:
Object Panel1:tpanel $ 232193153' Panel1' Color = clyellow 2 End
Finally, take a look at its paint function:
procedureTcustompanel.paint;Constalignments:Array[Talignment] ofLongint =(Dt_left, Dt_right, dt_center);varRect:trect; Topcolor, Bottomcolor:tcolor; Fontheight:integer; Flags:longint; procedureadjustcolors (Bevel:tpanelbevel); beginTopcolor:=Clbtnhighlight; ifBevel = bvlowered ThenTopcolor: =Clbtnshadow; Bottomcolor:=Clbtnshadow; ifBevel = bvlowered ThenBottomcolor: =Clbtnhighlight; End;beginRect:=GetClientRect; ifBevelouter <> Bvnone Then beginadjustcolors (Bevelouter); Frame3d (Canvas, Rect, Topcolor, Bottomcolor, bevelwidth); End; Frame3d (Canvas, Rect, color, color, BorderWidth); ifBevelinner <> Bvnone Then beginadjustcolors (Bevelinner); Frame3d (Canvas, Rect, Topcolor, Bottomcolor, bevelwidth); End; withCanvas Do begin if notThemeservices.themesenabledor notParentbackground Then beginBrush.color: = color;//This is where the brush is set. If it is changed to clred, the spot will make the Tpanel into Red FillRect (Rect); End; Brush.style:=bsclear; Font:=Self.font; Fontheight:= TextHeight ('W'); withRect Do beginTop:= ((Bottom + Top)-fontheight)Div 2; Bottom:= Top +Fontheight; End; Flags:= Dt_expandtabsorDt_vcenterorAlignments[falignment]; Flags:=drawtextbidimodeflags (Flags); DrawText (Handle, PChar (Caption),-1, Rect, Flags); End;End;
The default color of the Tpanel is stored in DFM, the color of the brush is set in the paint function after reading, and then the entire background is filled