mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 23:18:01 +02:00
implemented several TrackBar properties on win32 (issue #1795)
git-svn-id: trunk@9115 -
This commit is contained in:
parent
01de1692b1
commit
db2a2141a9
@ -1498,7 +1498,7 @@ type
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure SetTick(Value: Integer);
|
||||
published
|
||||
property Frequency: Integer read FFrequency write SetFrequency;
|
||||
property Frequency: Integer read FFrequency write SetFrequency default 1;
|
||||
property LineSize: Integer read FLineSize write SetLineSize default 1;
|
||||
property Max: Integer read FMax write SetMax default 10;
|
||||
property Min: Integer read FMin write SetMin default 0;
|
||||
|
@ -68,6 +68,7 @@ begin
|
||||
FMin := 0;
|
||||
FPosition := 0;
|
||||
FPageSize := 2;
|
||||
FFrequency := 1;
|
||||
FOrientation := trHorizontal;
|
||||
FScalePos := trTop;
|
||||
FScaleDigits := 0;
|
||||
@ -200,7 +201,11 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomTrackBar.SetFrequency(Value: Integer);
|
||||
begin
|
||||
FFrequency := Value;
|
||||
if FFrequency <> Value then
|
||||
begin
|
||||
FFrequency := Value;
|
||||
ApplyChanges;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -226,7 +231,11 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomTrackBar.SetTickMarks(Value: TTickMark);
|
||||
begin
|
||||
FTickMarks := Value;
|
||||
if FTickMarks <> Value then
|
||||
begin
|
||||
FTickMarks := Value;
|
||||
ApplyChanges;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -32,11 +32,11 @@ uses
|
||||
// LCL
|
||||
ComCtrls, LCLType, Controls, Graphics,
|
||||
ImgList, StdCtrls,
|
||||
LCLProc, InterfaceBase, Win32Int,
|
||||
LCLProc, InterfaceBase,
|
||||
// widgetset
|
||||
WSComCtrls, WSLCLClasses, WSProc,
|
||||
// win32 widgetset
|
||||
Win32WSControls;
|
||||
Win32Int, Win32Proc, Win32WSControls;
|
||||
|
||||
type
|
||||
|
||||
@ -525,35 +525,29 @@ end;
|
||||
procedure TWin32WSTrackBar.ApplyChanges(const ATrackBar: TCustomTrackBar);
|
||||
var
|
||||
wHandle: HWND;
|
||||
NewStyle: integer;
|
||||
const
|
||||
StyleMask = TBS_AUTOTICKS or TBS_NOTICKS or TBS_VERT or TBS_TOP or TBS_BOTH;
|
||||
TickStyleStyle : array[TTickStyle] of integer =
|
||||
(TBS_NOTICKS, TBS_AUTOTICKS, 0);
|
||||
OrientationStyle : array[TTrackBarOrientation] of integer =
|
||||
(TBS_HORZ, TBS_VERT);
|
||||
TickMarksStyle : array[TTickMark] of integer =
|
||||
(TBS_BOTTOM, TBS_TOP, TBS_BOTH);
|
||||
begin
|
||||
with ATrackBar do
|
||||
begin
|
||||
{ cache handle }
|
||||
wHandle := Handle;
|
||||
NewStyle := TickStyleStyle[TickStyle] or OrientationStyle[Orientation] or
|
||||
TickMarksStyle[TickMarks];
|
||||
UpdateWindowStyle(wHandle, NewStyle, StyleMask);
|
||||
Windows.SendMessage(wHandle, TBM_SETRANGEMAX, Windows.WPARAM(true), Max);
|
||||
Windows.SendMessage(wHandle, TBM_SETRANGEMIN, Windows.WPARAM(true), Min);
|
||||
Windows.SendMessage(wHandle, TBM_SETPOS, Windows.WPARAM(true), Position);
|
||||
Windows.SendMessage(wHandle, TBM_SETLINESIZE, 0, LineSize);
|
||||
Windows.SendMessage(wHandle, TBM_SETPAGESIZE, 0, PageSize);
|
||||
case Orientation of
|
||||
trVertical:
|
||||
SetWindowLong(wHandle, GWL_STYLE, GetWindowLong(wHandle, GWL_STYLE) or TBS_VERT);
|
||||
trHorizontal:
|
||||
SetWindowLong(wHandle, GWL_STYLE, GetWindowLong(wHandle, GWL_STYLE) or TBS_HORZ);
|
||||
end;
|
||||
if TickStyle<>tsNone then
|
||||
begin
|
||||
case ScalePos of
|
||||
trLeft:
|
||||
SetWindowLong(wHandle, GWL_STYLE, GetWindowLong(wHandle, GWL_STYLE) or TBS_LEFT or TBS_VERT);
|
||||
trRight:
|
||||
SetWindowLong(wHandle, GWL_STYLE, GetWindowLong(wHandle, GWL_STYLE) or TBS_RIGHT or TBS_VERT);
|
||||
trTop:
|
||||
SetWindowLong(wHandle, GWL_STYLE, GetWindowLong(wHandle, GWL_STYLE) or TBS_TOP or TBS_HORZ);
|
||||
trBottom:
|
||||
SetWindowLong(wHandle, GWL_STYLE, GetWindowLong(wHandle, GWL_STYLE) or TBS_BOTTOM or TBS_HORZ);
|
||||
end;
|
||||
end;
|
||||
Windows.SendMessage(wHandle, TBM_SETTICFREQ, Frequency, 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user