/
ProgressBar.prg
178 lines (98 loc) · 3.9 KB
/
ProgressBar.prg
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/// <include file="Gui.xml" path="doc/ProgressBar/*" />
CLASS ProgressBar INHERIT Control
PROTECT dwUnitSize AS DWORD
PROTECT dwPosition AS DWORD
PROTECT dwOldPosition AS DWORD
PROTECT oRange AS Range
/// <exclude />
ASSIGN __Value(nValue AS USUAL) STRICT
//PP-030828 Strong typing
IF IsString(nValue)
nValue := Val(nValue)
ENDIF
SELF:Position := LONGINT(Round(nValue, 0))
RETURN
/// <include file="Gui.xml" path="doc/ProgressBar.Advance/*" />
METHOD Advance(dwNewPosition)
// Instruct the ProgressBar to update its position and save the old position
IF IsNil(dwNewPosition)
dwOldPosition := DWORD(SendMessage(hWnd, PBM_STEPIT, 0, 0))
dwNewPosition := SELF:OldPosition + SELF:UnitSize
ELSE
dwOldPosition := DWORD(SendMessage(hWnd, PBM_DELTAPOS, dwNewPosition, 0))
ENDIF
// Read the position from the control
SELF:dwPosition := DWORD(SendMessage(SELF:Handle(), PBM_GETPOS, 0, 0L))
//RETURN dwPosition := dwNewPosition
RETURN SELF:dwPosition
/// <include file="Gui.xml" path="doc/ProgressBar.BackgroundColor/*" />
ASSIGN BackgroundColor(oColor)
SendMessage(SELF:Handle(), PBM_SETBKCOLOR, 0, LONGINT(_CAST, oColor:ColorRef))
RETURN
/// <include file="Gui.xml" path="doc/ProgressBar.BarColor/*" />
ASSIGN BarColor(oColor)
SendMessage(SELF:Handle(), PBM_SETBARCOLOR, 0, LONGINT(_CAST, oColor:ColorRef))
RETURN
/// <include file="Gui.xml" path="doc/ProgressBar.ctor/*" />
CONSTRUCTOR(oOwner, xID, oPoint, oDimension, kStyle, lDataAware)
Default(@lDataAware, TRUE)
IF (xID IS ResourceID)
SUPER(oOwner, xID, oPoint, oDimension, , kStyle, lDataAware)
ELSE
SUPER(oOwner, xID, oPoint, oDimension, PROGRESS_CLASS, kStyle, lDataAware)
ENDIF
// Set the default single-step size to 10 range to (0, 100). Since these are the default
// values, we don't need to call the UnitSize() and Range() assigns, since that will send
// a message to the control; we need only set the instance variable directly.
dwUnitSize := 10
oRange := Range{0, 100}
SELF:Position := 0
dwOldPosition := 0
RETURN
/// <include file="Gui.xml" path="doc/ProgressBar.OldPosition/*" />
ACCESS OldPosition
RETURN dwOldPosition
/// <include file="Gui.xml" path="doc/ProgressBar.Position/*" />
ACCESS Position
//RvdH 050602 Fixed issue 12973
//RETURN dwPosition
RETURN SendMessage(SELF:Handle(), PBM_GETPOS, 0, 0L)
/// <include file="Gui.xml" path="doc/ProgressBar.Position/*" />
ASSIGN Position(dwNewPosition)
// Instruct the ProgressBar to update its position and save the old position
dwOldPosition := DWORD(SendMessage(hWnd, PBM_SETPOS, dwNewPosition, 0))
RETURN dwPosition := dwNewPosition
/// <include file="Gui.xml" path="doc/ProgressBar.Range/*" />
ACCESS Range
//RvdH 050602 Changed to retrieve real range from Control
LOCAL DIM aInt[2] AS LONGINT
SendMessage(hWnd, PBM_GETRANGE, 1, LONGINT(_CAST, @aInt[1]))
SELF:oRange := Range{aInt[1], aInt[2]}
RETURN oRange
/// <include file="Gui.xml" path="doc/ProgressBar.Range/*" />
ASSIGN Range(oNewRange)
LOCAL oDllVers AS WinDLLVersion
LOCAL nVers AS FLOAT
//RvdH 050602 Handle large ranges when ComCtrl32 > 4.70
IF oNewRange:Max > 0xFFFF
oDllVers := WinDLLVersion{"COMCTL32"}
nVers := oDLLVers:MajorVersion + oDLLVers:MinorVersion /100
IF nVers > 4.70
SendMessage(hWnd, PBM_SETRANGE32, oNewRange:Min, oNewRange:Max)
ELSE
SendMessage(hWnd, PBM_SETRANGE, 0, MAKELPARAM(oNewRange:Min, 0xFFFF))
oNewRange := Range{oNewRange:Min, 0xFFFF}
ENDIF
ELSE
SendMessage(hWnd, PBM_SETRANGE, 0, MAKELPARAM(oNewRange:Min, oNewRange:Max))
ENDIF
RETURN oRange := oNewRange
/// <include file="Gui.xml" path="doc/ProgressBar.UnitSize/*" />
ACCESS UnitSize
RETURN dwUnitSize
/// <include file="Gui.xml" path="doc/ProgressBar.UnitSize/*" />
ASSIGN UnitSize(dwNewUnitSize)
// Instruct the ProgressBar to set the single-step increment
SendMessage(hWnd, PBM_SETSTEP, dwNewUnitSize, 0)
RETURN dwUnitSize := dwNewUnitSize
END CLASS