Check-in [933cdb7a74]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added all current source files
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 933cdb7a74a34c75bbd2e7bda830e3bd4ee0feb0
User & Date: Martijn 2011-05-19 20:06:45
Context
2011-05-21
10:32
Added screenshot check-in: d23a0db0ac user: Martijn tags: trunk
2011-05-19
20:06
Added all current source files check-in: 933cdb7a74 user: Martijn tags: trunk
2011-05-01
14:49
initial empty check-in check-in: b03b9b790d user: tinus tags: trunk
Changes

Added out/TempusFugit.exe.

cannot compute difference between binary files

Added out/TempusFugit.ini.sample.















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[General]
Opacity=100

[Gradient]
StartColor=$7F0000
StartCurve=4

CloseColor=$007F00
CloseCurve=2

StopColor=$00FFFF
;StopCurve=1

OverColor=$0000FF
;OverCurve=1

[Google Calendar]
URL=http://www.google.com/calendar/feeds/USER%40GMAIL.COM/private-SECRET/full
WorkingHours=Work
LunchHours=Lunch

[Debug]
DateOffset=0

Added res/Stopwatch.ico.

cannot compute difference between binary files

Added src/F_Main.dfm.













































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
object frmMain: TfrmMain
  Left = 0
  Top = 0
  AlphaBlend = True
  AlphaBlendValue = 204
  Caption = 'Work hours'
  ClientHeight = 356
  ClientWidth = 116
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PopupMenu = pumContext
  Position = poScreenCenter
  ShowHint = True
  OnClose = FormClose
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  OnPaint = FormPaint
  OnResize = FormResize
  PixelsPerInch = 96
  TextHeight = 13
  object httpClient: TIdHTTP
    AllowCookies = True
    HandleRedirects = True
    ProxyParams.BasicAuthentication = False
    ProxyParams.ProxyPort = 0
    Request.ContentLength = -1
    Request.Accept = 'text/xml, text/html, */*'
    Request.BasicAuthentication = False
    Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'
    HTTPOptions = [hoForceEncodeParams]
    Left = 32
    Top = 72
  end
  object tmrFetchTimes: TTimer
    Enabled = False
    Interval = 900000
    OnTimer = tmrFetchTimesTimer
    Left = 32
    Top = 8
  end
  object tmrUpdateProgress: TTimer
    Interval = 60000
    OnTimer = tmrUpdateProgressTimer
    Left = 32
    Top = 120
  end
  object pumContext: TPopupMenu
    Images = imlMain
    Left = 32
    Top = 176
    object miRefresh: TMenuItem
      Caption = '&Refresh'
      ImageIndex = 1
      OnClick = miRefreshClick
    end
    object miOpacity: TMenuItem
      Caption = '&Opacity'
      object mnuOpacity100: TMenuItem
        Tag = 100
        Caption = '100%'
        OnClick = mnuOpacityClick
      end
      object N751: TMenuItem
        Tag = 90
        Caption = '90%'
        OnClick = mnuOpacityClick
      end
      object N801: TMenuItem
        Tag = 80
        Caption = '80%'
        OnClick = mnuOpacityClick
      end
      object N701: TMenuItem
        Tag = 70
        Caption = '70%'
        OnClick = mnuOpacityClick
      end
      object N601: TMenuItem
        Tag = 60
        Caption = '60%'
        OnClick = mnuOpacityClick
      end
      object N501: TMenuItem
        Tag = 50
        Caption = '50%'
        OnClick = mnuOpacityClick
      end
      object N401: TMenuItem
        Tag = 40
        Caption = '40%'
        OnClick = mnuOpacityClick
      end
      object N301: TMenuItem
        Tag = 30
        Caption = '30%'
        OnClick = mnuOpacityClick
      end
    end
    object N1: TMenuItem
      Caption = '-'
    end
    object miClose: TMenuItem
      Caption = '&Close'
      ImageIndex = 0
      OnClick = miCloseClick
    end
  end
  object imlMain: TImageList
    Left = 32
    Top = 232
    Bitmap = {
      494C010102000400080010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
      0000000000003600000028000000400000001000000001002000000000000010
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000BDC5D200676FBE002B31B0000F17AB000F15A8002B2FA800686CB600BDC5
      D000000000000000000000000000000000000000000000000000000000000000
      000000000000ABC6B500489E49001C9B1900149A12003698320078AE7B000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000008B95
      D2000E20C0000020D8000023E0000020D9000019CC000011BD00000BB0000F13
      A4008D92C9000000000000000000000000000000000000000000000000000000
      000095C29D001D9C1D003BBF410036BF40002DBF340020BF220012AF12005DAA
      5C00000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000000000008B96D600031E
      D400002FFF00002AFB00002DF800002BF2000029EE00001FE5000012CA00000D
      B5000308A3008D92C90000000000000000000000000032A9340046B44B00A7C6
      B2001C9B1D004ABF500042BF48001CA11A005DAB60008BB98E006BAB6C001C8D
      130085B689000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000C0C8D300142ED2000035
      FF0097A9E8006888F4000034FF00002DFF000033FA0095B1FD004570FB000019
      D400000DB6000E12A300BDC5D10000000000000000002C9F2F0063BD65000F94
      16006ABF6D0057BF5A001FA320009AC3A200000000000000000000000000B3C9
      BC006EAF6E000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000000000006573CE00254EF8000034
      FF00CACDDC00F5EFDE00B1C0EF00063DFF00B1C4FA00FFFFFB00FFFFFF006187
      FD000012CA00000CB200676BB700000000000000000038A23E008FBF900076BF
      770070BF720048AF480070B67600000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000000000002E47D6003D6AFF00083C
      FE0097A3E200F4F1E100F6F3EA00E4E8F300FFFFF800FFFFFF00F3F7FF00446D
      FD000022E7000012BE002B30AC00000000000000000041A549009CBF9D007BBF
      7D0078BF7800219A25006CB27200B9CCC5000000000000000000000000000000
      0000C7CFD300C3CDCE0000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000000000001F3EE0004B76FF002255
      FF000D41FE005C7AF000EFEDEB00F6F6F300FFFFFB00CDDAFE00174AFF00002A
      FC00002CF3000019CB000E17AE00000000000000000056AB5D00ABBFAC0094BF
      940089BF8A007ABF7D005FBF630056AD5D00A3C3AB0052AA520043A23F003DA0
      390037943700369432008CB58F00000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000000000002141E4006489FF002E5F
      FF003364FF000639FC00DADCED00FBF9F300FFFFFB00ADC0FE000033FF000236
      FF000030FA000020DA000E18B100000000000000000085BB8E0038A642003CA6
      450036AF40003AB1410040AE4700A1C6AC0055A5580078BF7F008DBF930090BF
      94008DBF91008BBF9100619B5D00000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000304DDF0083A2FF003D6C
      FF003C6CFF00526DE900FFFBE900B2BFF300D4DAF900FFFFFF006D8FFF000033
      FF000032FF000023E2002C36B800000000000000000000000000C0CFCC00C6CF
      D20000000000000000000000000000000000B9CBC3006EA86E002E992A0078BF
      7B007ABF7B0085BF8C0048954300000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000677ADA00688AFA007096
      FF002958F700BABEDE00F5F3E7001543F7000E41FD00E7ECFB00FFFFFF002958
      FE000035FF000021DA006973C300000000000000000000000000000000000000
      0000000000000000000000000000000000000000000071B2750058B9580070BF
      720072BF760085BF8B003A933500000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000BEC7D600244AEB0097B6
      FF004C75F9005B6CD800546BE1003365FF002D5FFF001745FC00C7D1FA004C73
      FF000135FF001125C700BFC7D3000000000000000000000000000000000057B1
      5D00B4CDC00000000000000000000000000099C4A20026A9270057BF5A0066BF
      6C0012840D0075BD75002E952900000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000000000008FA0E0002E52
      F20096B3FF006F95FF003966FA00396AFF002F60FF002153FE00083CFF000C40
      FF000524DA00919CD60000000000000000000000000000000000000000007EBD
      870013A420006ABB75008AC194005CB4640021AA230042BF46005BBF6000229B
      2000AAC4B10047A9460043A63C00000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000000000000000000090A0
      DF002448EE006688FA0088A9FF006A8FFF004F7AFF003E6DFF00204CF6001833
      D800919ED7000000000000000000000000000000000000000000000000000000
      000053B95D0014B919001FBA21002BBF300033BF380057BF5D001C9E1D007CB6
      8200000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000BFC8D5006D7FDD003251E2002647E7002444E400324CD9006E7ED400C0C8
      D400000000000000000000000000000000000000000000000000000000000000
      00000000000070B5790034A93F00189E1C001F9B2000399D3C008EBA95000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000424D3E000000000000003E000000
      2800000040000000100000000100010000000000800000000000000000000000
      000000000000000000000000FFFFFF00FFFFFFFF00000000F00FF81F00000000
      E007F00F00000000C003800700000000800180E700000000800181FF00000000
      800180F300000000800180010000000080018001000000008001CF0100000000
      8001FF81000000008001E70100000000C003E00100000000E007F00F00000000
      F00FF81F00000000FFFFFFFF0000000000000000000000000000000000000000
      000000000000}
  end
  object trayIcon: TTrayIcon
    BalloonTimeout = 10000
    BalloonFlags = bfWarning
    Left = 32
    Top = 296
  end
end

Added src/F_Main.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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
unit F_Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, AppBar, ExtCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
  ComCtrls, StdCtrls, Menus, ImgList, IniFiles;

type
  TRGBColor = record
    case Boolean of
      True: (Color: integer);
      False: (Red, Green, Blue, Alpha: Byte);
  end;
  TControlPoint = record
    RGB: TRGBColor;
    Position: Extended;
    MapArg: Double;
  end;
  PControlPoint = ^TControlPoint;

type
  TfrmMain = class(TAppBar)
    httpClient: TIdHTTP;
    tmrFetchTimes: TTimer;
    tmrUpdateProgress: TTimer;
    pumContext: TPopupMenu;
    imlMain: TImageList;
    miRefresh: TMenuItem;
    miClose: TMenuItem;
    N1: TMenuItem;
    miOpacity: TMenuItem;
    mnuOpacity100: TMenuItem;
    N751: TMenuItem;
    N801: TMenuItem;
    N701: TMenuItem;
    N601: TMenuItem;
    N501: TMenuItem;
    N401: TMenuItem;
    N301: TMenuItem;
    trayIcon: TTrayIcon;
    procedure tmrFetchTimesTimer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormResize(Sender: TObject);
    procedure tmrUpdateProgressTimer(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure miRefreshClick(Sender: TObject);
    procedure miCloseClick(Sender: TObject);
    procedure mnuOpacityClick(Sender: TObject);
  private
    { Private declarations }
    FSettings: TIniFile;

    FStartTime: TDateTime;
    FStopTime: TDateTime;
    FLunchStart: TDateTime;
    FLunchStop: TDateTime;

    FWaypoints: array of TControlPoint;

    function  DateTimeFromXML(ISODateTime: string): TDateTime;

    procedure FetchHoursOnline();
  protected
    procedure OnAppBarStateChange(Proposed: boolean; Edge: TAppBarEdge); override;
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation
uses
  DateUtils, ComObj, ActiveX, Math,
  IdURI,
  L_VersionInfoW;

{$R *.dfm}

var
  XMLFS: TFormatSettings;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.FormCreate(Sender: TObject);
var
  i: integer;
  Percentage: integer;
begin
  FSettings := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));

  Application.HintHidePause := FSettings.ReadInteger('General', 'HintTimeout', 5000);

  RootKey := HKEY_CURRENT_USER;
  KeyName := '\Software\Voronwë\TimeRemaining\AppBar';
  LoadSettings;

  SetLength(FWaypoints, 4);
  FWaypoints[0].RGB.Color := StringToColor(FSettings.ReadString('Gradient', 'StartColor', 'clHighlight'));
  FWaypoints[0].Position := 0;
  FWaypoints[0].MapArg := FSettings.ReadInteger('Gradient', 'StartCurve', 4);

  FWaypoints[1].RGB.Color := StringToColor(FSettings.ReadString('Gradient', 'CloseColor', '$007F00'));
  FWaypoints[1].Position := 0.5; //(IncHour(FStopTime, -1) - FStartTime) / Duration;
  FWaypoints[1].MapArg := FSettings.ReadInteger('Gradient', 'CloseCurve', 2);

  FWaypoints[2].RGB.Color := StringToColor(FSettings.ReadString('Gradient', 'StopColor', 'clYellow'));
  FWaypoints[2].Position := 1;//(FStopTime - FStartTime) / Duration;
  FWaypoints[2].MapArg := FSettings.ReadInteger('Gradient', 'StopCurve', 1);

  FWaypoints[3].RGB.Color := StringToColor(FSettings.ReadString('Gradient', 'OverColor', 'clRed'));
  FWaypoints[3].Position := 1;
  FWaypoints[3].MapArg := FSettings.ReadInteger('Gradient', 'OverCurve', 1);

  Percentage := FSettings.ReadInteger('General', 'Opacity', 80);
  Self.AlphaBlendValue := Trunc(Percentage / 100 * 255);
  for i := 0 to miOpacity.Count - 1 do begin
    miOpacity.Items[i].Checked := (miOpacity.Items[i].Tag = Percentage);
  end;

  trayIcon.BalloonTitle := Application.Title;
  trayIcon.Hint := Application.Title;

  try
    with TFileVersionInfo.Create(ParamStr(0)) do begin
      Self.httpClient.Request.UserAgent := ProductName + '/' + ProductVersion + ' (Indy Library) ' + Internalname + '/' + FileVersion;
    end;
  except
    // ignore if this goes wrong
  end;

  tmrFetchTimesTimer(tmrFetchTimes);
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  SaveSettings;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.FormDestroy(Sender: TObject);
begin
  FreeAndNil(FSettings);
end;


{ ------------------------------------------------------------------------------------------------ }
function PowerMapping (arg1:Double; arg2:Double=0.0): Double;
{ given, arg1 in 0..1, return a value such that
  PowerMapping(0)=0 and
  PowerMapping(1)=1
}
begin
    if arg2 = 0 then arg2 := 1;

    if arg2 < 0
        then Result := 1 - Power ((1-arg1), -arg2)
        else Result := Power (arg1, arg2);
end;


{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.FormPaint(Sender: TObject);
var
  BeginTime, EndTime, Duration: TDateTime;
  WP1, WP2: PControlPoint;
  CurrentY, StartX, EndX, StartY, EndY: integer;
  Factor: Extended;
  Color, Shadow: TRGBColor;
  Grey: Byte;
  i, y: Integer;
  Box, LunchBox: TRect;
  Hour: TDateTime;
  Text: string;
  Height: integer;
  TopY, PrevY: integer;
begin
  if FStopTime <= FStartTime then begin
    Exit;
  end;

  Canvas.Brush.Style := bsSolid;
  Canvas.Brush.Color := clBtnFace;
  Canvas.Pen.Style := psSolid;
  Canvas.Pen.Color := clBtnText;
  ZeroMemory(@Color, sizeof(Color));

  BeginTime := Trunc(FStartTime) + EncodeTime(HourOf(FStartTime), 0, 0, 0);
//  if Abs(BeginTime - FStartTime) > 0.01 then begin
//    BeginTime := IncHour(BeginTime, -1);
//  end;

  if Now > FStopTime then begin
    EndTime := Now;
  end else begin
    EndTime := FStopTime;
  end;
  Duration := EndTime - BeginTime;

  FWaypoints[0].Position := (FStartTime - BeginTime) / Duration;
  FWaypoints[1].Position := (IncMinute(FStopTime, -30) - BeginTime) / Duration;
  FWaypoints[2].Position := (FStopTime - BeginTime) / Duration;
  CurrentY := Trunc(Self.ClientHeight * (Now - BeginTime) / Duration);

  StartX := 0;
  EndX := Self.ClientWidth;

  StartY := 0;
  EndY   := Trunc(Self.ClientHeight * FWaypoints[0].Position);
  if EndY > StartY then begin
    Box.Top := StartY;
    Box.Bottom := EndY;
    Box.Left := StartX;
    Box.Right := EndX;
    Canvas.Brush.Color := clBtnFace;
    Canvas.FillRect(Box);
  end;

  for i := 1 to Length(FWaypoints) - 1 do begin
    WP1 := @FWaypoints[i - 1];
    WP2 := @FWaypoints[i];

    Canvas.Brush.Color := WP1.RGB.Color;
    StartY := Trunc(Self.ClientHeight * WP1.Position);
    EndY   := Trunc(Self.ClientHeight * WP2.Position);

    if StartY > CurrentY then begin
      Break;
    end;
    Canvas.Pen.Color := WP1.RGB.Color;
    Canvas.MoveTo(StartX, StartY);
    Canvas.LineTo(EndX,   StartY);

    for y := StartY + 1 to Min(EndY, CurrentY) - 1 do begin
      Factor := 1.0 * (y - StartY) / (EndY - StartY);
      Factor := PowerMapping(Factor, WP1.MapArg);

      Color.Red := WP1.RGB.Red + Trunc((WP2.RGB.Red - WP1.RGB.Red) * Factor);
      Color.Green := WP1.RGB.Green + Trunc((WP2.RGB.Green - WP1.RGB.Green) * Factor);
      Color.Blue := WP1.RGB.Blue + Trunc((WP2.RGB.Blue - WP1.RGB.Blue) * Factor);
      Color.Alpha := 0;

      Canvas.Pen.Color := Color.Color;
      Canvas.MoveTo(StartX, y);
      Canvas.LineTo(EndX,   y);
    end;

    if EndY > CurrentY then begin
      Break;
    end;
    Canvas.Pen.Color := WP2.RGB.Color;
    Canvas.MoveTo(StartX, EndY);
    Canvas.LineTo(EndX,   EndY);
  end;

  if Now < FStopTime then begin
    Box.Top := Min(EndY, CurrentY) + 1;
    Box.Bottom := Self.ClientHeight;
    Box.Left := 0;
    Box.Right := Self.ClientWidth;
    Canvas.Brush.Color := clBtnFace;
    Canvas.FillRect(Box);
  end;

  if (FLunchStop > FLunchStart) then begin
    LunchBox.Top := Trunc(Self.ClientHeight * (FLunchStart - BeginTime) / Duration);
    LunchBox.Bottom := Trunc(Self.ClientHeight * (FLunchStop - BeginTime) / Duration);
    LunchBox.Left := 2;
    LunchBox.Right := Self.ClientWidth - 2;
    Canvas.Brush.Color := clInfoBk;
    Canvas.FillRect(LunchBox);
  end;
  
  Canvas.Pen.Color := clBlack;
  Canvas.Brush.Style := bsClear;

  // Label the hours
  Shadow.Alpha := 0;
  Hour := BeginTime;
  PrevY := -1;
  while Hour <= EndTime do begin
    Y := Trunc(Self.ClientHeight * (Hour - BeginTime) / Duration);
    if Y < CurrentY then begin
      Color.Color := Canvas.Pixels[StartX, Y];
    end else begin
      Color.Color := ColorToRGB(clBtnFace);
    end;
    Grey := (((Color.Red + Color.Green + Color.Blue) div 6) + 160) mod 256;
    Color.Red := Grey;
    Color.Green := Grey;
    Color.Blue := Grey;

    Grey := (((Color.Red + Color.Green + Color.Blue) div 6) + 224) mod 256;
    Shadow.Red := Grey;
    Shadow.Green := Grey;
    Shadow.Blue := Grey;

    Canvas.Pen.Color := Color.Color;
    Canvas.MoveTo(StartX, Y);
    Canvas.LineTo(EndX,   Y);

    Text := FormatDateTime('H:nn', Hour);
    if (Hour = FStopTime) and (Canvas.TextWidth(Text) > Self.ClientWidth) and (MinuteOf(Hour) >= 10) then begin
      Text := FormatDateTime('nn', Hour);
    end;
    Height := Canvas.TextHeight(Text);
    if (Height < Y) or ((Y + Height) > EndY) then begin
      TopY := Y - Height;
    end else begin
      TopY := Y;
    end;
    if TopY > PrevY then begin
      Canvas.Font.Color := Shadow.Color;
      Canvas.TextOut(StartX + 1, TopY + 1, Text);
      Canvas.Font.Color := Color.Color;
      Canvas.TextOut(StartX, TopY, Text);
      PrevY := TopY + Height;
    end;

    Hour := IncHour(Hour);

    if (Hour > EndTime) and (Now < FStopTime) and (IncMinute(Hour, -59) < FStopTime) then begin
      Hour := FStopTime;
    end;
  end;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.FormResize(Sender: TObject);
var
  EndTime, Duration: TDateTime;
  Fraction: Extended;
  Lunch: string;
begin
  if FStopTime > FStartTime then begin

    if Now > FStopTime then begin
      EndTime := Now;
    end else begin
      EndTime := FStopTime;
    end;
    Duration := EndTime - FStartTime;
    Fraction := (Now - FStartTime) / Duration;

    if (FLunchStop > FLunchStart) then begin
      Lunch := Format('Lunch: %s - %s'#13#10,
                      [FormatDateTime('H:nn', FLunchStart),  FormatDateTime('H:nn', FLunchStop)]);
    end else begin
      Lunch := '';
    end;
    Self.Hint := Format('%s'#13#10'%s - %s'#13#10'%s'#13#10'%s (%.0f%%)'#13#10#13#10'%s done'#13#10'%s left',
                        [FormatDateTime('dddddd', Now),
                         FormatDateTime('HH:nn', FStartTime), FormatDateTime('HH:nn', FStopTime),
                         Lunch,
                         FormatDateTime('H:nn', Now), Fraction * 100,
                         FormatDateTime('H:nn', Now - FStartTime),
                         FormatDateTime('H:nn', FStopTime - Now) ]);

  end else begin
    Self.Hint := Format('%s'#13#10'%s',
                        [FormatDateTime('dddddd', Now), FormatDateTime('H:nn', Now) ]);
  end;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.miCloseClick(Sender: TObject);
begin
  Application.Terminate;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.miRefreshClick(Sender: TObject);
begin
  FetchHoursOnline;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.mnuOpacityClick(Sender: TObject);
var
  MenuItem: TMenuItem;
  i: Integer;
begin
  MenuItem := TMenuItem(Sender);
  Self.AlphaBlendValue := Trunc((MenuItem.Tag / 100) * 255);
  for i := 0 to MenuItem.Parent.Count - 1 do begin
    MenuItem.Parent.Items[i].Checked := (MenuItem.Parent.Items[i] = MenuItem);
  end;
  FSettings.WriteInteger('General', 'Opacity', MenuItem.Tag);
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.OnAppBarStateChange(Proposed: boolean; Edge: TAppBarEdge);
begin
  inherited;

  if Proposed then begin
    SaveSettings;
  end;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.tmrFetchTimesTimer(Sender: TObject);
begin
  TTimer(Sender).Enabled := False;
  try
    if trayIcon.Visible then trayIcon.Visible := False;
    try
      FetchHoursOnline;
    except
      on E: Exception do begin
        tmrFetchTimes.Interval := 60000; // try again in a minute or so
        trayIcon.BalloonHint := E.Message + #13#10'[' + E.ClassName + ']';
        trayIcon.Hint := Application.Title + ' - ' + E.Message;
        trayIcon.Visible := True;
        trayIcon.ShowBalloonHint;
      end;
    end;
  finally
    TTimer(Sender).Enabled := True;
  end;
end{TfrmMain.tmrFetchTimesTimer};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.tmrUpdateProgressTimer(Sender: TObject);
begin
  try
    FormResize(Self);
    Self.Invalidate;
  except
    on E: Exception do begin
      trayIcon.BalloonHint := E.Message + #13#10'[' + E.ClassName + ']';
      trayIcon.Hint := Application.Title + ' - ' + E.Message;
      trayIcon.Visible := True;
      trayIcon.ShowBalloonHint;
    end;
  end;
end{TfrmMain.tmrUpdateProgressTimer};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.FetchHoursOnline();
var
  URL: string;
  DateOffset: integer;
  QueryDate: TDate;
  HourQuery, LunchQuery: string;
  Start, Stop: string;
  { -------------------------------------------------------------------------------------------- }
  function FetchHours(Query: string; out Start, Stop: string): boolean;
  var
    Content: TMemoryStream;
    SA: TStreamAdapter;
    xmlDoc, xmlEntry: OleVariant;
  begin
    Result := False;
    Start := '';
    Stop := '';

    // Retrieve the HTTP content
    Content := TMemoryStream.Create;
    try
      httpClient.Get(URL + '&q=' + TIdURI.ParamsEncode(Query), Content);
      if httpClient.ResponseCode = 200 then begin
        Content.Position := 0;
        SA := TStreamAdapter.Create(Content, soReference);

        // Parse the XML stream
        xmlDoc := CreateOLEObject('MSXML2.DOMDocument.6.0');
        if not xmlDoc.load(SA as IStream) then begin
          raise Exception.Create('Unable to parse!'#13#10 + xmlDoc.parseError.reason);
        end;
        xmlDoc.setProperty('SelectionNamespaces', 'xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005"');

        // Extract the hours
        xmlEntry := xmlDoc.selectSingleNode('/atom:feed/atom:entry[atom:title="' + Query + '"]');
        if not (VarIsClear(xmlEntry) or VarIsNull(xmlEntry)) then begin
          Result := True;
          Start := xmlEntry.selectSingleNode('gd:when/@startTime').text;
          Stop := xmlEntry.selectSingleNode('gd:when/@endTime').text;
        end;
      end else begin
        raise EIdHTTPProtocolException.CreateError(httpClient.ResponseCode, httpClient.ResponseText, httpClient.ResponseText);
      end;
    finally
      Content.Free;
    end;
  end;
begin
  // Determine the events to look for
  HourQuery := FSettings.ReadString('Google Calendar', 'WorkingHours', '');
  LunchQuery := FSettings.ReadString('Google Calendar', 'LunchHours', '');

  // Determine the date
  DateOffset := FSettings.ReadInteger('Debug', 'DateOffset', 0);
  QueryDate := IncDay(Date, DateOffset);

  // Assemble the URL
  URL := Format('%s?singleevents=true&orderby=starttime&start-min=%s&start-max=%s',
              [FSettings.ReadString('Google Calendar', 'URL', ''),
               FormatDateTime('yyyy-MM-dd', QueryDate, XMLFS),
               FormatDateTime('yyyy-MM-dd', IncDay(QueryDate), XMLFS)]);

  // Get the work hours
  if FetchHours(HourQuery, Start, Stop) then begin
    FStartTime := DateTimeFromXML(Start);
    FStopTime := DateTimeFromXML(Stop);
  end else begin
    FStartTime := QueryDate;
    FStopTime := QueryDate + 1;
  end;
  if DateOffset <> 0 then begin
    FStartTime := IncDay(FStartTime, -DateOffset);
    FStopTime := IncDay(FStopTime, -DateOffset);
  end;

  // Get the lunch hours
  if (Length(LunchQuery) > 0) and FetchHours(LunchQuery, Start, Stop) then begin
    FLunchStart := DateTimeFromXML(Start);
    FLunchStop  := DateTimeFromXML(Stop);
  end else begin
    FLunchStart := QueryDate + 1;
    FLunchStop := QueryDate;
  end;
  if DateOffset <> 0 then begin
    FLunchStart := IncDay(FLunchStart, -DateOffset);
    FLunchStop := IncDay(FLunchStop, -DateOffset);
  end;

  // Display the new hours
  FormResize(Self);
  Self.Paint;

  // Schedule the next update
  if (Now > FStartTime) then begin
    tmrFetchTimes.Interval := 7200000; // once every 2 hours
  end else begin
    tmrFetchTimes.Interval := 1800000; // once every 30 minutes
  end;
end;

{ ------------------------------------------------------------------------------------------------ }
function TfrmMain.DateTimeFromXML(ISODateTime: string): TDateTime;
var
  CharPos: integer;
  Offset: TDateTime;
begin
  CharPos := Pos('+', ISODateTime);
  if CharPos > 0 then begin
    Offset := StrToTime(Copy(ISODateTime, CharPos + 1));
    ISODateTime := Copy(ISODateTime, 1, CharPos - 1);
  end else begin
    CharPos := Pos('-', ISODateTime);
    if CharPos > 0 then begin
      Offset := -StrToTime(Copy(ISODateTime, CharPos + 1));
      ISODateTime := Copy(ISODateTime, 1, CharPos - 1);
    end else begin
      Offset := 0;
    end;
  end;
  Result := StrToDateTime(StringReplace(ISODateTime, 'T', ' ', []), XMLFS);
  if Offset <> 0 then begin
    // TODO: correct for current time zone
  end;
end;


initialization
  XMLFS.DateSeparator := '-';
  XMLFS.TimeSeparator := ':';
  XMLFS.LongDateFormat := 'yyyy-MM-dd';
  XMLFS.ShortDateFormat := 'yyyy-MM-dd';
  XMLFS.LongTimeFormat := 'HH:nn:ss';
  XMLFS.ShortTimeFormat := 'HH:nn:ss';

finalization



end.

Added src/lib/AppBar.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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
{*****************************************************************************}
{                                                                             }
{ TAppBar Class v1.5                                                          }
{ implements Application Desktop Toolbar                                      }
{ (based on J.Richter's CAppBar MFC Class)                                    }
{                                                                             }
{ Copyright (c) 1997/98 Paolo Giacomuzzi                                      }
{ e-mail: paolo.giacomuzzi@usa.net                                            }
{ http://www.geocities.com/SiliconValley/9486                                 }
{                                                                             }
{ Adjusted for multiple monitors (Delphi 2006) by Martijn Coppoolse           }
{                                                                             }
{*****************************************************************************}


unit AppBar;


interface


uses
  Windows, Messages, SysUtils, Classes, Forms, Dialogs, Controls, ExtCtrls,
  ShellApi, Registry;


const
  // AppBar's user notification message
  WM_APPBARNOTIFY = WM_USER + 100;

  // Timer interval
  SLIDE_DEF_TIMER_INTERVAL = 400;  // milliseconds

  // Defaults
  AB_DEF_SIZE_INC  = 1;
  AB_DEF_DOCK_SIZE = 32;
  AB_DEF_ROOT_KEY: cardinal  = HKEY_CURRENT_USER;
  AB_DEF_KEY_NAME  = 'Software\AppBar\1.5\Delphi';


type
  // You can send to the Windows shell one of the following messages:
  // Message             Description
  // --------------      --------------------------------------------------
  // ABM_NEW             Register a new AppBar to the system
  // ABM_REMOVE          Remove a previously created AppBar from the system
  // ABM_QUERYPOS        Query the AppBar position
  // ABM_SETPOS          Set the AppBar position
  // ABM_GETSTATE        Get the edge the Appbar is docked to
  // ABM_GETTASKBARPOS   Get the Explorer Taskbar position
  // ABM_ACTIVATE        Activate the AppBar
  // ABM_GETAUTOHIDEBAR  Query if AppBar has Auto-hide behavior
  // ABM_SETAUTOHIDEBAR  Set the AppBar's Auto-hide behavior

  // The ABM_message constants are defined in SHELLAPI.PAS as follows:
  // ABM_NEW              = $00000000;
  // ABM_REMOVE           = $00000001;
  // ABM_QUERYPOS         = $00000002;
  // ABM_SETPOS           = $00000003;
  // ABM_GETSTATE         = $00000004;
  // ABM_GETTASKBARPOS    = $00000005;
  // ABM_ACTIVATE         = $00000006;
  // ABM_GETAUTOHIDEBAR   = $00000007;
  // ABM_SETAUTOHIDEBAR   = $00000008;
  // ABM_WINDOWPOSCHANGED = $00000009;

  // The following enumerated type defines the constants in the table
  TAppBarMessage = (abmNew, abmRemove, abmQueryPos, abmSetPos, abmGetState,
                    abmGetTaskBarPos, abmActivate, abmGetAutoHideBar,
                    abmSetAutoHideBar, abmWindowPosChanged);

  // An AppBar can be in one of 6 states shown in the table below:
  // State          Description
  // -----------    -----------------------------------------------------
  // ABE_UNKNOWN    The Appbar is in an unknown state
  //                (usually during construction/destruction)
  // ABE_FLOAT      The AppBar is floating on the screen
  // ABE_LEFT       The Appbar is docked on the left   edge of the screen
  // ABE_TOP        The Appbar is docked on the top    edge of the screen
  // ABE_RIGHT      The Appbar is docked on the right  edge of the screen
  // ABE_BOTTOM     The Appbar is docked on the bottom edge of the screen

  // The ABE_edge state constants are defined in SHELLAPI.PAS as follows:
  // ABE_LEFT    = 0;
  // ABE_TOP     = 1;
  // ABE_RIGHT   = 2;
  // ABE_BOTTOM  = 3;

  // The ABE_UNKNOWN and ABE_FLOAT constants are defined here as follows:
  // ABE_UNKNOWN = 4;
  // ABE_FLOAT   = 5;

  // The following enumerated type defines the constants in the table
  // (Values are mutually exclusive)
  TAppBarEdge = (abeLeft, abeTop, abeRight, abeBottom, abeUnknown, abeFloat);

  // An AppBar can have several behavior flags as shown below:
  // Flag                        Description
  // --------------------------- -----------------------------------
  // ABF_ALLOWLEFT               Allow dock on left   of screen
  // ABF_ALLOWRIGHT              Allow dock on right  of screen
  // ABF_ALLOWTOP                Allow dock on top    of screen
  // ABF_ALLOWBOTTOM             Allow dock on bottom of screen
  // ABF_ALLOWFLOAT              Allow float in the middle of screen

  // The following enumerated type defines the constants in the table
  TAppBarFlag = (abfAllowLeft, abfAllowTop, abfAllowRight, abfAllowBottom,
                 abfAllowFloat);
  TAppBarFlags = set of TAppBarFlag;

  // The following enumerated type defines the AppBar behavior in the Taskbar
  TAppBarTaskEntry = (abtShow, abtHide, abtFloatDependent);

  // The record below contains all of the AppBar settings that
  // can be saved/loaded in/from the Registry
  TAppBarSettings = record
    cbSize         : DWORD;        // Size of this structure
    abEdge         : TAppBarEdge;  // ABE_UNKNOWN, ABE_FLOAT, or ABE_edge
    abFlags        : TAppBarFlags; // ABF_* flags
    bAutohide      : Boolean;      // Should AppBar be auto-hidden when docked?
    bAlwaysOnTop   : Boolean;      // Should AppBar always be on top?
    bSlideEffect   : Boolean;      // Should AppBar slide?
    nTimerInterval : Integer;      // Slide Timer Interval (determines speed)
    szSizeInc      : TSize;        // Discrete width/height size increments
    szDockSize     : TSize;        // Width/Height for docked bar
    rcFloat        : TRect;        // Floating rectangle in screen coordinates
    nMinWidth      : Integer;      // Min allowed width
    nMinHeight     : Integer;      // Min allowed height
    nMaxWidth      : Integer;      // Max allowed width
    nMaxHeight     : Integer;      // Max allowed height
    szMinDockSize  : TSize;        // Min Width/Height when docked
    szMaxDockSize  : TSize;        // Max Width/Height when docked
    abTaskEntry    : TAppBarTaskEntry; // AppBar behavior in the Taskbar
//    nMonitorNum    : integer;      // Monitor to edge onto
  end;

  // The record below contains the settings location in the registry
  TAppBarSettingsLocation = record
    nRootKey : Cardinal;  // HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE
    KeyName  : String;   // Key Name starting from root
  end;

  // TAppBar class ////////////////////////////////////////////////////////////
  TAppBar = class(TForm)

  private

  { Internal implementation state variables }

    // This AppBar's settings info
    FABS : TAppBarSettings;

    // We need a member variable which tracks the proposed edge of the
    // AppBar while the user is moving it, deciding where to position it.
    // While not moving, this member must contain ABE_UNKNOWN so that
    // GetEdge returns the current edge contained in FABS.abEdge.
    // While moving the AppBar, FabEdgeProposedPrev contains the
    // proposed edge based on the position of the AppBar.  The proposed
    // edge becomes the new edge when the user stops moving the AppBar.
    FabEdgeProposedPrev : TAppBarEdge;

    // We need a member variable which tracks whether a full screen
    // application window is open
    FbFullScreenAppOpen : Boolean;

    // We need a member variable which tracks whether our autohide window
    // is visible or not
    FbAutoHideIsVisible : Boolean;

    // We need a timer to to determine when the AppBar should be re-hidden
    FTimer : TTimer;

    // We need a member variable to store the settings location in the registry
    FabSettingsLocation : TAppBarSettingsLocation;

  { Internal implementation functions }

    // These functions encapsulate the shell's SHAppBarMessage function
    function AppBarMessage (abMessage : TAppBarMessage;
                            abEdge    : TAppBarEdge;
                            lParam    : LPARAM;
                            bRect     : Boolean;
                            var rc    : TRect) : UINT;

    function AppBarMessage1 (abMessage : TAppBarMessage) : UINT;

    function AppBarMessage2 (abMessage : TAppBarMessage;
                             abEdge    : TAppBarEdge) : UINT;

    function AppBarMessage3 (abMessage : TAppBarMessage;
                             abEdge    : TAppBarEdge;
                             lParam    : LPARAM) : UINT;

    function AppBarMessage4 (abMessage : TAppBarMessage;
                             abEdge    : TAppBarEdge;
                             lParam    : LPARAM;
                             var rc    : TRect) : UINT;

    // Gets a edge (ABE_FLOAT or ABE_edge) from a point (screen coordinates)
    function CalcProposedState (var pt : TSmallPoint) : TAppBarEdge;

    // Gets a retangle position (screen coordinates) from a proposed state
    procedure GetRect (abEdgeProposed : TAppBarEdge; var rcProposed : TRect);

    // Adjusts the AppBar's location to account for autohide
    // Returns TRUE if rectangle was adjusted
    function AdjustLocationForAutohide (bShow  : Boolean;
                                        var rc : TRect) : Boolean;

    // If AppBar is Autohide and docked, shows/hides the AppBar
    procedure ShowHiddenAppBar (bShow : Boolean);

    // When Autohide AppBar is shown/hidden, slides in/out of view
    procedure SlideWindow (var rcEnd : TRect);

    // Returns which edge we're autohidden on or ABE_UNKNOWN
    function GetAutohideEdge : TAppBarEdge;

    // Returns a TSmallPoint that gives the cursor position in screen coords
    function GetMessagePosition : TSmallPoint;

    // Changes the style of a window (translated from AfxModifyStyle)
    function ModifyStyle (hWnd         : THandle;
                          nStyleOffset : Integer;
                          dwRemove     : DWORD;
                          dwAdd        : DWORD;
                          nFlags       : UINT) : Boolean;

  protected

    // Modifies window creation flags
    procedure CreateParams (var Params: TCreateParams); override;

  { Property selector functions }

    // Retrieves the AppBar's edge.  If the AppBar is being positioned, its
    // proposed state is returned instead
    function GetEdge : TAppBarEdge;

    // Changes the AppBar's edge to ABE_UNKNOWN, ABE_FLOAT or an ABE_edge
    procedure SetEdge (abEdge : TAppBarEdge);

    // Changes the slide time interval
    procedure SetSlideTime (nInterval : Integer);

  { Overridable functions }

    // Called when the AppBar's proposed state changes
    procedure OnAppBarStateChange (bProposed      : Boolean;
                                   abEdgeProposed : TAppBarEdge); virtual;

    // Called if user attempts to dock an Autohide AppBar on
    // an edge that already contains an Autohide AppBar
    procedure OnAppBarForcedToDocked; virtual;

    // Called when AppBar gets an ABN_FULLSCREENAPP notification
    procedure OnABNFullScreenApp (bOpen : Boolean); virtual;

    // Called when AppBar gets an ABN_POSCHANGED notification
    procedure OnABNPosChanged; virtual;

    // Called when AppBar gets an ABN_WINDOWARRANGE notification
    procedure OnABNWindowArrange (bBeginning : Boolean); virtual;

  { Message handlers }

    // Called when the AppBar receives a WM_APPBARNOTIFY window message
    procedure OnAppBarCallbackMsg(var Msg : TMessage); message WM_APPBARNOTIFY;

    // Called when the AppBar form is first created
    procedure OnCreate (var Msg: TWMCreate); message WM_CREATE;

    // Called when the AppBar form is about to be destroyed
    procedure OnDestroy (var Msg : TWMDestroy); message WM_DESTROY;

    // Called when the AppBar receives a WM_WINDOWPOSCHANGED message
    procedure OnWindowPosChanged (var Msg : TWMWindowPosChanged);
                                                   message WM_WINDOWPOSCHANGED;

    // Called when the AppBar receives a WM_ACTIVATE message
    procedure OnActivate (var Msg : TWMActivate); message WM_ACTIVATE;

    // Called every timer tick
    procedure OnAppBarTimer (Sender : TObject);

    // Called when the AppBar receives a WM_NCMOUSEMOVE message
    procedure OnNcMouseMove (var Msg : TWMNCMouseMove); message WM_NCMOUSEMOVE;

    // Called when the AppBar receives a WM_NCHITTEST message
    procedure OnNcHitTest (var Msg: TWMNCHitTest); message WM_NCHITTEST;

    // Called when the AppBar receives a WM_ENTERSIZEMOVE message
    procedure OnEnterSizeMove (var Msg : TMessage); message WM_ENTERSIZEMOVE;

    // Called when the AppBar receives a WM_EXITSIZEMOVE message
    procedure OnExitSizeMove (var Msg : TMessage); message WM_EXITSIZEMOVE;

    // Called when the AppBar receives a WM_MOVING message
    procedure OnMoving (var Msg : TMessage); message WM_MOVING;

    // Called when the AppBar receives a WM_SIZING message
    procedure OnSizing (var Msg : TMessage); message WM_SIZING;

    // Called when the AppBar receives a WM_GETMINMAXINFO message
    procedure OnGetMinMaxInfo (var Msg : TWMGetMinMaxInfo);
                                                      message WM_GETMINMAXINFO;

  { AppBar-specific helper functions }

    // Returns TRUE if abEdge is ABE_LEFT or ABE_RIGHT, else FALSE is returned
    function IsEdgeLeftOrRight (abEdge : TAppBarEdge) : Boolean;

    // Returns TRUE if abEdge is ABE_TOP or ABE_BOTTOM, else FALSE is returned
    function IsEdgeTopOrBottom (abEdge : TAppBarEdge) : Boolean;

    // Returns TRUE if abEdge is ABE_FLOAT, else FALSE is returned
    function IsFloating (abEdge : TAppBarEdge) : Boolean;

    // Returns TRUE if abFlags contain an at least allowed edge to dock on
    function IsDockable (abFlags : TAppBarFlags) : Boolean;

    // Returns TRUE if abFlags contain abfAllowLeft and abfAllowRight
    function IsDockableVertically (abFlags : TAppBarFlags) : Boolean;

    // Returns TRUE if abFlags contain abfAllowTop and abfAllowBottom
    function IsDockableHorizontally (abFlags : TAppBarFlags) : Boolean;

    // Forces the shell to update its AppBar list and the workspace area
    procedure ResetSystemKnowledge;

    // Returns a proposed edge or ABE_FLOAT based on ABF_* flags and a
    // point specified in screen coordinates
    function GetEdgeFromPoint (abFlags : TAppBarFlags;
                               pt      : TSmallPoint) : TAppBarEdge;

  public

  { Public member functions }

    // Constructs an AppBar
    constructor Create (Owner : TComponent); override;

    // Destroys a previously created AppBar
    destructor Destroy; override;

    // Forces the AppBar's visual appearance to match its internal state
    procedure UpdateBar; virtual;

    // Loads settings from the registry at RootKey and KeyName location.
    // Returns TRUE if the settings are available, else FALSE
    function LoadSettings : Boolean; virtual;

    // Saves settings into the registry at RootKey and KeyName location.
    // Returns TRUE if succeeded, else FALSE
    function SaveSettings : Boolean; virtual;

  published

  { Properties }

    // Allowed dockable edges
    property Flags : TAppBarFlags read FABS.abFlags write FABS.abFlags;

    // Horizontal size increment
    property HorzSizeInc : Integer read  FABS.szSizeInc.cx
                                   write FABS.szSizeInc.cx;
    // Vertical size increment
    property VertSizeInc : Integer read  FABS.szSizeInc.cy
                                   write FABS.szSizeInc.cy;
    // Edge to dock on
    property Edge : TAppBarEdge read GetEdge write SetEdge;

    // Auto-hide On/Off
    property AutoHide : Boolean read FABS.bAutohide write FABS.bAutohide;

    // Always On Top On/Off
    property AlwaysOnTop : Boolean read  FABS.bAlwaysOnTop
                                   write FABS.bAlwaysOnTop;
    // Slide Effect On/Off
    property SlideEffect : Boolean read  FABS.bSlideEffect
                                   write FABS.bSlideEffect;
    // Slide Time
    property SlideTime : Integer read FABS.nTimerInterval write SetSlideTime;

    // Horizontal size when docked on left or right
    property HorzDockSize : Integer read  FABS.szDockSize.cy
                                    write FABS.szDockSize.cy;

    // Vertical size when docked on top or bottom
    property VertDockSize : Integer read  FABS.szDockSize.cx
                                    write FABS.szDockSize.cx;

    // AppBar coordinates when floating
    property FloatLeft   : Integer read  FABS.rcFloat.Left
                                   write FABS.rcFloat.Left;
    property FloatTop    : Integer read  FABS.rcFloat.Top
                                   write FABS.rcFloat.Top;
    property FloatRight  : Integer read  FABS.rcFloat.Right
                                   write FABS.rcFloat.Right;
    property FloatBottom : Integer read  FABS.rcFloat.Bottom
                                   write FABS.rcFloat.Bottom;

    // AppBar MinMax dimensions when floating
    property MinWidth  : Integer read FABS.nMinWidth  write FABS.nMinWidth;
    property MinHeight : Integer read FABS.nMinHeight write FABS.nMinHeight;
    property MaxWidth  : Integer read FABS.nMaxWidth  write FABS.nMaxWidth;
    property MaxHeight : Integer read FABS.nMaxHeight write FABS.nMaxHeight;

    // Min Height when docked horizontally
    property MinHorzDockSize : Integer read  FABS.szMinDockSize.cy
                                       write FABS.szMinDockSize.cy;

    // Min Width when docked vertically
    property MinVertDockSize : Integer read  FABS.szMinDockSize.cx
                                       write FABS.szMinDockSize.cx;

    // Max Height when docked horizontally
    property MaxHorzDockSize : Integer read  FABS.szMaxDockSize.cy
                                       write FABS.szMaxDockSize.cy;

    // Max Width when docked vertically
    property MaxVertDockSize : Integer read  FABS.szMaxDockSize.cx
                                       write FABS.szMaxDockSize.cx;

    // AppBar behavior in the Window Taskbar
    property TaskEntry : TAppBarTaskEntry read  FABS.abTaskEntry
                                          write FABS.abTaskEntry;

    // RootKey in the registry where settings should be loaded/saved
    property RootKey : Cardinal read  FabSettingsLocation.nRootKey
                               write FabSettingsLocation.nRootKey;

    // KeyName in the registry where settings should be loaded/saved
    property KeyName : String read  FabSettingsLocation.KeyName
                              write FabSettingsLocation.KeyName;

  end;


implementation


{ Internal implementation functions }


// TAppBar.CreateParams ///////////////////////////////////////////////////////
procedure TAppBar.CreateParams (var Params: TCreateParams);
var
  dwAdd, dwRemove, dwAddEx, dwRemoveEx : DWORD;
begin
  // Call the inherited first
  inherited CreateParams(Params);

  // Styles to be added
  dwAdd := 0;
  dwAddEx := WS_EX_TOOLWINDOW;

  // Styles to be removed
  dwRemove := WS_SYSMENU or WS_MAXIMIZEBOX or WS_MINIMIZEBOX;
  dwRemoveEx := WS_EX_APPWINDOW;

  // Modify style flags
  with Params do begin
    Style := Style and (not dwRemove);
    Style := Style or dwAdd;
    ExStyle := ExStyle and (not dwRemoveEx);
    ExStyle := ExStyle or dwAddEx;
  end;
end;


// TAppBar.AppBarMessage //////////////////////////////////////////////////////
function TAppBar.AppBarMessage (abMessage : TAppBarMessage;
                                abEdge    : TAppBarEdge;
                                lParam    : LPARAM;
                                bRect     : Boolean;
                                var rc    : TRect) : UINT;
var
  abd : TAppBarData;
begin
  // Initialize an APPBARDATA structure
  abd.cbSize := sizeof(abd);
  abd.hWnd := Handle;
  abd.uCallbackMessage := WM_APPBARNOTIFY;
  abd.uEdge := Ord(abEdge);
  if bRect then
    abd.rc := rc
  else
    abd.rc := Rect(0, 0, 0, 0);
  abd.lParam := lParam;
  Result := SHAppBarMessage(Ord(abMessage), abd);

  // If the caller passed a rectangle, return the updated rectangle
  if bRect then
    rc := abd.rc;
end;


// TAppBar.AppBarMessage1 /////////////////////////////////////////////////////
function TAppBar.AppBarMessage1 (abMessage : TAppBarMessage) : UINT;
var
  rc : TRect;
begin
  Result := AppBarMessage(abMessage, abeFloat, 0, False, rc);
end;


// TAppBar.AppBarMessage2 /////////////////////////////////////////////////////
function TAppBar.AppBarMessage2 (abMessage : TAppBarMessage;
                                 abEdge    : TAppBarEdge) : UINT;
var
  rc : TRect;
begin
  Result := AppBarMessage(abMessage, abEdge, 0, False, rc);
end;


// TAppBar.AppBarMessage3 /////////////////////////////////////////////////////
function TAppBar.AppBarMessage3 (abMessage : TAppBarMessage;
                                 abEdge    : TAppBarEdge;
                                 lParam    : LPARAM) : UINT;
var
  rc : TRect;
begin
  Result := AppBarMessage(abMessage, abEdge, lParam, False, rc);
end;


// TAppBar.AppBarMessage4 /////////////////////////////////////////////////////
function TAppBar.AppBarMessage4 (abMessage : TAppBarMessage;
                                 abEdge    : TAppBarEdge;
                                 lParam    : LPARAM;
                                 var rc    : TRect) : UINT;
begin
  Result := AppBarMessage(abMessage, abEdge, lParam, True, rc);
end;


// TAppBar.CalcProposedState //////////////////////////////////////////////////
function TAppBar.CalcProposedState (var pt : TSmallPoint) : TAppBarEdge;
var
  bForceFloat : Boolean;
begin
  // Force the AppBar to float if the user is holding down the Ctrl key
  // and the AppBar's style allows floating
  bForceFloat := ((GetKeyState(VK_CONTROL) and $8000) <> 0) and
                 (abfAllowFloat in FABS.abFlags);
  if bForceFloat then
    Result := abeFloat
  else
    Result := GetEdgeFromPoint(FABS.abFlags, pt);
end;


// TAppBar.GetRect ////////////////////////////////////////////////////////////
procedure TAppBar.GetRect (abEdgeProposed : TAppBarEdge;
                           var rcProposed : TRect);
var
  Monitor: TMonitor;
begin
  // This function finds the x, y, cx, cy of the AppBar window
  if abEdgeProposed = abeFloat then begin
    // The AppBar is floating, the proposed rectangle is correct
  end else begin
    Monitor := Screen.MonitorFromWindow(Self.Handle);

    // The AppBar is docked or auto-hide
    // Set dimensions to full screen
//    with rcProposed do begin
//      Left   := 0;
//      Top    := 0;
//      Right  := GetSystemMetrics(SM_CXSCREEN);
//      Bottom := GetSystemMetrics(SM_CYSCREEN);
//    end;
    rcProposed := Monitor.BoundsRect;

    // Subtract off what we want from the full screen dimensions
    if not FABS.bAutohide then
      // Ask the shell where we can dock
      AppBarMessage4(abmQueryPos, abEdgeProposed, LPARAM(False), rcProposed);

    case abEdgeProposed of
      abeLeft:
        rcProposed.Right  := rcProposed.Left   + FABS.szDockSize.cx;
      abeTop:
        rcProposed.Bottom := rcProposed.Top    + FABS.szDockSize.cy;
      abeRight:
        rcProposed.Left   := rcProposed.Right  - FABS.szDockSize.cx;
      abeBottom:
        rcProposed.Top    := rcProposed.Bottom - FABS.szDockSize.cy;
    end; // end of case

  end; // end of else
end;


// TAppBar.AdjustLocationForAutohide //////////////////////////////////////////
function TAppBar.AdjustLocationForAutohide (bShow  : Boolean;
                                            var rc : TRect) : Boolean;
var
  x, y : Integer;
  cxVisibleBorder, cyVisibleBorder : Integer;
begin
  if ((GetEdge = abeUnknown) or (GetEdge = abeFloat) or
      (not FABS.bAutohide)) then begin
    // If we are not docked on an edge OR we are not auto-hidden, there is
    // nothing for us to do; just return
    Result := False;
    Exit;
  end;

  // Showing/hiding doesn't change our size; only our position
  x := 0; y := 0; // Assume a position of (0, 0)

  if bShow then
    // If we are on the right or bottom, calculate our visible position
    case GetEdge of
      abeRight:
        x := GetSystemMetrics(SM_CXSCREEN) - (rc.Right - rc.Left);
      abeBottom:
        y := GetSystemMetrics(SM_CYSCREEN) - (rc.Bottom - rc.Top);
    end
  else begin
    // Keep a part of the AppBar visible at all times
    cxVisibleBorder := 2 * GetSystemMetrics(SM_CXBORDER);
    cyVisibleBorder := 2 * GetSystemMetrics(SM_CYBORDER);

    // Calculate our x or y coordinate so that only the border is visible
    case GetEdge of
      abeLeft:
        x := -((rc.Right - rc.Left) - cxVisibleBorder);
      abeRight:
        x := GetSystemMetrics(SM_CXSCREEN) - cxVisibleBorder;
      abeTop:
        y := -((rc.Bottom - rc.Top) - cyVisibleBorder);
      abeBottom:
        y := GetSystemMetrics(SM_CYSCREEN) - cyVisibleBorder;
    end;
  end;

  with rc do begin
    Right  := x + (Right - Left);
    Bottom := y + (Bottom - Top);
    Left   := x;
    Top    := y;
  end;

  Result := True;
end;


// TAppBar.ShowHiddenAppBar ///////////////////////////////////////////////////
procedure TAppBar.ShowHiddenAppBar (bShow : Boolean);
var
  rc : TRect;
begin
  // Get our window location in screen coordinates
  GetWindowRect(Handle, rc);

  // Assume  that we are visible
  FbAutoHideIsVisible := True;

  if AdjustLocationForAutohide(bShow, rc) then begin
    // the rectangle was adjusted, we are an autohide bar
    // Remember whether we are visible or not
    FbAutoHideIsVisible := bShow;

    // Slide window in from or out to the edge
    SlideWindow(rc);
  end;
end;


// TAppBar.SlideWindow ////////////////////////////////////////////////////////
procedure TAppBar.SlideWindow (var rcEnd : TRect);
var
  bFullDragOn : LongBool;
  rcStart : TRect;
  dwTimeStart, dwTimeEnd, dwTime : DWORD;
  x, y, w, h : Integer;
begin
  // Only slide the window if the user has FullDrag turned on
  SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, @bFullDragOn, 0);

  // Get the current window position
  GetWindowRect(Handle, rcStart);
  if (FABS.bSlideEffect and bFullDragOn and
      ((rcStart.Left   <> rcEnd.Left  ) or
       (rcStart.Top    <> rcEnd.Top   ) or
       (rcStart.Right  <> rcEnd.Right ) or
       (rcStart.Bottom <> rcEnd.Bottom))) then begin

    // Get our starting and ending time
    dwTimeStart := GetTickCount;
    dwTimeEnd := dwTimeStart + Cardinal(FABS.nTimerInterval);
    dwTime := dwTimeStart;
    while (dwTime < dwTimeEnd) do begin
      // While we are still sliding, calculate our new position
      x := rcStart.Left - (rcStart.Left - rcEnd.Left)
           * Integer(dwTime - dwTimeStart) div FABS.nTimerInterval;

      y := rcStart.Top  - (rcStart.Top  - rcEnd.Top)
           * Integer(dwTime - dwTimeStart) div FABS.nTimerInterval;

      w := (rcStart.Right - rcStart.Left)
           - ((rcStart.Right - rcStart.Left) - (rcEnd.Right - rcEnd.Left))
           * Integer(dwTime - dwTimeStart) div FABS.nTimerInterval;

      h := (rcStart.Bottom - rcStart.Top)
           - ((rcStart.Bottom - rcStart.Top) - (rcEnd.Bottom - rcEnd.Top))
           * Integer(dwTime - dwTimeStart) div FABS.nTimerInterval;

      // Show the window at its changed position
      SetWindowPos(Handle, 0, x, y, w, h,
                   SWP_NOZORDER or SWP_NOACTIVATE or SWP_DRAWFRAME);
      UpdateWindow(Handle);
      dwTime := GetTickCount;
    end;
  end;

  // Make sure that the window is at its final position
  Left   := rcEnd.Left;
  Top    := rcEnd.Top;
  Width  := rcEnd.Right - rcEnd.Left;
  Height := rcEnd.Bottom - rcEnd.Top;
end;


// TAppBar.GetAutohideEdge ////////////////////////////////////////////////////
function TAppBar.GetAutohideEdge : TAppBarEdge;
begin
  if Handle = AppBarMessage2(abmGetAutoHideBar, abeLeft) then
    Result := abeLeft
  else if Handle = AppBarMessage2(abmGetAutoHideBar, abeTop) then
    Result := abeTop
  else if Handle = AppBarMessage2(abmGetAutoHideBar, abeRight) then
    Result := abeRight
  else if Handle = AppBarMessage2(abmGetAutoHideBar, abeBottom) then
    Result := abeBottom
  else
    // NOTE: If AppBar is docked but not auto-hidden, we return ABE_UNKNOWN
    Result := abeUnknown;
end;


// TAppBar.GetMessagePosition /////////////////////////////////////////////////
function TAppBar.GetMessagePosition : TSmallPoint;
var
  pt : TSmallPoint;
  dw : DWORD;
begin
  dw := GetMessagePos;
  pt.X := SHORT(dw);
  pt.Y := SHORT((dw and $FFFF0000) shr 16);
  Result := pt;
end;


// TAppBar.ModifyStyle ////////////////////////////////////////////////////////
function TAppBar.ModifyStyle (hWnd : THandle;
                              nStyleOffset : Integer;
                              dwRemove     : DWORD;
                              dwAdd        : DWORD;
                              nFlags       : UINT) : Boolean;
var
  dwStyle : DWORD;
  dwNewStyle : DWORD;
begin
  dwStyle := GetWindowLong(hWnd, nStyleOffset);
  dwNewStyle := (dwStyle and (not dwRemove)) or dwAdd;

  if dwStyle = dwNewStyle then begin
    Result := False;
    Exit;
  end;

  SetWindowLong(hWnd, nStyleOffset, dwNewStyle);

  if nFlags <> 0 then
    SetWindowPos(hWnd, 0, 0, 0, 0, 0,
      SWP_NOSIZE or SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE or nFlags);

  Result := True;
end;


{ Property selector functions }


// TAppBar.GetEdge ////////////////////////////////////////////////////////////
function TAppBar.GetEdge : TAppBarEdge;
begin
  if FabEdgeProposedPrev <> abeUnknown then
    Result := FabEdgeProposedPrev
  else
    Result := FABS.abEdge;
end;


// TAppBar.SetEdge ////////////////////////////////////////////////////////////
procedure TAppBar.SetEdge (abEdge : TAppBarEdge);
var
  abCurrentEdge : TAppBarEdge;
  currentRect : TRect;
  rc : TRect;
  hWnd : THandle;
begin
  // If the AppBar is registered as auto-hide, unregister it
  abCurrentEdge := GetAutohideEdge;

  if abCurrentEdge <> abeUnknown then
    // Our AppBar is auto-hidden, unregister it
    AppBarMessage3(abmSetAutoHideBar, abCurrentEdge, LPARAM(False));

  // Save the new requested state
  FABS.abEdge := abEdge;

  case abEdge of

    abeUnknown: begin
      // We are being completely unregistered.
      // Probably, the AppBar window is being destroyed.
      // If the AppBar is registered as NOT auto-hide, unregister it
      AppBarMessage1(abmRemove);
    end;

    abeFloat: begin
      // We are floating and therefore are just a regular window.
      // Tell the shell that the docked AppBar should be of 0x0 dimensions
      // so that the workspace is not affected by the AppBar
      currentRect := Rect(0, 0, 0, 0);
      AppBarMessage4(abmSetPos, abEdge, LPARAM(False), currentRect);
      Left   := FABS.rcFloat.Left;
      Top    := FABS.rcFloat.Top;
      Width  := FABS.rcFloat.Right - FABS.rcFloat.Left;
      Height := FABS.rcFloat.Bottom - FABS.rcFloat.Top;
    end;

    else begin
      if FABS.bAutohide and
         (AppBarMessage3(abmSetAutoHideBar,
                         GetEdge,
                         LPARAM(True)) = 0) then begin
        // We couldn't set the AppBar on a new edge, let's dock it instead
        FABS.bAutohide := False;
        // Call a virtual function to let derived classes know that the AppBar
        // changed from auto-hide to docked
        OnAppBarForcedToDocked;
      end;

      GetRect(GetEdge, rc);
      if FABS.bAutohide then begin
        currentRect := Rect(0, 0, 0, 0);
        AppBarMessage4(abmSetPos, abeLeft, LPARAM(False), currentRect);
      end else begin
        // Tell the shell where the AppBar is
        AppBarMessage4(abmSetPos, abEdge, LPARAM(False), rc);
      end;

      AdjustLocationForAutohide(FbAutoHideIsVisible, rc);

      // Slide window in from or out to the edge
      SlideWindow(rc);

    end; // end of else

  end; // end of case

  // Set the AppBar's z-order appropriately
  hWnd := HWND_NOTOPMOST; // Assume normal Z-Order
  if FABS.bAlwaysOnTop then begin
    // If we are supposed to be always-on-top, put us there
    hWnd := HWND_TOPMOST;
    if FbFullScreenAppOpen then
      // But, if a full-screen window is opened, put ourself at the bottom
      // of the z-order so that we don't cover the full-screen window
      hWnd := HWND_BOTTOM;
  end;
  SetWindowPos(Handle,
               hWnd,
               0, 0, 0, 0,
               SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);

  // Make sure that any auto-hide appbars stay on top of us after we move
  // even though our activation state has not changed
  AppBarMessage1(abmActivate);

  // Tell our derived class that there is a state change
  OnAppBarStateChange(False, abEdge);

  // Show or hide the taskbar entry depending on AppBar position
  case FABS.abTaskEntry of
    abtShow :
      ShowWindow(Application.Handle, SW_SHOW);
    abtHide :
      ShowWindow(Application.Handle, SW_HIDE);
    abtFloatDependent :
      case abEdge of
        abeFloat:
          ShowWindow(Application.Handle, SW_SHOW);
        abeLeft, abeTop, abeRight, abeBottom :
          ShowWindow(Application.Handle, SW_HIDE);
      end;
  end;
end;


// TAppBar.SetSlideTime ///////////////////////////////////////////////////////
procedure TAppBar.SetSlideTime (nInterval : Integer);
begin
  FABS.nTimerInterval := nInterval;
  FTimer.Interval := nInterval;
end;


{ Overridable functions }


// TAppBar.OnAppBarStateChange ////////////////////////////////////////////////
procedure TAppBar.OnAppBarStateChange (bProposed      : Boolean;
                                       abEdgeProposed : TAppBarEdge);
var
  bFullDragOn : LongBool;
begin
  // Find out if the user has FullDrag turned on
  SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, @bFullDragOn, 0);

  // If FullDrag is turned on OR the appbar has changed position
  if bFullDragOn or not bProposed then begin
    if abEdgeProposed = abeFloat then
      // Show the window adornments
      ModifyStyle(Handle,
                  GWL_STYLE,
                  0,
                  WS_CAPTION or WS_SYSMENU,
                  SWP_DRAWFRAME)
    else
      // Hide the window adornments
      ModifyStyle(Handle,
                  GWL_STYLE,
                  WS_CAPTION or WS_SYSMENU,
                  0,
                  SWP_DRAWFRAME);
  end;
end;


// TAppBar.OnAppBarForcedToDocked /////////////////////////////////////////////
procedure TAppBar.OnAppBarForcedToDocked;
const
  CRLF = #10#13;
begin
  // Display the application name as the message box caption text.
  MessageDlg('There is already an auto hidden window on this edge.' + CRLF +
             'Only one auto hidden window is allowed on each edge.',
             mtInformation,
             [mbOk],
             0);
end;

// TAppBar.OnABNFullScreenApp /////////////////////////////////////////////////
procedure TAppBar.OnABNFullScreenApp (bOpen : Boolean);
begin
  // This function is called when a FullScreen window is openning or
  // closing. A FullScreen window is a top-level window that has its caption
  // above the top of the screen allowing the entire screen to be occupied
  // by the window's client area.

  // If the AppBar is a topmost window when a FullScreen window is activated,
  // we need to change our window to a non-topmost window so that the AppBar
  // doesn't cover the FullScreen window's client area.

  // If the FullScreen window is closing, we need to set the AppBar's
  // Z-Order back to when the user wants it to be.
  FbFullScreenAppOpen := bOpen;
  UpdateBar;
end;


// TAppBar.OnABNPosChanged ////////////////////////////////////////////////////
procedure TAppBar.OnABNPosChanged;
begin
  // The TaskBar or another AppBar has changed its size or position
  if (GetEdge <> abeFloat) and (not FABS.bAutohide) then
    // If we're not floating and we're not auto-hidden, we have to
    // reposition our window
    UpdateBar;
end;


// TAppBar.OnABNWindowArrange /////////////////////////////////////////////////
procedure TAppBar.OnABNWindowArrange (bBeginning : Boolean);
begin
  // This function intentionally left blank
end;


{ Message handlers }


// TAppBar.OnAppBarCallbackMsg ////////////////////////////////////////////////
procedure TAppBar.OnAppBarCallbackMsg (var Msg : TMessage);
begin
  case Msg.WParam of

    ABN_FULLSCREENAPP:
      OnABNFullScreenApp(Msg.LParam <> 0);

    ABN_POSCHANGED:
      OnABNPosChanged;

    ABN_WINDOWARRANGE:
      OnABNWindowArrange(Msg.LParam <> 0);
  end;
end;


// TAppBar.OnCreate ///////////////////////////////////////////////////////////
procedure TAppBar.OnCreate (var Msg : TWMCreate);
var
  hMenu : THandle;
begin
  inherited;
  // Associate a timer with the AppBar.  The timer is used to determine
  // when a visible, inactive, auto-hide AppBar should be re-hidden
  FTimer := TTimer.Create(Self);
  with FTimer do begin
    Interval := FABS.nTimerInterval;
    OnTimer := OnAppBarTimer;
    Enabled := True;
  end;

  // Save the initial position of the floating AppBar
  FABS.rcFloat.Left   := Left;
  FABS.rcFloat.Top    := Top;

  // Register our AppBar window with the Shell
  AppBarMessage1(abmNew);

  // Update AppBar internal state
  UpdateBar;

  // Save the initial size of the floating AppBar
  PostMessage(Handle, WM_ENTERSIZEMOVE, 0, 0);
  PostMessage(Handle, WM_EXITSIZEMOVE,  0, 0);

  // Remove system menu
  hMenu := GetSystemMenu(Handle, False);
  DeleteMenu(hMenu, SC_RESTORE,  MF_BYCOMMAND);
  DeleteMenu(hMenu, SC_MINIMIZE, MF_BYCOMMAND);
  DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND);
end;


// TAppBar.OnDestroy //////////////////////////////////////////////////////////
procedure TAppBar.OnDestroy (var Msg : TWMDestroy);
begin
  // Free the Autohide timer
  FTimer.Enabled := False;
  FTimer.Free;
  // Unregister our AppBar window with the Shell
  SetEdge(abeUnknown);
  inherited;
end;


// TAppBar.OnWindowPosChanged /////////////////////////////////////////////////
procedure TAppBar.OnWindowPosChanged (var Msg : TWMWindowPosChanged);
begin
  inherited;
  // When our window changes position, tell the Shell so that any
  // auto-hidden AppBar on our edge stays on top of our window making it
  // always accessible to the user
  AppBarMessage1(abmWindowPosChanged);
end;


// TAppBar.OnActivate /////////////////////////////////////////////////////////
procedure TAppBar.OnActivate (var Msg : TWMActivate);
begin
  inherited;
  if Msg.Active = WA_INACTIVE then
    // Hide the AppBar if we are docked and auto-hidden
    ShowHiddenAppBar(False);
  // When our window changes position, tell the Shell so that any
  // auto-hidden AppBar on our edge stays on top of our window making it
  // always accessible to the user.
  AppBarMessage1(abmActivate);
end;


// TAppBar.OnAppBarTimer //////////////////////////////////////////////////////
procedure TAppBar.OnAppBarTimer (Sender : TObject);
var
  pt : TSmallPoint;
  rc : TRect;
begin
  if GetActiveWindow <> Handle then begin
    // Possibly hide the AppBar if we are not the active window
    // Get the position of the mouse and the AppBar's position
    // Everything must be in screen coordinates
    pt := GetMessagePosition;
    GetWindowRect(Handle, rc);
    // Add a little margin around the AppBar
    InflateRect(rc,
                2 * GetSystemMetrics(SM_CXDOUBLECLK),
                2 * GetSystemMetrics(SM_CYDOUBLECLK));
    if not PtInRect(rc, SmallPointToPoint(pt)) then
      // If the mouse is NOT over the AppBar, hide the AppBar
      ShowHiddenAppBar(False);
  end;
  inherited;
end;


// TAppBar.OnNcMouseMove //////////////////////////////////////////////////////
procedure TAppBar.OnNcMouseMove (var Msg : TWMNCMouseMove);
begin
  // If we are a docked, auto-hidden AppBar, shown us
  // when the user moves over our non-client area
  ShowHiddenAppBar(True);
  inherited;
end;


// TAppBar.OnNcHitTest ////////////////////////////////////////////////////////
procedure TAppBar.OnNcHitTest (var Msg: TWMNCHitTest);
var
  u : UINT;
  bPrimaryMouseBtnDown : Boolean;
  rcClient : TRect;
  pt : TPoint;
  vKey : Integer;
begin
  // Find out what the system thinks is the hit test code
  inherited;
  u := Msg.Result;

  // NOTE: If the user presses the secondary mouse button, pretend that the
  // user clicked on the client area so that we get WM_CONTEXTMENU messages
  if GetSystemMetrics(SM_SWAPBUTTON) <> 0 then
    vKey := VK_RBUTTON
  else
    vKey := VK_LBUTTON;
  bPrimaryMouseBtnDown := ((GetAsyncKeyState(vKey) and $8000) <> 0);

  pt.X := Msg.XPos;
  pt.Y := Msg.YPos;
  pt := ScreenToClient(pt);
  if (u = HTCLIENT) and bPrimaryMouseBtnDown
     and (ControlAtPos(pt, False) = nil) then
    // User clicked in client area, allow AppBar to move.  We get this
    // behavior by pretending that the user clicked on the caption area
    u := HTCAPTION;

  // If the AppBar is floating and the hittest code is a resize code...
  if ((GetEdge = abeFloat) and
      (HTSIZEFIRST <= u) and (u <= HTSIZELAST)) then begin
    case u of
      HTLEFT, HTRIGHT:
        if FABS.szSizeInc.cx = 0
          then u := HTBORDER;
      HTTOP, HTBOTTOM:
        if FABS.szSizeInc.cy = 0
          then u := HTBORDER;
      HTTOPLEFT:
        if (FABS.szSizeInc.cx = 0) and (FABS.szSizeInc.cy = 0)
          then u := HTBORDER
        else if (FABS.szSizeInc.cx = 0) and (FABS.szSizeInc.cy <> 0)
          then u := HTTOP
        else if (FABS.szSizeInc.cx <> 0) and (FABS.szSizeInc.cy = 0)
          then u := HTLEFT;
      HTTOPRIGHT:
        if (FABS.szSizeInc.cx = 0) and (FABS.szSizeInc.cy = 0)
          then u := HTBORDER
        else if (FABS.szSizeInc.cx = 0) and (FABS.szSizeInc.cy <> 0)
          then u := HTTOP
        else if (FABS.szSizeInc.cx <> 0) and (FABS.szSizeInc.cy = 0)
          then u := HTRIGHT;
      HTBOTTOMLEFT:
        if (FABS.szSizeInc.cx = 0) and (FABS.szSizeInc.cy = 0)
          then u := HTBORDER
        else if (FABS.szSizeInc.cx = 0) and (FABS.szSizeInc.cy <> 0)
          then u := HTBOTTOM
        else if (FABS.szSizeInc.cx <> 0) and (FABS.szSizeInc.cy = 0)
          then u := HTLEFT;
      HTBOTTOMRIGHT:
        if (FABS.szSizeInc.cx = 0) and (FABS.szSizeInc.cy = 0)
          then u := HTBORDER
        else if (FABS.szSizeInc.cx = 0) and (FABS.szSizeInc.cy <> 0)
          then u := HTBOTTOM
        else if (FABS.szSizeInc.cx <> 0) and (FABS.szSizeInc.cy = 0)
          then u := HTRIGHT;
    end;
  end;

  // When the AppBar is docked, the user can resize only one edge.
  // This next section determines which edge the user can resize.
  // To allow resizing, the AppBar window must have the WS_THICKFRAME style

  // If the AppBar is docked and the hittest code is a resize code...
  if ((GetEdge <> abeFloat) and (GetEdge <> abeUnknown) and
      (HTSIZEFIRST <= u) and (u <= HTSIZELAST)) then begin

    if (IsEdgeLeftOrRight(GetEdge) and (FABS.szSizeInc.cx = 0)) or
       (not IsEdgeLeftOrRight(GetEdge) and (FABS.szSizeInc.cy = 0)) then begin
      // If the width/height size increment is zero, then resizing is NOT
      // allowed for the edge that the AppBar is docked on
      u := HTBORDER; // Pretend that the mouse is not on a resize border
    end else begin
      // Resizing IS allowed for the edge that the AppBar is docked on
      // Get the location of the appbar's client area in screen coordinates
      rcClient := GetClientRect;
      pt.X := rcClient.Left;
      pt.Y := rcClient.Top;
      pt := ClientToScreen(pt);
      rcClient.Left := pt.X;
      rcClient.Top  := pt.Y;
      pt.X := rcClient.Right;
      pt.Y := rcClient.Bottom;
      pt := ClientToScreen(pt);
      rcClient.Right  := pt.X;
      rcClient.Bottom := pt.Y;

      u := HTBORDER;  // Assume that we can't resize
      case GetEdge of
        abeLeft:
          if Msg.XPos > rcClient.Right then
            u := HTRIGHT;
        abeTop:
          if Msg.YPos > rcClient.Bottom then
            u := HTBOTTOM;
        abeRight:
          if Msg.XPos < rcClient.Left then
            u := HTLEFT;
        abeBottom:
          if Msg.YPos < rcClient.Top then
            u := HTTOP;
      end; // end of case
    end; // end of else
  end;

  // Return the hittest code
  Msg.Result := u;
end;


// TAppBar.OnEnterSizeMove ////////////////////////////////////////////////////
procedure TAppBar.OnEnterSizeMove (var Msg : TMessage);
begin
  // The user started moving/resizing the AppBar, save its current state
  FabEdgeProposedPrev := GetEdge;
end;


// TAppBar.OnExitSizeMove /////////////////////////////////////////////////////
procedure TAppBar.OnExitSizeMove (var Msg : TMessage);
var
  abEdgeProposedPrev : TAppBarEdge;
  rc, rcWorkArea : TRect;
  w, h : Integer;
  Monitor: TMonitor;
begin
  // The user stopped moving/resizing the AppBar, set the new state
  // Save the new proposed state of the AppBar
  abEdgeProposedPrev := FabEdgeProposedPrev;

  // Set the proposed state back to unknown.  This causes GetState
  // to return the current state rather than the proposed state
  FabEdgeProposedPrev := abeUnknown;

  // Get the location of the window in screen coordinates
  GetWindowRect(Handle, rc);

  // If the AppBar's state has changed...
  if GetEdge = abEdgeProposedPrev then
    case GetEdge of
      abeLeft, abeRight:
        // Save the new width of the docked AppBar
        FABS.szDockSize.cx := rc.Right - rc.Left;
      abeTop, abeBottom:
        // Save the new height of the docked AppBar
        FABS.szDockSize.cy := rc.Bottom - rc.Top;
    end;

  // Always save the new position of the floating AppBar
  if abEdgeProposedPrev = abeFloat then begin
    // If AppBar was floating and keeps floating...
    if GetEdge = abeFloat then begin
      FABS.rcFloat := rc;
    // If AppBar was docked and is going to float...
    end else begin
      Monitor := Screen.MonitorFromRect(rc);

      // Propose width and height depending on the current window position
      w := rc.Right - rc.Left;
      h := rc.Bottom - rc.Top;
      // Adjust width and height
//      SystemParametersInfo(SPI_GETWORKAREA, 0, @rcWorkArea, 0);
      rcWorkArea := Monitor.WorkareaRect;
      if (w >= (rcWorkArea.Right - rcWorkArea.Left)) or
         (h >= (rcWorkArea.Bottom - rcWorkArea.Top)) then begin
        w := FABS.rcFloat.Right - FABS.rcFloat.Left;
        h := FABS.rcFloat.Bottom - FABS.rcFloat.Top;
      end;
      // Save new floating position
      FABS.rcFloat.Left   := rc.Left;
      FABS.rcFloat.Top    := rc.Top;
      FABS.rcFloat.Right  := rc.Left + w;
      FABS.rcFloat.Bottom := rc.Top + h;
    end;
  end;

  // After setting the dimensions, set the AppBar to the proposed state
  SetEdge(abEdgeProposedPrev);
end;


// TAppBar.OnMoving ///////////////////////////////////////////////////////////
procedure TAppBar.OnMoving (var Msg : TMessage);
var
  prc            : PRect;
  pt             : TSmallPoint;
  abEdgeProposed : TAppBarEdge;
  w, h           : Integer;
begin
  // We control the moving of the AppBar.  For example, if the mouse moves
  // close to an edge, we want to dock the AppBar
  // The lParam contains the window's position proposed by the system
  prc := PRect(Msg.LParam);

  // Get the location of the mouse cursor
  pt := GetMessagePosition;

  // Where should the AppBar be based on the mouse position?
  abEdgeProposed := CalcProposedState(pt);

  if ((FabEdgeProposedPrev <> abeFloat) and
      (abEdgeProposed = abeFloat)) then begin
    // While moving, the user took us from a docked/autohidden state to
    // the float state.  We have to calculate a rectangle location so that
    // the mouse cursor stays inside the window.
    prc^ := FABS.rcFloat;
    w := prc^.Right - prc^.Left;
    h := prc^.Bottom - prc^.Top;
    with prc^ do begin
      Left   := pt.X - w div 2;
      Top    := pt.Y;
      Right  := pt.X - w div 2 + w;
      Bottom := pt.Y + h;
    end;
  end;

  // Remember the most-recently proposed state
  FabEdgeProposedPrev := abEdgeProposed;

  // Tell the system where to move the window based on the proposed state
  GetRect(abEdgeProposed, prc^);

  // Tell our derived class that there is a proposed state change
  OnAppBarStateChange(True, abEdgeProposed);
end;


// TAppBar.OnSizing ///////////////////////////////////////////////////////////
procedure TAppBar.OnSizing (var Msg : TMessage);
var
  prc : PRect;
  rcBorder : TRect;
  nWidthNew, nHeightNew : Integer;
begin
  // We control the sizing of the AppBar.  For example, if the user re-sizes
  // an edge, we want to change the size in discrete increments.
  // The lParam contains the window's position proposed by the system
  prc := PRect(Msg.LParam);

  // Get the minimum allowed size of the window depending on current edge.
  // This is the width/height of the window that must always be present
  with FABS do
    case abEdge of
      abeFloat:
        rcBorder := Rect(0, 0, nMinWidth, nMinHeight);
      else
        rcBorder := Rect(0, 0, szMinDockSize.cx, szMinDockSize.cy);
    end;

  // We force the window to resize in discrete units set by the FABS.szSizeInc
  // member.  From the new, proposed window dimensions passed to us, round
  // the width/height to the nearest discrete unit
  if FABS.szSizeInc.cx <> 0 then
    nWidthNew  := ((prc^.Right - prc^.Left) - (rcBorder.Right - rcBorder.Left)
                   + FABS.szSizeInc.cx div 2) div FABS.szSizeInc.cx
                   * FABS.szSizeInc.cx + (rcBorder.Right - rcBorder.Left)
  else
    nWidthNew  := prc^.Right - prc^.Left;

  if FABS.szSizeInc.cy <> 0 then
    nHeightNew := ((prc^.Bottom - prc^.Top) - (rcBorder.Bottom - rcBorder.Top)
                   + FABS.szSizeInc.cy div 2) div FABS.szSizeInc.cy
                   * FABS.szSizeInc.cy + (rcBorder.Bottom - rcBorder.Top)
  else
    nHeightNew := prc^.Bottom - prc^.Top;

  // Adjust the rectangle's dimensions
  case Msg.wParam of
    WMSZ_LEFT:
      prc^.Left   := prc^.Right  - nWidthNew;

    WMSZ_TOP:
      prc^.Top    := prc^.Bottom - nHeightNew;

    WMSZ_RIGHT:
      prc^.Right  := prc^.Left   + nWidthNew;

    WMSZ_BOTTOM:
      prc^.Bottom := prc^.Top    + nHeightNew;

    WMSZ_BOTTOMLEFT: begin
      prc^.Bottom := prc^.Top    + nHeightNew;
      prc^.Left   := prc^.Right  - nWidthNew;
    end;

    WMSZ_BOTTOMRIGHT: begin
      prc^.Bottom := prc^.Top    + nHeightNew;
      prc^.Right  := prc^.Left   + nWidthNew;
    end;

    WMSZ_TOPLEFT: begin
      prc^.Left   := prc^.Right  - nWidthNew;
      prc^.Top    := prc^.Bottom - nHeightNew;
    end;

    WMSZ_TOPRIGHT: begin
      prc^.Top    := prc^.Bottom - nHeightNew;
      prc^.Right  := prc^.Left   + nWidthNew;
    end;
  end; // end of case
end;


// TAppBar.OnGetMinMaxInfo ////////////////////////////////////////////////////
procedure TAppBar.OnGetMinMaxInfo (var Msg : TWMGetMinMaxInfo);
begin
  if GetEdge = abeFloat then
    with Msg.MinMaxInfo^ do begin
      ptMinTrackSize.X := FABS.nMinWidth;
      ptMinTrackSize.Y := FABS.nMinHeight;
      ptMaxTrackSize.X := FABS.nMaxWidth;
      ptMaxTrackSize.Y := FABS.nMaxHeight;
    end
  else
    with Msg.MinMaxInfo^ do begin
      ptMinTrackSize.X := FABS.szMinDockSize.cx;
      ptMinTrackSize.Y := FABS.szMinDockSize.cy;
      ptMaxTrackSize.X := GetSystemMetrics(SM_CXSCREEN);
      ptMaxTrackSize.Y := GetSystemMetrics(SM_CYSCREEN);
      if not IsEdgeTopOrBottom(GetEdge) then
        ptMaxTrackSize.X := FABS.szMaxDockSize.cx;
      if not IsEdgeLeftOrRight(GetEdge) then
        ptMaxTrackSize.Y := FABS.szMaxDockSize.cy;
    end;
end;


{ AppBar-specific helper functions }


// TAppBar.IsEdgeLeftOrRight //////////////////////////////////////////////////
function TAppBar.IsEdgeLeftOrRight (abEdge : TAppBarEdge) : Boolean;
begin
  Result := (abEdge in [abeLeft, abeRight]);
end;


// TAppBar.IsEdgeTopOrBottom //////////////////////////////////////////////////
function TAppBar.IsEdgeTopOrBottom (abEdge : TAppBarEdge) : Boolean;
begin
  Result := (abEdge in [abeTop, abeBottom]);
end;


// TAppBar.IsFloating /////////////////////////////////////////////////////////
function TAppBar.IsFloating (abEdge : TAppBarEdge) : Boolean;
begin
  Result := (abEdge = abeFloat);
end;


// TAppBar.IsDockable /////////////////////////////////////////////////////////
function TAppBar.IsDockable (abFlags : TAppBarFlags) : Boolean;
begin
  Result := ((abFlags * [abfAllowLeft .. abfAllowBottom]) <> []);
end;


// TAppBar.IsDockableVertically ///////////////////////////////////////////////
function TAppBar.IsDockableVertically (abFlags : TAppBarFlags) : Boolean;
begin
  Result := ((abFlags * [abfAllowLeft, abfAllowRight]) <> []);
end;


// TAppBar.IsDockableHorizontally /////////////////////////////////////////////
function TAppBar.IsDockableHorizontally (abFlags : TAppBarFlags) : Boolean;
begin
  Result := ((abFlags * [abfAllowTop, abfAllowBottom]) <> []);
end;


// TAppBar.ResetSystemKnowledge ///////////////////////////////////////////////
procedure TAppBar.ResetSystemKnowledge;
{$ifdef DEBUG}
var
  abd : TAppBarData;
begin
  abd.cbSize := sizeof(abd);
  abd.hWnd := 0;
  SHAppBarMessage(ABM_REMOVE, abd);
end;
{$else}
begin
  // nothing to do when not in debug mode
end;
{$endif}


// TAppBar.GetEdgeFromPoint ///////////////////////////////////////////////////
function TAppBar.GetEdgeFromPoint (abFlags : TAppBarFlags;
                                   pt      : TSmallPoint) : TAppBarEdge;
var
  Monitor: TMonitor;
  rc             : TRect;
  cxScreen       : Integer;
  cyScreen       : Integer;
  ptCenter       : TSmallPoint;
  ptOffset       : TSmallPoint;
  bIsLeftOrRight : Boolean;
  abSubstEdge    : TAppBarEdge;
begin
  Monitor := Screen.MonitorFromPoint(SmallPointToPoint(pt));

  // Let's get floating out of the way first
  if abfAllowFloat in abFlags then begin

    // Get the rectangle that bounds the size of the screen
    // minus any docked (but not-autohidden) AppBars
    //SystemParametersInfo(SPI_GETWORKAREA, 0, @rc, 0);
    rc := Monitor.WorkareaRect;

    // Leave a 1/2 width/height-of-a-scrollbar gutter around the workarea
    InflateRect(rc,
                -GetSystemMetrics(SM_CXVSCROLL),
                -GetSystemMetrics(SM_CYHSCROLL));

    // If the point is in the adjusted workarea OR no edges are allowed
    if PtInRect(rc, SmallPointToPoint(pt)) or
       not IsDockable(abFlags) then begin
      // The AppBar should float
      Result := abeFloat;
      Exit;
    end;
  end;

  // If we get here, the AppBar should be docked; determine the proper edge
  // Get the dimensions of the screen
  cxScreen := Monitor.Width; //GetSystemMetrics(SM_CXSCREEN);
  cyScreen := Monitor.Height; // GetSystemMetrics(SM_CYSCREEN);

  // Find the center of the screen
  ptCenter.X := Monitor.Left + cxScreen div 2;
  ptCenter.Y := Monitor.Top + cyScreen div 2;

  // Find the distance from the point to the center
  ptOffset.X := pt.X - ptCenter.X;
  ptOffset.Y := pt.Y - ptCenter.Y;

  // Determine if the point is farther from the left/right or top/bottom
  bIsLeftOrRight :=
    ((Abs(ptOffset.Y) * cxScreen) <= (Abs(ptOffset.X) * cyScreen));

  // Propose an edge
  if bIsLeftOrRight then begin
    if 0 <= ptOffset.X then
      Result := abeRight
    else
      Result := abeLeft;
  end else begin
    if 0 <= ptOffset.Y then
      Result := abeBottom
    else
      Result := abeTop;
  end;

  // Calculate an edge substitute
  if abfAllowFloat in abFlags then
    abSubstEdge := abeFloat
  else
    abSubstEdge := FABS.abEdge;

  // Check if the proposed edge is allowed. If not, return the edge substitute
  case Result of
    abeLeft  : if not (abfAllowLeft   in abFlags) then Result := abSubstEdge;
    abeTop   : if not (abfAllowTop    in abFlags) then Result := abSubstEdge;
    abeRight : if not (abfAllowRight  in abFlags) then Result := abSubstEdge;
    abeBottom: if not (abfAllowBottom in abFlags) then Result := abSubstEdge;
  end;

end;


{ Public member functions }


// TAppBar.Create /////////////////////////////////////////////////////////////
constructor TAppBar.Create (Owner : TComponent);
begin
  // Force the shell to update its list of AppBars and the workarea.
  // This is a precaution and is very useful when debugging.  If you create
  // an AppBar and then just terminate the application, the shell still
  // thinks that the AppBar exists and the user's workarea is smaller than
  // it should be.  When a new AppBar is created, calling this function
  // fixes the user's workarea.
  ResetSystemKnowledge;

  // Set default state of AppBar to float with no width & height
  FABS.cbSize            := sizeof(TAppBarSettings);
  FABS.abEdge            := abeFloat;
  FABS.abFlags           := [abfAllowLeft .. abfAllowFloat];
  FABS.bAutohide         := False;
  FABS.bAlwaysOnTop      := True;
  FABS.bSlideEffect      := True;
  FABS.nTimerInterval    := SLIDE_DEF_TIMER_INTERVAL;
  FABS.szSizeInc.cx      := AB_DEF_SIZE_INC;
  FABS.szSizeInc.cy      := AB_DEF_SIZE_INC;
  FABS.szDockSize.cx     := AB_DEF_DOCK_SIZE;
  FABS.szDockSize.cy     := AB_DEF_DOCK_SIZE;
  FABS.rcFloat.Left      := 0;
  FABS.rcFloat.Top       := 0;
  FABS.rcFloat.Right     := 0;
  FABS.rcFloat.Bottom    := 0;
  FABS.nMinWidth         := 0;
  FABS.nMinHeight        := 0;
  FABS.nMaxWidth         := GetSystemMetrics(SM_CXSCREEN);
  FABS.nMaxHeight        := GetSystemMetrics(SM_CYSCREEN);
  FABS.szMinDockSize.cx  := 0;
  FABS.szMinDockSize.cy  := 0;
  FABS.szMaxDockSize.cx  := GetSystemMetrics(SM_CXSCREEN) div 2;
  FABS.szMaxDockSize.cy  := GetSystemMetrics(SM_CYSCREEN) div 2;
  FABS.abTaskEntry       := abtFloatDependent;
  FabEdgeProposedPrev    := abeUnknown;
  FbFullScreenAppOpen    := False;
  FbAutoHideIsVisible    := False;

  // Set default location of the settings in the registry
  with FabSettingsLocation do begin
    RootKey := AB_DEF_ROOT_KEY;
    KeyName := AB_DEF_KEY_NAME;
  end;

  // Call base class
  inherited Create(Owner);
end;


// TAppBar.Destroy ////////////////////////////////////////////////////////////
destructor TAppBar.Destroy;
begin
  ResetSystemKnowledge;

  // Call base class
  inherited Destroy;
end;


// TAppBar.UpdateBar //////////////////////////////////////////////////////////
procedure TAppBar.UpdateBar;
begin
  SetEdge(GetEdge);
end;

// TAppBar.LoadSettings ///////////////////////////////////////////////////////
function TAppBar.LoadSettings : Boolean;
var
  reg : TRegistry;
  abs : TAppBarSettings;
begin
  // Set the default return value
  Result := False;
  // Create a TRegistry object
  reg := TRegistry.Create;
  // Set the RootKey
  reg.RootKey := FabSettingsLocation.nRootKey;
  // Open the KeyName
  if reg.OpenKey(FabSettingsLocation.KeyName, False) then
    // Load the FABS record from the 'default' value
    if reg.ReadBinaryData('', abs, sizeof(abs)) = sizeof(abs) then begin
      FABS := abs;
      Result := True;
    end;
  // Free the TRegistry object
  reg.Destroy
end;

// TAppBar.SaveSettings ///////////////////////////////////////////////////////
function TAppBar.SaveSettings : Boolean;
var
  reg : TRegistry;
begin
  // Set the default return value
  Result := False;
  // Create a TRegistry object
  reg := TRegistry.Create;
  // Set the RootKey
  reg.RootKey := FabSettingsLocation.nRootKey;
  // Open the KeyName, creating it if not exists
  if reg.OpenKey(FabSettingsLocation.KeyName, True) then begin
    // Save the FABS record in the 'default' value
    reg.WriteBinaryData('', FABS, sizeof(FABS));
    Result := True;
  end;
  // Free the TRegistry object
  reg.Destroy
end;

end.

Added src/lib/CheckPrevious.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
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
unit CheckPrevious;
{
********************************************
Zarko Gajic
About.com Guide to Delphi Programming
http://delphi.about.com
email: delphi.guide@about.com
free newsletter: http://delphi.about.com/library/blnewsletter.htm
forum: http://forums.about.com/ab-delphi/start/
********************************************
}
interface
uses Windows, SysUtils;

function RestoreIfRunning(
                const AppHandle : THandle;
                MaxInstances : integer = 1) : boolean;

implementation
uses
  L_VersionInfoW;

type
  PInstanceInfo = ^TInstanceInfo;
  TInstanceInfo = packed record
    PreviousHandle : THandle;
    RunCounter : integer;
  end;

var
  MappingHandle: THandle;
  InstanceInfo: PInstanceInfo;
  MappingName : string;

  RemoveMe : boolean = True;

{ ------------------------------------------------------------------------------------------------ }
function RestoreIfRunning(
             const AppHandle : THandle;
             MaxInstances : integer = 1) : boolean;
var
  FWI: FLASHWINFO;
  FVI: TFileVersionInfo;
begin
  Result := True;

  FVI := TFileVersionInfo.Create(ParamStr(0));
  try
    if FVI.HasVersionInfo then begin
      MappingName := Format('%s_%s_%s_V%d.%d',
                            [FVI.CompanyName, FVI.ProductName, FVI.Internalname,
                             FVI.MajorVersion, FVI.MinorVersion]);
    end else begin
      MappingName := StringReplace(ParamStr(0),
                                   '\','',
                                   [rfReplaceAll, rfIgnoreCase]);
    end;
  finally
    FVI.Free;
  end;

  MappingHandle := CreateFileMapping($FFFFFFFF,
                                     nil,
                                     PAGE_READWRITE,
                                     0,
                                     SizeOf(TInstanceInfo),
                                     PChar(MappingName));

  if MappingHandle = 0 then
    RaiseLastOSError
  else
  begin
    if GetLastError <> ERROR_ALREADY_EXISTS then
    begin
      InstanceInfo := MapViewOfFile(MappingHandle,
                                    FILE_MAP_ALL_ACCESS,
                                    0,
                                    0,
                                    SizeOf(TInstanceInfo));

      InstanceInfo^.PreviousHandle := AppHandle;
      InstanceInfo^.RunCounter := 1;

      Result := False;
    end
    else //already runing
    begin
      MappingHandle := OpenFileMapping(
                                FILE_MAP_ALL_ACCESS, 
                                False, 
                                PChar(MappingName));
      if MappingHandle <> 0 then
      begin
        InstanceInfo := MapViewOfFile(MappingHandle,
                                      FILE_MAP_ALL_ACCESS,
                                      0,
                                      0,
                                      SizeOf(TInstanceInfo));

        if InstanceInfo^.RunCounter >= MaxInstances then
        begin
          RemoveMe := False;

          if IsIconic(InstanceInfo^.PreviousHandle) then
            ShowWindow(InstanceInfo^.PreviousHandle, SW_RESTORE);
          if not SetForegroundWindow(InstanceInfo^.PreviousHandle) then begin
            FWI.cbSize := sizeof(FWI);
            FWI.hwnd := InstanceInfo^.PreviousHandle;
            FWI.dwFlags := FLASHW_ALL;
            FWI.uCount := 5;
            FWI.dwTimeout := 125;
            FlashWindowEx(FWI);
          end;
        end
        else
        begin
          InstanceInfo^.PreviousHandle := AppHandle;
          InstanceInfo^.RunCounter := 1 + InstanceInfo^.RunCounter;

          Result := False;
        end
      end;
    end;
  end;
end; (*RestoreIfRunning*)

initialization
//nothing special here
//we need this section because we have the
//finalization section

finalization
  //remove this instance
  if RemoveMe then
  begin
    MappingHandle := OpenFileMapping(
                        FILE_MAP_ALL_ACCESS, 
                        False, 
                        PChar(MappingName));
    if MappingHandle <> 0 then
    begin
      InstanceInfo := MapViewOfFile(MappingHandle,
                                  FILE_MAP_ALL_ACCESS,
                                  0,
                                  0,
                                  SizeOf(TInstanceInfo));

      InstanceInfo^.RunCounter := -1 + InstanceInfo^.RunCounter;
    end
    else
      RaiseLastOSError;
  end;

  if Assigned(InstanceInfo) then UnmapViewOfFile(InstanceInfo);
  if MappingHandle <> 0 then CloseHandle(MappingHandle);

end(*unit CheckPrevious*). 



Added src/lib/L_VersionInfoW.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
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
unit L_VersionInfoW;

interface

uses
  Windows, SysUtils;

type
  TFileVersionInfo = class
  private
    { Private declarations }
    FFilename         : WideString;
    FHasVersionInfo   : boolean;

    FCompanyName      : WideString;
    FFileDescription  : WideString;
    FFileVersion      : WideString;
    FInternalname     : WideString;
    FLegalCopyright   : WideString;
    FLegalTradeMarks  : WideString;
    FOriginalFilename : WideString;
    FProductName      : WideString;
    FProductVersion   : WideString;
    FComments         : WideString;
    FMajorVersion     : Word;
    FMinorVersion     : Word;
    FRevision          : Word;
    FBuild            : Word;

    procedure SetFileName(AFileName: WideString);
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AFileName: WideString);
    destructor  Destroy; override;

    property FileName         : WideString  read FFileName          write SetFileName;
    property HasVersionInfo   : boolean     read FHasVersionInfo;
  published
    { Published declarations }
    property CompanyName      : WideString  read FCompanyName;
    property FileDescription  : WideString  read FFileDescription;
    property FileVersion      : WideString  read FFileVersion;
    property Internalname     : WideString  read FInternalname;
    property LegalCopyright   : WideString  read FLegalCopyright;
    property LegalTradeMarks  : WideString  read FLegalTradeMarks;
    property OriginalFilename : WideString  read FOriginalFilename;
    property ProductName      : WideString  read FProductName;
    property ProductVersion   : WideString  read FProductVersion;
    property Comments         : WideString  read FComments;
    property MajorVersion     : Word        read FMajorVersion;
    property MinorVersion     : Word        read FMinorVersion;
    property Revision         : Word        read FRevision;
    property Build            : Word        read FBuild;
  end;

implementation

type
  TLangAndCP = record
    wLanguage : word;
    wCodePage : word;
  end;
  PLangAndCP = ^TLangAndCP;

constructor TFileVersionInfo.Create(AFileName: WideString);
begin
  inherited Create;
  SetFileName(AFileName);
end;

destructor TFileVersionInfo.Destroy;
begin
  inherited Destroy;
end;

procedure TFileVersionInfo.SetFileName(AFileName: WideString);
var
  Dummy     : cardinal;
  BufferSize: integer;
  Buffer    : Pointer;
  Lang      : PLangAndCP;
  SubBlock  : WideString;
  InfoBlock : VS_FIXEDFILEINFO;
  InfoPtr   : Pointer;
  function QueryValue(AName: WideString): WideString;
  var
    Value   : PWChar;
  begin
    SubBlock := WideFormat('\\StringFileInfo\\%.4x%.4x\\%s', [Lang.wLanguage, Lang.wCodePage, AName]);
    VerQueryValueW(Buffer, PWChar(SubBlock), Pointer(Value), Dummy);
    Result := WideString(Value);
  end;
begin
  FFilename := AFileName;

  BufferSize := GetFileVersionInfoSizeW(PWChar(AFileName), Dummy);
  FHasVersionInfo := (Buffersize > 0);
  if FHasVersionInfo then begin
    Buffer := AllocMem(BufferSize);
    try
      GetFileVersionInfoW(PWChar(AFileName),0,BufferSize,Buffer);

      SubBlock := '\\VarFileInfo\\Translation';
      VerQueryValueW(Buffer, PWChar(SubBlock), Pointer(Lang), Dummy);

      FCompanyName      := QueryValue('CompanyName');
      FFileDescription  := QueryValue('FileDescription');
      FFileVersion      := QueryValue('FileVersion');
      FInternalName     := QueryValue('InternalName');
      FLegalCopyright   := QueryValue('LegalCopyright');
      FLegalTradeMarks  := QueryValue('LegalTradeMarks');
      FOriginalFilename := QueryValue('OriginalFilename');
      FProductName      := QueryValue('ProductName');
      FProductVersion   := QueryValue('ProductVersion');
      FComments         := QueryValue('Comments');

      VerQueryValue(Buffer, '\', InfoPtr, Dummy);
      Move(InfoPtr^, InfoBlock, SizeOf(VS_FIXEDFILEINFO));
      FMajorVersion := InfoBlock.dwFileVersionMS shr 16;
      FMinorVersion := InfoBlock.dwFileVersionMS and 65535;
      FRevision     := InfoBlock.dwFileVersionLS shr 16;
      FBuild        := InfoBlock.dwFileVersionLS and 65535;
    finally
      FreeMem(Buffer,BufferSize);
    end;
  end
  else begin
    FCompanyname      := '';
    FFileDescription  := '';
    FFileVersion      := '';
    FInternalname     := '';
    FLegalCopyright   := '';
    FLegalTradeMarks  := '';
    FOriginalFilename := '';
    FProductName      := '';
    FProductVersion   := '';
    FComments         := '';
    FMajorVersion     := 0;
    FMinorVersion     := 0;
    FRevision         := 0;
    FBuild            := 0;
  end;
end;


end.

Added src/prj/d2009/TempusFugit.cfg.

























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
-$A8
-$B-
-$C+
-$D+
-$E-
-$F-
-$G+
-$H+
-$I+
-$J-
-$K-
-$L+
-$M-
-$N+
-$O-
-$P+
-$Q+
-$R+
-$S-
-$T-
-$U-
-$V+
-$W-
-$X+
-$Y+
-$Z1
-cg
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-H+
-W+
-M
-$M16384,1048576
-K$00400000
-E"..\Out"
-N0"..\Out\DCU"
-LE"C:\Program Files\Prog\Borland\BDS\4.0\Bin"
-LN"F:\MM\Code\Projects\Borland\Bpl"
-U"..\Src;W:\Lib"
-O"..\Src;W:\Lib"
-I"..\Src;W:\Lib"
-R"..\Src;W:\Lib"
-w-UNSAFE_TYPE
-w-UNSAFE_CODE
-w-UNSAFE_CAST

Added src/prj/d2009/TempusFugit.dpr.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
program TempusFugit;

uses
  Forms, Windows,
  F_Main {frmMain},
  AppBar,
  CheckPrevious;

{$R *.res}

begin
  if not CheckPrevious.RestoreIfRunning(Application.Handle) then begin
    ShowWindow(Application.Handle, SW_HIDE);
    SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);
    Application.Initialize;
    Application.Title := 'Tempus Fugit';
    Application.CreateForm(TfrmMain, frmMain);
    ShowWindow(Application.Handle, SW_SHOW);
    Application.Run;
  end;
end.

Added src/prj/d2009/TempusFugit.dproj.

















































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
		<PropertyGroup>
			<ProjectGuid>{6D193C34-4617-40F0-A1F0-F4ABDB7FFD3B}</ProjectGuid>
			<MainSource>TempusFugit.dpr</MainSource>
			<Config Condition="'$(Config)'==''">Debug</Config>
			<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
			<ProjectVersion>12.0</ProjectVersion>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
			<Base>true</Base>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
			<Cfg_1>true</Cfg_1>
			<CfgParent>Base</CfgParent>
			<Base>true</Base>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
			<Cfg_2>true</Cfg_2>
			<CfgParent>Base</CfgParent>
			<Base>true</Base>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Base)'!=''">
			<DCC_DependencyCheckOutputName>..\..\..\out\TempusFugit.exe</DCC_DependencyCheckOutputName>
			<DCC_UnitSearchPath>..\..;..\..\Lib;W:\Lib;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
			<DCC_UsePackage>vcl;rtl;vclx;dbrtl;vcldb;adortl;xmlrtl;vclactnband;inet;vclie;inetdbbde;inetdbxpress;IndyCore;IndySystem;dclOfficeXP;VclSmp;soaprtl;dsnap;IndyProtocols;bdertl;teeui;teedb;tee;vcldbx;TMSD2006;Scit;DL_Geo_100;DL_Base_100;S303_r100;B305_r100;DL_Control_100;DL_GDI_100;RaizeComponentsVcl</DCC_UsePackage>
			<DCC_ImageBase>00400000</DCC_ImageBase>
			<DCC_RangeChecking>true</DCC_RangeChecking>
			<DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;$(DCC_UnitAlias)</DCC_UnitAlias>
			<DCC_ExeOutput>..\..\..\out\</DCC_ExeOutput>
			<DCC_Platform>x86</DCC_Platform>
			<DCC_K>false</DCC_K>
			<DCC_F>false</DCC_F>
			<DCC_S>false</DCC_S>
			<DCC_N>true</DCC_N>
			<DCC_DcuOutput>..\..\..\out\DCU\</DCC_DcuOutput>
			<DebugSourcePath>W:\Lib\Src\;$(DebugSourcePath)</DebugSourcePath>
			<DCC_E>false</DCC_E>
			<DCC_IntegerOverflowCheck>true</DCC_IntegerOverflowCheck>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Cfg_1)'!=''">
			<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
			<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
			<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
			<DCC_DebugInformation>false</DCC_DebugInformation>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Cfg_2)'!=''">
			<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
			<DCC_OutputDependencies>true</DCC_OutputDependencies>
			<DCC_Optimize>false</DCC_Optimize>
			<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
			<DCC_RunTimeTypeInfo>true</DCC_RunTimeTypeInfo>
		</PropertyGroup>
		<ItemGroup>
			<DelphiCompile Include="TempusFugit.dpr">
				<MainSource>MainSource</MainSource>
			</DelphiCompile>
			<BuildConfiguration Include="Base">
				<Key>Base</Key>
			</BuildConfiguration>
			<BuildConfiguration Include="Debug">
				<Key>Cfg_2</Key>
				<CfgParent>Base</CfgParent>
			</BuildConfiguration>
			<BuildConfiguration Include="Release">
				<Key>Cfg_1</Key>
				<CfgParent>Base</CfgParent>
			</BuildConfiguration>
		</ItemGroup>
		<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
		<ProjectExtensions>
			<Borland.Personality>Delphi.Personality.12</Borland.Personality>
			<Borland.ProjectType/>
			<BorlandProject>
				<Delphi.Personality>
					<Source>
						<Source Name="MainSource">TempusFugit.dpr</Source>
					</Source>
					<Parameters>
						<Parameters Name="UseLauncher">False</Parameters>
						<Parameters Name="LoadAllSymbols">True</Parameters>
						<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
					</Parameters>
					<VersionInfo>
						<VersionInfo Name="IncludeVerInfo">True</VersionInfo>
						<VersionInfo Name="AutoIncBuild">True</VersionInfo>
						<VersionInfo Name="MajorVer">1</VersionInfo>
						<VersionInfo Name="MinorVer">0</VersionInfo>
						<VersionInfo Name="Release">0</VersionInfo>
						<VersionInfo Name="Build">6</VersionInfo>
						<VersionInfo Name="Debug">True</VersionInfo>
						<VersionInfo Name="PreRelease">False</VersionInfo>
						<VersionInfo Name="Special">False</VersionInfo>
						<VersionInfo Name="Private">False</VersionInfo>
						<VersionInfo Name="DLL">False</VersionInfo>
						<VersionInfo Name="Locale">1043</VersionInfo>
						<VersionInfo Name="CodePage">1252</VersionInfo>
					</VersionInfo>
					<VersionInfoKeys>
						<VersionInfoKeys Name="CompanyName">Voronwë</VersionInfoKeys>
						<VersionInfoKeys Name="FileDescription">TempusFugit</VersionInfoKeys>
						<VersionInfoKeys Name="FileVersion">1.0.0.6</VersionInfoKeys>
						<VersionInfoKeys Name="InternalName">TempusFugit</VersionInfoKeys>
						<VersionInfoKeys Name="LegalCopyright">© Martijn Coppoolse</VersionInfoKeys>
						<VersionInfoKeys Name="LegalTrademarks"/>
						<VersionInfoKeys Name="OriginalFilename">TempusFugit.exe</VersionInfoKeys>
						<VersionInfoKeys Name="ProductName">Tempus Fugit</VersionInfoKeys>
						<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
						<VersionInfoKeys Name="Comments">http://martijn.coppoolse.com/software/</VersionInfoKeys>
					</VersionInfoKeys>
					<Excluded_Packages>
						<Excluded_Packages Name="C:\WINDOWS\system32\vclshlctrls100.bpl">Win32 Shell Controls</Excluded_Packages>
						<Excluded_Packages Name="C:\Proj32\_Lib\B305vr100.bpl">TurboPower Abbrevia 3.05 Run-time package - VCL90</Excluded_Packages>
						<Excluded_Packages Name="C:\Proj32\_Lib\S303_r100.bpl">SysTools 3 Runtime Package</Excluded_Packages>
						<Excluded_Packages Name="C:\Proj32\_Lib\B305_r100.bpl">TurboPower Abbrevia 3.05 Run-time package - RTL90</Excluded_Packages>
					</Excluded_Packages>
				</Delphi.Personality>
			</BorlandProject>
			<ProjectFileVersion>12</ProjectFileVersion>
		</ProjectExtensions>
	</Project>

Added src/prj/d2009/TempusFugit.res.

cannot compute difference between binary files