mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-25 06:50:42 +01:00
lcl: don't allow to set position of trackbar outside Min and Max (based on idea of Leslie Kaye, bug #0012893)
git-svn-id: trunk@18008 -
This commit is contained in:
parent
e1948d6e7a
commit
e5ead902a7
@ -1664,6 +1664,7 @@ type
|
||||
protected
|
||||
procedure ApplyChanges;
|
||||
procedure DoChange(var msg); message LM_CHANGED;
|
||||
procedure FixParams(var APosition, AMin, AMax: Integer);
|
||||
class function GetControlClassDefaultSize: TPoint; override;
|
||||
procedure InitializeWnd; override;
|
||||
procedure Loaded; override;
|
||||
|
||||
@ -143,12 +143,12 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomTrackBar.SetParams(APosition, AMin, AMax: Integer);
|
||||
begin
|
||||
if (not (csLoading in ComponentState)) then begin
|
||||
if AMin>AMax then AMin:=AMax;
|
||||
if APosition<AMin then APosition:=AMin;
|
||||
if APosition>AMax then APosition:=AMax;
|
||||
end;
|
||||
if (FPosition=APosition) and (FMin=AMin) and (FMax=AMax) then exit;
|
||||
if not (csLoading in ComponentState) then
|
||||
FixParams(APosition, AMin, AMax);
|
||||
|
||||
if (FPosition = APosition) and (FMin = AMin) and (FMax = AMax) then
|
||||
Exit;
|
||||
|
||||
FPosition := APosition;
|
||||
FMax := AMax;
|
||||
FMin := AMin;
|
||||
@ -164,10 +164,11 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomTrackBar.SetPosition(Value: Integer);
|
||||
begin
|
||||
FixParams(Value, FMin, FMax);
|
||||
if FPosition <> Value then
|
||||
begin
|
||||
FPosition := Value;
|
||||
if HandleAllocated then
|
||||
if HandleAllocated then
|
||||
TWSTrackBarClass(WidgetSetClass).SetPosition(Self, FPosition);
|
||||
end;
|
||||
end;
|
||||
@ -181,7 +182,8 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomTrackBar.SetMin(Value: Integer);
|
||||
begin
|
||||
if FMin <> Value then SetParams(FPosition,Value,FMax);
|
||||
if FMin <> Value then
|
||||
SetParams(FPosition, Value, FMax);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -193,7 +195,8 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomTrackBar.SetMax(Value: Integer);
|
||||
begin
|
||||
if FMax <> Value then SetParams(FPosition,FMin,Value);
|
||||
if FMax <> Value then
|
||||
SetParams(FPosition, FMin, Value);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -315,6 +318,13 @@ begin
|
||||
FOnChange(Self);
|
||||
end;
|
||||
|
||||
procedure TCustomTrackBar.FixParams(var APosition, AMin, AMax: Integer);
|
||||
begin
|
||||
if AMin > AMax then AMin := AMax;
|
||||
if APosition < AMin then APosition := AMin;
|
||||
if APosition > AMax then APosition := AMax;
|
||||
end;
|
||||
|
||||
class function TCustomTrackBar.GetControlClassDefaultSize: TPoint;
|
||||
begin
|
||||
Result.X:=100;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user