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; FAlignment: TAlignment;
FBorder: TButtonExBorder; FBorder: TButtonExBorder;
FCanvas: TCanvas; FCanvas: TCanvas;
FCaption: String;
FColors: TButtonExColors; FColors: TButtonExColors;
FDefaultDrawing: Boolean; FDefaultDrawing: Boolean;
FFontDisabled: TFont; FFontDisabled: TFont;
@ -90,6 +91,7 @@ type
FState: TButtonExState; FState: TButtonExState;
FWordwrap: Boolean; FWordwrap: Boolean;
procedure SetAlignment(const Value: TAlignment); procedure SetAlignment(const Value: TAlignment);
procedure SetCaption(const AValue: String);
procedure SetDefaultDrawing(const Value: Boolean); procedure SetDefaultDrawing(const Value: Boolean);
procedure SetGradient(const Value: Boolean); procedure SetGradient(const Value: Boolean);
procedure SetShowFocusRect(const Value: Boolean); procedure SetShowFocusRect(const Value: Boolean);
@ -97,7 +99,7 @@ type
procedure SetWordWrap(const Value: Boolean); procedure SetWordWrap(const Value: Boolean);
protected protected
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: Integer; procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: Integer;
WithThemeSpace: Boolean); override; {%H-}WithThemeSpace: Boolean); override;
class function GetControlClassDefaultSize: TSize; override; class function GetControlClassDefaultSize: TSize; override;
function GetDrawTextFlags: Cardinal; function GetDrawTextFlags: Cardinal;
procedure MouseEnter; override; procedure MouseEnter; override;
@ -118,7 +120,7 @@ type
property AutoSize; property AutoSize;
property BorderSpacing; property BorderSpacing;
property Cancel; property Cancel;
property Caption; property Caption: String read FCaption write SetCaption;
//property Color; removed for new property Colors //property Color; removed for new property Colors
property Constraints; property Constraints;
property Cursor; property Cursor;
@ -618,6 +620,15 @@ begin
Invalidate; Invalidate;
end; 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); procedure TButtonEx.SetDefaultDrawing(const Value: Boolean);
begin begin
if FDefaultDrawing = Value then if FDefaultDrawing = Value then
@ -703,6 +714,7 @@ begin
FState := bxsFocused; FState := bxsFocused;
Invalidate; Invalidate;
end; end;
{ not clear...
CM_DIALOGKEY: CM_DIALOGKEY:
begin begin
if (Message.WParam = VK_RETURN) and Default and (not Focused) and (FState <> bxsDisabled) then 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 if (Message.WParam = VK_ESCAPE) and Cancel and (FState <> bxsDisabled) then
Click; Click;
end; end;
}
CM_ENABLEDCHANGED: CM_ENABLEDCHANGED:
begin begin
if not Enabled then if not Enabled then

View File

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

View File

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

View File

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

View File

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