ExCtrls: Fix painting of TButtonEx under Win 11. Less hints and warnings

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8123 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-10-27 14:24:30 +00:00
parent 1f45709f7c
commit abb51a3028
5 changed files with 27 additions and 14 deletions

View File

@ -78,6 +78,7 @@ type
FAlignment: TAlignment;
FBorder: TButtonExBorder;
FCanvas: TCanvas;
FCaption: String;
FColors: TButtonExColors;
FDefaultDrawing: Boolean;
FFontDisabled: TFont;
@ -90,6 +91,7 @@ type
FState: TButtonExState;
FWordwrap: Boolean;
procedure SetAlignment(const Value: TAlignment);
procedure SetCaption(const AValue: String);
procedure SetDefaultDrawing(const Value: Boolean);
procedure SetGradient(const Value: Boolean);
procedure SetShowFocusRect(const Value: Boolean);
@ -97,7 +99,7 @@ type
procedure SetWordWrap(const Value: Boolean);
protected
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: Integer;
WithThemeSpace: Boolean); override;
{%H-}WithThemeSpace: Boolean); override;
class function GetControlClassDefaultSize: TSize; override;
function GetDrawTextFlags: Cardinal;
procedure MouseEnter; override;
@ -118,7 +120,7 @@ type
property AutoSize;
property BorderSpacing;
property Cancel;
property Caption;
property Caption: String read FCaption write SetCaption;
//property Color; removed for new property Colors
property Constraints;
property Cursor;
@ -575,13 +577,13 @@ begin
btn := tbPushButtonDefaulted
else
btn := tbPushButtonNormal;
// Background
details := ThemeServices.GetElementDetails(btn);
InflateRect(lRect, 1, 1);
ThemeServices.DrawElement(FCanvas.Handle, details, lRect);
InflateRect(lRect, -1, -1);
// Text
FCanvas.Font.Assign(Font);
flags := GetDrawTextFlags;
@ -618,6 +620,15 @@ begin
Invalidate;
end;
procedure TButtonEx.SetCaption(const AValue: String);
begin
if FCaption = AValue then
exit;
inherited Caption := '';
FCaption := AValue;
Invalidate;
end;
procedure TButtonEx.SetDefaultDrawing(const Value: Boolean);
begin
if FDefaultDrawing = Value then
@ -703,6 +714,7 @@ begin
FState := bxsFocused;
Invalidate;
end;
{ not clear...
CM_DIALOGKEY:
begin
if (Message.WParam = VK_RETURN) and Default and (not Focused) and (FState <> bxsDisabled) then
@ -710,6 +722,7 @@ begin
if (Message.WParam = VK_ESCAPE) and Cancel and (FState <> bxsDisabled) then
Click;
end;
}
CM_ENABLEDCHANGED:
begin
if not Enabled then

View File

@ -5,7 +5,7 @@ unit ExCheckCombo;
interface
uses
LCLIntf, LCLType, LMessages,
LCLIntf, LCLType,
Classes, SysUtils, Controls, StdCtrls, GroupedEdit, EditBtn, CheckLst, Forms;
type
@ -294,7 +294,7 @@ end;
procedure TCheckComboBoxForm.MeasureHeight(out AHeight: Integer);
var
i: Integer;
h: Integer;
h: Integer = 0;
begin
AHeight := 0;
for i := 0 to FCheckListbox.Items.Count-1 do

View File

@ -34,7 +34,6 @@ type
private
FAlignment: TLeftRight;
FAllowGrayed: Boolean;
FThemedBtnSize: TSize;
FBtnLayout: TTextLayout;
FDistance: Integer; // between button and caption
FDrawFocusRect: Boolean;
@ -358,7 +357,7 @@ type
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function CanModify: boolean; virtual;
procedure FlipChildren(AllLevels: Boolean); override;
procedure FlipChildren({%H-}AllLevels: Boolean); override;
function Rows: integer;
end;
@ -2017,6 +2016,7 @@ procedure TCheckGroupExStringList.SaveCheckStates(out AStates: TByteDynArray);
var
i: Integer;
begin
AStates := nil;
SetLength(AStates, FCheckgroup.Items.Count);
for i:=0 to FCheckgroup.Items.Count-1 do begin
AStates[i] := 0;
@ -2101,7 +2101,7 @@ end;
procedure TCustomCheckGroupEx.ReadData(Stream: TStream);
var
ChecksCount: integer;
Checks: string;
Checks: string = '';
i: Integer;
v: Integer;
begin
@ -2184,7 +2184,7 @@ end;
procedure TCustomCheckGroupEx.WriteData(Stream: TStream);
var
ChecksCount: integer;
Checks: string;
Checks: string = '';
i: Integer;
v: Integer;
begin

View File

@ -30,7 +30,7 @@ unit ExCombo;
interface
uses
LCLIntf, LCLType, LMessages, LazLoggerBase,
LCLIntf, LCLType, LazLoggerBase,
Classes, SysUtils, Graphics, Types,
StdCtrls, Controls, Forms;
@ -153,7 +153,7 @@ type
implementation
uses
GraphUtil, Themes;
Themes;
const
DEFAULT_COLUMN_MARGIN = 4;

View File

@ -188,7 +188,7 @@ type
public
function ValueToStr(const AValue: Double): String; override;
{$IF LCL_FullVersion >= 2010000}
function KeyAllowed(Key: Char): Boolean; override;
function KeyAllowed({%H-}Key: Char): Boolean; override;
{$endif}
end;
@ -439,7 +439,7 @@ var
parenth: TParenthesis;
P: PChar;
PEnd: PChar;
s: String;
s: String = '';
n: Integer;
begin
Result := false;