From abb51a302895602664d4e15953fd7c66664c9e15 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 27 Oct 2021 14:24:30 +0000 Subject: [PATCH] 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 --- components/exctrls/source/exbuttons.pas | 21 +++++++++++++++++---- components/exctrls/source/excheckcombo.pas | 4 ++-- components/exctrls/source/excheckctrls.pas | 8 ++++---- components/exctrls/source/excombo.pas | 4 ++-- components/exctrls/source/exeditctrls.pas | 4 ++-- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/components/exctrls/source/exbuttons.pas b/components/exctrls/source/exbuttons.pas index 916deec8e..8730368fb 100644 --- a/components/exctrls/source/exbuttons.pas +++ b/components/exctrls/source/exbuttons.pas @@ -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 diff --git a/components/exctrls/source/excheckcombo.pas b/components/exctrls/source/excheckcombo.pas index b61fe44e3..1d6cf48f5 100644 --- a/components/exctrls/source/excheckcombo.pas +++ b/components/exctrls/source/excheckcombo.pas @@ -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 diff --git a/components/exctrls/source/excheckctrls.pas b/components/exctrls/source/excheckctrls.pas index bf18986a3..3eac8bd75 100644 --- a/components/exctrls/source/excheckctrls.pas +++ b/components/exctrls/source/excheckctrls.pas @@ -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 diff --git a/components/exctrls/source/excombo.pas b/components/exctrls/source/excombo.pas index 05faa6f38..8028912dd 100644 --- a/components/exctrls/source/excombo.pas +++ b/components/exctrls/source/excombo.pas @@ -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; diff --git a/components/exctrls/source/exeditctrls.pas b/components/exctrls/source/exeditctrls.pas index 40785ee96..9d6b7fbff 100644 --- a/components/exctrls/source/exeditctrls.pas +++ b/components/exctrls/source/exeditctrls.pas @@ -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;