-
Notifications
You must be signed in to change notification settings - Fork 1
/
TrackbarStyleHookCA.pas
118 lines (82 loc) · 2.52 KB
/
TrackbarStyleHookCA.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
unit TrackbarStyleHookCA;
interface
uses
// Delphi
Winapi.Windows, Winapi.Messages, Winapi.CommCtrl,
System.Types, System.SysUtils, Vcl.Controls, Vcl.Themes, Vcl.ComCtrls, Vcl.Graphics,
// DSPack
Unit_DSTrackBarEx;
type
// Draw multiple selections on styled TrackBar
TTrackBarStyleHookCA = class(TTrackBarStyleHook)
protected
procedure Paint(Canvas: TCanvas); override;
public
constructor Create(AControl: TWinControl); override;
end;
implementation
{...$UNDEF USE_HOOK_WITH_SOURCE_CODE}
// Define USE_HOOK_WITH_SOURCE_CODE, if Vcl.ComCtrls.pas is available.
{$DEFINE USE_HOOK_WITH_SOURCE_CODE}
{ TTrackBarStyleHookCA }
constructor TTrackBarStyleHookCA.Create(AControl: TWinControl);
begin
inherited;
if not (AControl is TDSTrackBarEx) then
raise EProgrammerNotFound.Create('Hook needs TDSTrackBarEx!');
end;
{$IFNDEF USE_HOOK_WITH_SOURCE_CODE}
// Simple solution
procedure TTrackBarStyleHookCA.Paint(Canvas: TCanvas);
var
R: TRect;
begin
with TDSTrackBarEx(Control) do
if Assigned(OnChannelPostPaint) then
begin
SendMessage(Handle, TBM_GETCHANNELRECT, 0, IntPtr(@R));
InflateRect(R, -4, -2);
ChannelCanvas.Handle := Canvas.Handle;
OnChannelPostPaint(TDSTrackBarEx(Control), R);
end;
inherited;
end;
{$ELSE}
// Better solution
type
// Access private variables FThumbPressed and FMouseOnThumb
TTrackBarStyleHookHelper = class helper for TTrackBarStyleHook
public
function MouseOnThumb: Boolean;
function ThumbPressed: Boolean;
end;
{ TTrackBarStyleHookHelper }
function TTrackBarStyleHookHelper.MouseOnThumb: Boolean;
begin
with Self do
Result := FMouseOnThumb;
end;
function TTrackBarStyleHookHelper.ThumbPressed: Boolean;
begin
with Self do
Result := FThumbPressed;
end;
const
huhu = 'huhu';
procedure TTrackBarStyleHookCA.Paint(Canvas: TCanvas);
// Insert here (from Vcl.ComCtrls.pas)
// line 33088 (after "procedure TTrackBarStyleHook.Paint(Canvas: TCanvas);")
// to line 33224 (before "// Thumb")
{$I abc874\TrackbarStyleHookCA1.inc}
with TDSTrackBarEx(Control) do
if Assigned(OnChannelPostPaint) then
begin
InflateRect(R, -4, -2);
ChannelCanvas.Handle := Canvas.Handle;
OnChannelPostPaint(TDSTrackBarEx(Control), R);
end;
// Insert here (from Vcl.ComCtrls.pas) line 33225 (after "// Thumb") to line 33323 (before "end;")
{$I abc874\TrackbarStyleHookCA2.inc}
end;
{$ENDIF}
end.