LCL: groupbox: use csOpaque style if the groupbox shouldn't be transparent, publish ParentBackground

git-svn-id: trunk@64871 -
This commit is contained in:
ondrej 2021-03-26 09:17:12 +00:00
parent 6be311758d
commit 28e5806a74
2 changed files with 32 additions and 1 deletions

View File

@ -20,6 +20,21 @@ begin
Result.CY := 105;
end;
procedure TCustomGroupBox.SetParentBackground(const AParentBackground: Boolean);
begin
inherited SetParentBackground(AParentBackground);
UpdateOpaque;
end;
procedure TCustomGroupBox.UpdateOpaque;
begin
if ParentBackground then
ControlStyle := ControlStyle - [csOpaque]
else
ControlStyle := ControlStyle + [csOpaque];
end;
procedure TCustomGroupBox.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
@ -33,9 +48,18 @@ constructor TCustomGroupBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCompStyle := csGroupBox;
ControlStyle := ControlStyle + [csAcceptsControls];
ControlStyle := ControlStyle + [csAcceptsControls, csParentBackground];
with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY);
end;
procedure TCustomGroupBox.CMParentColorChanged(var Message: TLMessage);
begin
inherited;
if csLoading in ComponentState then Exit;
UpdateOpaque;
end;
// included by stdctrls.pp

View File

@ -166,9 +166,15 @@ type
protected
class procedure WSRegisterClass; override;
class function GetControlClassDefaultSize: TSize; override;
procedure UpdateOpaque;
procedure CreateParams(var Params: TCreateParams); override;
procedure SetParentBackground(const AParentBackground: Boolean); override;
procedure CMParentColorChanged(var Message: TLMessage); message CM_PARENTCOLORCHANGED;
public
constructor Create(AOwner: TComponent); override;
property ParentBackground default True;
end;
@ -194,6 +200,7 @@ type
property DragMode;
property Enabled;
property Font;
property ParentBackground;
property ParentBidiMode;
property ParentColor;
property ParentDoubleBuffered;