mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-30 09:22:40 +02:00
lcl: add TStaticText.Transparent property for Delphi compatibility
win32: implement TStaticText.Transparent same way as groupbox transparency git-svn-id: trunk@28151 -
This commit is contained in:
parent
d49ae27a49
commit
f09ed2fb3c
@ -32,7 +32,8 @@ begin
|
|||||||
fAlignment := taLeftJustify;
|
fAlignment := taLeftJustify;
|
||||||
FShowAccelChar:= true;
|
FShowAccelChar:= true;
|
||||||
FStaticBorderStyle:=sbsNone;
|
FStaticBorderStyle:=sbsNone;
|
||||||
ControlStyle := ControlStyle + [csOpaque, csReplicatable];
|
ControlStyle := ControlStyle + [csReplicatable];
|
||||||
|
Transparent := True;
|
||||||
with GetControlClassDefaultSize do
|
with GetControlClassDefaultSize do
|
||||||
SetInitialBounds(0, 0, CX, CY);
|
SetInitialBounds(0, 0, CX, CY);
|
||||||
end;
|
end;
|
||||||
@ -82,6 +83,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomStaticText.GetTransparent: Boolean;
|
||||||
|
begin
|
||||||
|
Result := not (csOpaque in ControlStyle);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCustomStaticText.SetFocusControl
|
Method: TCustomStaticText.SetFocusControl
|
||||||
Params: Val - new property value
|
Params: Val - new property value
|
||||||
@ -151,6 +157,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomStaticText.SetTransparent(const AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if Transparent = AValue then
|
||||||
|
Exit;
|
||||||
|
if AValue then
|
||||||
|
ControlStyle := ControlStyle - [csOpaque]
|
||||||
|
else
|
||||||
|
ControlStyle := ControlStyle + [csOpaque];
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCustomStaticText.WMActivate
|
Method: TCustomStaticText.WMActivate
|
||||||
Params: Message: Activation message
|
Params: Message: Activation message
|
||||||
|
@ -1384,6 +1384,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function StaticTextParentMsgHandler(const AWinControl: TWinControl; Window: HWnd;
|
||||||
|
Msg: UInt; WParam: Windows.WParam; LParam: Windows.LParam;
|
||||||
|
var MsgResult: Windows.LResult; var WinProcess: Boolean): Boolean;
|
||||||
|
var
|
||||||
|
Info: PWin32WindowInfo;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
case Msg of
|
||||||
|
WM_CTLCOLORSTATIC:
|
||||||
|
begin
|
||||||
|
Info := GetWin32WindowInfo(HWND(LParam));
|
||||||
|
Result := Assigned(Info) and ThemeServices.ThemesAvailable and TCustomStaticText(Info^.WinControl).Transparent;
|
||||||
|
if Result then
|
||||||
|
begin
|
||||||
|
ThemeServices.DrawParentBackground(HWND(LParam), HDC(WParam), nil, False);
|
||||||
|
MsgResult := GetStockObject(HOLLOW_BRUSH);
|
||||||
|
WinProcess := False;
|
||||||
|
SetBkMode(HDC(WParam), TRANSPARENT);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function CalcStaticTextFlags(
|
function CalcStaticTextFlags(
|
||||||
const AAlignment: TAlignment;
|
const AAlignment: TAlignment;
|
||||||
@ -1423,6 +1445,7 @@ begin
|
|||||||
// create window
|
// create window
|
||||||
FinishCreateWindow(AWinControl, Params, false);
|
FinishCreateWindow(AWinControl, Params, false);
|
||||||
Result := Params.Window;
|
Result := Params.Window;
|
||||||
|
Params.WindowInfo^.ParentMsgHandler := @StaticTextParentMsgHandler;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSCustomStaticText.GetPreferredSize(
|
class procedure TWin32WSCustomStaticText.GetPreferredSize(
|
||||||
|
@ -967,8 +967,10 @@ type
|
|||||||
FFocusControl: TWinControl;
|
FFocusControl: TWinControl;
|
||||||
FShowAccelChar: boolean;
|
FShowAccelChar: boolean;
|
||||||
FStaticBorderStyle: TStaticBorderStyle;
|
FStaticBorderStyle: TStaticBorderStyle;
|
||||||
|
function GetTransparent: Boolean;
|
||||||
procedure SetAlignment(Value: TAlignment);
|
procedure SetAlignment(Value: TAlignment);
|
||||||
procedure SetStaticBorderStyle(Value: TStaticBorderStyle);
|
procedure SetStaticBorderStyle(Value: TStaticBorderStyle);
|
||||||
|
procedure SetTransparent(const AValue: Boolean);
|
||||||
procedure WMActivate(var Message: TLMActivate); message LM_ACTIVATE;
|
procedure WMActivate(var Message: TLMActivate); message LM_ACTIVATE;
|
||||||
protected
|
protected
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
@ -985,6 +987,7 @@ type
|
|||||||
property BorderStyle: TStaticBorderStyle read FStaticBorderStyle write SetStaticBorderStyle default sbsNone;
|
property BorderStyle: TStaticBorderStyle read FStaticBorderStyle write SetStaticBorderStyle default sbsNone;
|
||||||
property FocusControl: TWinControl read FFocusControl write SetFocusControl;
|
property FocusControl: TWinControl read FFocusControl write SetFocusControl;
|
||||||
property ShowAccelChar: boolean read FShowAccelChar write SetShowAccelChar default true;
|
property ShowAccelChar: boolean read FShowAccelChar write SetShowAccelChar default true;
|
||||||
|
property Transparent: Boolean read GetTransparent write SetTransparent default True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1028,6 +1031,7 @@ type
|
|||||||
property ShowHint;
|
property ShowHint;
|
||||||
property TabOrder;
|
property TabOrder;
|
||||||
property TabStop;
|
property TabStop;
|
||||||
|
property Transparent;
|
||||||
property Visible;
|
property Visible;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user