summaryrefslogtreecommitdiff
path: root/plugins/Libs/KOLCCtrls.pas
blob: f90e8f0e904639fdb6444b42624617b5e5ce57e2 (plain)
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
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
unit KOLCCtrls;
{$UNDEF UNICODE}

interface

uses
  Windows, Messages, ShellAPI, KOL;

{ ====== TRACKBAR CONTROL CONSTANTS =================== }

const
  TRACKBAR_CLASS    = 'msctls_trackbar32';

  TBS_AUTOTICKS     = $0001;
  TBS_VERT          = $0002;
  TBS_HORZ          = $0000;
  TBS_TOP           = $0004;
  TBS_BOTTOM        = $0000;
  TBS_LEFT          = $0004;
  TBS_RIGHT         = $0000;
  TBS_BOTH          = $0008;
  TBS_NOTICKS       = $0010;
  TBS_ENABLESELRANGE = $0020;
  TBS_FIXEDLENGTH   = $0040;
  TBS_NOTHUMB       = $0080;
  TBS_TOOLTIPS      = $0100;

  TBM_GETPOS        = WM_USER;
  TBM_GETRANGEMIN   = WM_USER + 1;
  TBM_GETRANGEMAX   = WM_USER + 2;
  TBM_GETTIC        = WM_USER + 3;
  TBM_SETTIC        = WM_USER + 4;
  TBM_SETPOS        = WM_USER + 5;
  TBM_SETRANGE      = WM_USER + 6;
  TBM_SETRANGEMIN   = WM_USER + 7;
  TBM_SETRANGEMAX   = WM_USER + 8;
  TBM_CLEARTICS     = WM_USER + 9;
  TBM_SETSEL        = WM_USER + 10;
  TBM_SETSELSTART   = WM_USER + 11;
  TBM_SETSELEND     = WM_USER + 12;
  TBM_GETPTICS      = WM_USER + 14;
  TBM_GETTICPOS     = WM_USER + 15;
  TBM_GETNUMTICS    = WM_USER + 16;
  TBM_GETSELSTART   = WM_USER + 17;
  TBM_GETSELEND     = WM_USER + 18;
  TBM_CLEARSEL      = WM_USER + 19;
  TBM_SETTICFREQ    = WM_USER + 20;
  TBM_SETPAGESIZE   = WM_USER + 21;
  TBM_GETPAGESIZE   = WM_USER + 22;
  TBM_SETLINESIZE   = WM_USER + 23;
  TBM_GETLINESIZE   = WM_USER + 24;
  TBM_GETTHUMBRECT  = WM_USER + 25;
  TBM_GETCHANNELRECT = WM_USER + 26;
  TBM_SETTHUMBLENGTH = WM_USER + 27;
  TBM_GETTHUMBLENGTH = WM_USER + 28;
  TBM_SETTOOLTIPS   = WM_USER + 29;
  TBM_GETTOOLTIPS   = WM_USER + 30;
  TBM_SETTIPSIDE    = WM_USER + 31;

  // TrackBar Tip Side flags
  TBTS_TOP          = 0;
  TBTS_LEFT         = 1;
  TBTS_BOTTOM       = 2;
  TBTS_RIGHT        = 3;

  TBM_SETBUDDY      = WM_USER + 32; // wparam = BOOL fLeft; (or right)
  TBM_GETBUDDY      = WM_USER + 33; // wparam = BOOL fLeft; (or right)
  TBM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
  TBM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;

  TB_LINEUP         = 0;
  TB_LINEDOWN       = 1;
  TB_PAGEUP         = 2;
  TB_PAGEDOWN       = 3;
  TB_THUMBPOSITION  = 4;
  TB_THUMBTRACK     = 5;
  TB_TOP            = 6;
  TB_BOTTOM         = 7;
  TB_ENDTRACK       = 8;

  // custom draw item specs
  TBCD_TICS         = $0001;
  TBCD_THUMB        = $0002;
  TBCD_CHANNEL      = $0003;

  { ^^^^^^^^ TRACKBAR CONTROL ^^^^^^^^ }

type
  PTrackbar = ^TTrackbar;
  TTrackbarOption = (trbAutoTicks, trbEnableSelRange, trbFixedLength,
    trbNoThumb, trbNoTicks, trbTooltips, trbTopLeftMarks,
    trbVertical, trbNoBorder, trbBoth);
  TTrackbarOptions = set of TTrackbarOption;

  TOnScroll = procedure(Sender: PTrackbar; Code: Integer) of object;
  {* Code:
  |<pre>
  TB_THUMBTRACK    Slider movement (the user dragged the slider)
  TB_THUMBPOSITION WM_LBUTTONUP following a TB_THUMBTRACK notification message
  TB_BOTTOM        VK_END
  TB_ENDTRACK      WM_KEYUP (the user released a key that sent a relevant virtual key code)
  TB_LINEDOWN      VK_RIGHT or VK_DOWN
  TB_LINEUP        VK_LEFT or VK_UP
  TB_PAGEDOWN      VK_NEXT (the user clicked the channel below or to the right of the slider)
  TB_PAGEUP        VK_PRIOR (the user clicked the channel above or to the left of the slider)
  TB_TOP           VK_HOME
  |</pre>
  }

  TTrackbar = object(TControl)
  private
    function GetOnScroll: TOnScroll;
    procedure SetOnScroll(const Value: TOnScroll);
    function GetVal(const Index: Integer): Integer;
    procedure SetVal(const Index, Value: Integer);
    procedure SetThumbLen(const Index, Value: Integer);
  protected
  public
    property OnScroll: TOnScroll read GetOnScroll write SetOnScroll;
    property RangeMin: Integer index $80010007 read GetVal write SetVal;
    property RangeMax: Integer index $80020008 read GetVal write SetVal;
    property PageSize: Integer index $00160015 read GetVal write SetVal;
    property LineSize: Integer index $00180017 read GetVal write SetVal;
    property Position: Integer index $80000005 read GetVal write SetVal;
    property NumTicks: Integer index $00100000 read GetVal;
    property SelStart: Integer index $0011000B read GetVal write SetVal;
    property SelEnd: Integer index $0012000C read GetVal write SetVal;
    property ThumbLen: Integer index $001B0000 read GetVal write SetThumbLen;

    function ChannelRect: TRect;
  end;

  PTrackbarData = ^TTrackbarData;
  TTrackbarData = packed record
    FOnScroll: TOnScroll;
  end;

  TKOLTrackbar = PTrackbar;

  { SPC CONTROLS }

  TSortBy = (sbName, sbExtention);

  PSPCDirectoryEdit = ^TSPCDirectoryEdit;
  TSPCDirectoryEditBox = PSPCDirectoryEdit;
  TSPCDirectoryEdit = object(TObj)
  private
    { Private declarations }
    fCreated: Boolean;
    fBorder: Integer;
    fControl: PControl;
    fEdit: PControl;
    fButton: PControl;
    fDirList: POpenDirDialog;
    fFont: PGraphicTool;
    fPath: string;
    fTitle: string;
    fCaptionEmpty: string;
    fOnChange: TOnEvent;
    fColor: TColor;
    function GetTop: Integer;
    procedure SetTop(Value: Integer);
    function GetLeft: Integer;
    procedure SetLeft(Value: Integer);
    function GetHeight: Integer;
    procedure SetHeight(Value: Integer);
    function GetWidth: Integer;
    procedure SetWidth(Value: Integer);
    procedure DoClick(Sender: PObj);
    procedure SetPath(Value: string);
  protected
    { Protected declarations }
  public
    destructor Destroy; virtual;
    procedure Initialize;
    function SetAlign(Value: TControlAlign): PSPCDirectoryEdit; overload;
    function SetPosition(X, Y: integer): PSPCDirectoryEdit; overload;
    function SetSize(X, Y: integer): PSPCDirectoryEdit; overload;
    function GetFont: PGraphicTool;
    property Border: Integer read fBorder write fBorder;
    { Public declarations }
    property Font: PGraphicTool read GetFont;
    property Color: TColor read fColor write fColor;
    property Title: string read fTitle write fTitle;
    property Path: string read fPath write SetPath;
    property OnChange: TOnEvent read fOnChange write fOnChange;
    property CaptionEmpty: string read fCaptionEmpty write fCaptionEmpty;
    property Height: Integer read GetHeight write SetHeight;
    property Width: Integer read GetWidth write SetWidth;
    property Top: Integer read GetTop write SetTop;
    property Left: Integer read GetLeft write SetLeft;
  end;

  TCase = (ctDefault, ctLower, ctUpper);

  PSPCFileList = ^TSPCFileList;
  TSPCFileListBox = PSPCFileList;
  TSPCFileList = object(TObj)
  private
    { Private declarations }
    fColor: TColor;
    fIcons: PImageList;
    fFilters: string;
    fIntegralHeight: Boolean;
    fFileList: PDirList;
    fControl: PControl;
    fPath: KOLString;
    fFont: PGraphicTool;
    FOnSelChange: TOnEvent;
    fDoCase: TCase;
    fHasBorder: Boolean;
    fOnPaint: TOnPaint;
    fExecuteOnDblClk: Boolean;
    fSortBy: TSortBy;
    FOnMouseDblClick: TOnMouse;
    function GetVisible: Boolean; // Edited
    procedure SetVisible(Value: Boolean); // Edited
    function GetFocused: Boolean;
    procedure SetFocused(Value: Boolean);
    function GetTop: Integer;
    procedure SetTop(Value: Integer);
    function GetLeft: Integer;
    procedure SetLeft(Value: Integer);
    function GetHeight: Integer;
    procedure SetHeight(Value: Integer);
    function GetWidth: Integer;
    procedure SetWidth(Value: Integer);
    procedure DoSelChange(Sender: PObj);
    procedure SetPath(Value: KOLString);
    procedure SetFilters(Value: string);
    procedure SetIntegralHeight(Value: Boolean);
    function GetCurIndex: Integer;
    procedure SetCurIndex(Value: Integer);
    procedure SetHasBorder(Value: Boolean);
    function GetSelected(Index: Integer): Boolean;
    procedure SetSelected(Index: Integer; Value: Boolean);
    function GetItem(Index: Integer): string;
    function DrawOneItem(Sender: PObj; DC: HDC; const Rect: TRect; ItemIdx: Integer; DrawAction: TDrawAction; ItemState: TDrawState): Boolean;
    procedure DoMouseDblClk(Sender: PControl; var Mouse: TMouseEventData);
    procedure SetFont(Value: PGraphicTool);
    procedure SetSortBy(Value: TSortBy);
  protected
    { Protected declarations }
  public
    property _SortBy: TSortBy read fSortBy write SetSortBy;
    property OnMouseDblClk: TOnMouse read FOnMouseDblClick write FOnMouseDblClick;
    destructor Destroy; virtual;
    function GetFileName: string;
    function GetFullFileName: string;
    property Selected[Index: Integer]: Boolean read GetSelected write SetSelected;
    property Items[Index: Integer]: string read GetItem;
    function TotalSelected: Integer;
    function SetPosition(X, Y: integer): PSPCFileList; overload;
    function SetSize(X, Y: integer): PSPCFileList; overload;
    function SetAlign(Value: TControlAlign): PSPCFileList; overload;
    function GetFont: PGraphicTool;
    { Public declarations }
    property Color: TColor read fColor write fColor;
    property Font: PGraphicTool read GetFont write SetFont;
    property IntegralHeight: Boolean read fIntegralHeight write SetIntegralHeight;
    property Path: KOLstring read fPath write SetPath;
    property Filters: string read fFilters write SetFilters;
    property OnSelChange: TOnEvent read FOnSelChange write FOnSelChange;
    property OnPaint: TOnPaint read FOnPaint write FOnPaint;
    property CurIndex: Integer read GetCurIndex write SetCurIndex;
    function Count: LongInt;
    property DoCase: TCase read fDoCase write fDoCase;
    property HasBorder: Boolean read fHasBorder write SetHasBorder;
    property Height: Integer read GetHeight write SetHeight;
    property Width: Integer read GetWidth write SetWidth;
    property Top: Integer read GetTop write SetTop;
    property Left: Integer read GetLeft write SetLeft;
    property Visible: Boolean read GetVisible write SetVisible; // Edited
    property Focused: Boolean read GetFocused write SetFocused;
    property ExecuteOnDblClk: Boolean read fExecuteOnDblClk write fExecuteOnDblClk;
    procedure SortByName;
    procedure SortByExtention;
  end;

  PSPCDirectoryList = ^TSPCDirectoryList;
  TSPCDirectoryListBox = PSPCDirectoryList;
  TSPCDirectoryList = object(TObj)
  private
    { Private declarations }
    fColor: TColor;
    fDoIndent: Boolean;
    fTotalTree: Integer;
    fDIcons: PImageList;
    fFOLDER: PIcon;
    fInitialized: Integer;
    fCreated: Boolean;
    fIntegralHeight: Boolean;
    fDirList: PDirList;
    fCurIndex: Integer;
    fControl: PControl;
    fPath: string;
    fFont: PGraphicTool;
    FOnMouseDblClick: TOnMouse;
    fLVBkColor: Integer;
    fOnChange: TOnEvent;
    fFileListBox: PSPCFileList;
    function GetTop: Integer;
    procedure SetTop(Value: Integer);
    function GetLeft: Integer;
    procedure SetLeft(Value: Integer);
    function GetHeight: Integer;
    procedure SetHeight(Value: Integer);
    function GetWidth: Integer;
    procedure SetWidth(Value: Integer);
    procedure DoMouseDblClick(Sender: PControl; var Mouse: TMouseEventData);
    procedure SetPath(Value: string);
    procedure SetFileListBox(Value: PSPCFileList);
  protected
    { Protected declarations }
  public
    destructor Destroy; virtual;
    property FileListBox: PSPCFileList read fFileListBox write SetFileListBox;
    function SetAlign(Value: TControlAlign): PSPCDirectoryList; overload;
    function SetPosition(X, Y: integer): PSPCDirectoryList; overload;
    function SetSize(X, Y: integer): PSPCDirectoryList; overload;
    function GetFont: PGraphicTool;
    property Color: TColor read fColor write fColor;
    { Public declarations }
    property Font: PGraphicTool read GetFont;
    property IntegralHeight: Boolean read fIntegralHeight write fIntegralHeight;
    property Path: string read fPath write SetPath;
    property DoIndent: Boolean read fDoIndent write fDoIndent;
    property OnMouseDblClk: TOnMouse read FOnMouseDblClick write FOnMouseDblClick;
    property CurIndex: Integer read fCurIndex write fCurIndex;
    property LVBkColor: Integer read fLVBkColor write fLVBkColor;
    property OnChange: TOnEvent read fOnChange write fOnChange;
    property Height: Integer read GetHeight write SetHeight;
    property Width: Integer read GetWidth write SetWidth;
    property Top: Integer read GetTop write SetTop;
    property Left: Integer read GetLeft write SetLeft;
  end;

  PSPCDriveCombo = ^TSPCDriveCombo;
  TSPCDriveComboBox = PSPCDriveCombo;
  TSPCDriveCombo = object(TObj)
  private
    { Private declarations }
    fIcons: PImageList;
    fColor: TColor;
    fInitialized: Integer;
    fCurIndex: Integer;
    fControl: PControl;
    fDrive: KOLChar;
    fFont: PGraphicTool;
    fLVBkColor: Integer;
    fOnChange: TOnEvent;
    //    fOnChangeInternal: TOnEvent;
    fAOwner: PControl;
    fDirectoryListBox: PSPCDirectoryList;
    function GetTop: Integer;
    procedure SetTop(Value: Integer);
    function GetLeft: Integer;
    procedure SetLeft(Value: Integer);
    function GetHeight: Integer;
    procedure SetHeight(Value: Integer);
    function GetWidth: Integer;
    procedure SetWidth(Value: Integer);
    procedure SetDrive(Value: KOLChar);
    procedure BuildList;
    procedure DoChange(Obj: PObj);
    //    procedure DoChangeInternal(Obj: PObj);
    function DoMeasureItem(Sender: PObj; Idx: Integer): Integer;
    function DrawOneItem(Sender: PObj; DC: HDC; const Rect: TRect; ItemIdx: Integer; DrawAction: TDrawAction; ItemState: TDrawState): Boolean;
  protected
    { Protected declarations }
  public
    destructor Destroy; virtual;
    function SetAlign(Value: TControlAlign): PSPCDriveCombo; overload;
    function SetPosition(X, Y: integer): PSPCDriveCombo; overload;
    function SetSize(X, Y: integer): PSPCDriveCombo; overload;
    function GetFont: PGraphicTool;
    procedure SetFont(Value: PGraphicTool);
    property Color: TColor read fColor write fColor;
    { Public declarations }
    property DirectoryListBox: PSPCDirectoryList read fDirectoryListBox write fDirectoryListBox;
    property Font: PGraphicTool read GetFont write SetFont;
    property Drive: KOLChar read fDrive write SetDrive;
    property CurIndex: Integer read fCurIndex write fCurIndex;
    property LVBkColor: Integer read fLVBkColor write fLVBkColor;
    property OnChange: TOnEvent read fOnChange write fOnChange;
    property Height: Integer read GetHeight write SetHeight;
    property Width: Integer read GetWidth write SetWidth;
    property Top: Integer read GetTop write SetTop;
    property Left: Integer read GetLeft write SetLeft;
  end;

  TFilterItem = class
  private
    fFull: string;
    fDescription: string;
    fFilter: string;
  public
  published
    property Full: string read fFull write fFull;
    property Description: string read fDescription write fDescription;
    property Filter: string read fFilter write fFilter;
  end;

  PSPCFilterCombo = ^TSPCFilterCombo;
  TSPCFilterComboBox = PSPCFilterCombo;
  TSPCFilterCombo = object(TObj)
  private
    { Private declarations }
    fColor: TColor;
    fCurIndex: Integer;
    fControl: PControl;
    fFont: PGraphicTool;
    fLVBkColor: Integer;
    fOnChange: TOnEvent;
    fFilterItems: PList;
    fFilter: string;
    fCreated: Boolean;
    fInitialized: Integer;
    fFileListBox: PSPCFileList;
    ftext: string;
    function GetTop: Integer;
    procedure SetTop(Value: Integer);
    function GetLeft: Integer;
    procedure SetLeft(Value: Integer);
    function GetHeight: Integer;
    procedure SetHeight(Value: Integer);
    function GetWidth: Integer;
    procedure SetWidth(Value: Integer);
    function GetFilterItem(Index: Integer): TFilterItem;
    procedure SetFilter(Value: string);
    procedure SetCurIndex(Value: Integer);
    function GetCurIndex: Integer;
    procedure DoChange(Obj: PObj);
    function DoMeasureItem(Sender: PObj; Idx: Integer): Integer;
    function GetItem(Index: Integer): string;
    procedure SetItem(Index: Integer; Value: string);
    function GetFilter: string;
  protected
    { Protected declarations }
  public
    destructor Destroy; virtual;
    procedure Update;
    procedure Add(fNewFilter: string);
    procedure DeleteItem(Index: Integer);
    function Count: Integer;
    procedure BuildList;
    property FileListBox: PSPCFileList read fFileListBox write fFileListBox;
    function SetAlign(Value: TControlAlign): PSPCFilterCombo; overload;
    function SetPosition(X, Y: integer): PSPCFilterCombo; overload;
    function SetSize(X, Y: integer): PSPCFilterCombo; overload;
    function GetFont: PGraphicTool;
    procedure SetFont(Value: PGraphicTool);
    property Filter: string read GetFilter write SetFilter;
    property Color: TColor read fColor write fColor;
    { Public declarations }
    property Text: string read fText write fText;
    property Font: PGraphicTool read GetFont write SetFont;
    property CurIndex: Integer read GetCurIndex write SetCurIndex;
    property LVBkColor: Integer read fLVBkColor write fLVBkColor;
    property OnChange: TOnEvent read fOnChange write fOnChange;
    property Items[Index: Integer]: string read GetItem write SetItem;
    property Filters[Index: Integer]: TFilterItem read GetFilterItem;
    property Height: Integer read GetHeight write SetHeight;
    property Width: Integer read GetWidth write SetWidth;
    property Top: Integer read GetTop write SetTop;
    property Left: Integer read GetLeft write SetLeft;
  end;

  PSPCStatus = ^TSPCStatus;
  TSPCStatusBar = PSPCStatus;
  TSPCStatus = object(TControl)
  private
    { Private declarations }
    fControl: PControl;
    function GetTop: Integer;
    procedure SetTop(Value: Integer);
    function GetLeft: Integer;
    procedure SetLeft(Value: Integer);
    function GetHeight: Integer;
    procedure SetHeight(Value: Integer);
    function GetWidth: Integer;
    procedure SetWidth(Value: Integer);
    procedure SetSimpleStatusText(Value: string);
    function GetSimpleStatusText: string;
  protected
    { Protected declarations }
  public
    destructor Destroy; virtual;
    function SetAlign(Value: TControlAlign): PSPCStatus; overload;
    function SetPosition(X, Y: integer): PSPCStatus; overload;
    function SetSize(X, Y: integer): PSPCStatus; overload;
    function GetFont: PGraphicTool;
    procedure SetFont(Value: PGraphicTool);
    { Public declarations }
    property Font: PGraphicTool read GetFont write SetFont;
    property SimpleStatusText: string read GetSimpleStatusText write SetSimpleStatusText;
    property Height: Integer read GetHeight write SetHeight;
    property Width: Integer read GetWidth write SetWidth;
    property Top: Integer read GetTop write SetTop;
    property Left: Integer read GetLeft write SetLeft;
    //    property SizeGrip;
  end;

function NewTrackbar(AParent: PControl; Options: TTrackbarOptions; OnScroll: TOnScroll): PTrackbar;

function CheckBit(Value, Index: LongInt): Boolean;
function GetLastPos(c: char; s: string): Integer;
function NewTSPCDirectoryEditBox(AOwner: PControl): PSPCDirectoryEdit;
function NewTSPCDirectoryListBox(AOwner: PControl; Style: TListViewStyle; Options: TListViewOptions; ImageListSmall, ImageListNormal, ImageListState: PImageList): PSPCDirectoryList;
function NewTSPCDriveComboBox(AOwner: PControl; Options: TComboOptions): PSPCDriveCombo;
function NewTSPCFileListBox(AOwner: PControl; Options: TListOptions): PSPCFileList;
function NewTSPCFilterComboBox(AOwner: PControl; Options: TComboOptions): PSPCFilterCombo;
function NewTSPCStatusBar(AOwner: PControl): PSPCStatus;

implementation

function WndProcTrackbarParent(Sender: PControl; var Msg: TMsg; var Rslt: Integer): Boolean;
var
  D                 : PTrackbarData;
  Trackbar          : PTrackbar;
begin
  Result := False;
  if (Msg.message = WM_HSCROLL) or (Msg.message = WM_VSCROLL) then
    if (Msg.lParam <> 0) then begin
      Trackbar := Pointer({$IFDEF USE_PROP}
        GetProp(Msg.lParam, ID_SELF)
{$ELSE}
        GetWindowLong(Msg.lParam, GWL_USERDATA)
{$ENDIF});
      if Assigned(Trackbar) then begin
        D := Trackbar.CustomData;
        if Assigned(D.FOnScroll) then
          D.FOnScroll(Trackbar, Msg.wParam);
      end;
    end;
end;

function TTrackbar.ChannelRect: TRect;
begin
  Perform( TBM_GETCHANNELRECT, 0, Integer( @ Result ) );
end;

function NewTrackbar(AParent: PControl; Options: TTrackbarOptions; OnScroll: TOnScroll): PTrackbar;
const
  TrackbarOptions   : array[TTrackbarOption] of Integer = (TBS_AUTOTICKS,
    TBS_ENABLESELRANGE, TBS_FIXEDLENGTH, TBS_NOTHUMB, TBS_NOTICKS, TBS_TOOLTIPS,
    TBS_TOP, TBS_VERT, 0, TBS_BOTH);
var
  aStyle            : DWORD;
  D                 : PTrackbarData;
  W, H              : Integer;
begin
  DoInitCommonControls(ICC_BAR_CLASSES);
  aStyle := MakeFlags(@Options, TrackbarOptions) or WS_CHILD or WS_VISIBLE;
  Result := PTrackbar(_NewCommonControl(AParent, TRACKBAR_CLASS, aStyle,
    not (trbNoBorder in Options), nil));
  W := 200;
  H := 40;
  if (trbVertical in Options) then begin
    H := W;
    W := 40;
  end;
  Result.Width := W;
  Result.Height := H;
  GetMem(D, Sizeof(D^));
  Result.CustomData := D;
  D.FOnScroll := OnScroll;
  AParent.AttachProc(WndProcTrackbarParent);
end;

{ TTrackbar }

function TTrackbar.GetOnScroll: TOnScroll;
var
  D                 : PTrackbarData;
begin
  D := CustomData;
  Result := D.FOnScroll;
end;

function TTrackbar.GetVal(const Index: Integer): Integer;
begin
  Result := Perform(WM_USER + (HiWord(Index) and $7FFF), 0, 0);
end;

procedure TTrackbar.SetOnScroll(const Value: TOnScroll);
var
  D                 : PTrackbarData;
begin
  D := CustomData;
  D.FOnScroll := Value;
end;

procedure TTrackbar.SetThumbLen(const Index, Value: Integer);
begin
  Perform(TBM_SETTHUMBLENGTH, Value, 0);
end;

procedure TTrackbar.SetVal(const Index, Value: Integer);
begin
  Perform(WM_USER + LoWord(Index), Index shr 31, Value);
end;

{ TSPCDirectoryEdit }

function NewTSPCDirectoryEditBox;
var
  p                 : PSPCDirectoryEdit;
  c                 : PControl;
begin
  c := NewPanel(AOwner, esNone);
  c.ExStyle := c.ExStyle or WS_EX_CLIENTEDGE;
  New(p, create);
  AOwner.Add2AutoFree(p);
  p.fControl := c;
  p.fFont := NewFont;
  p.fCreated := False;
  Result := p;
end;

function TSPCDirectoryEdit.SetAlign(Value: TControlAlign): PSPCDirectoryEdit;
begin
  fControl.Align := Value;
  Result := @Self;
end;

destructor TSPCDirectoryEdit.Destroy;
begin
  fFont.Free;
  inherited;
end;

function TSPCDirectoryEdit.SetPosition(X, Y: integer): PSPCDirectoryEdit;
begin
  fControl.Left := X;
  fControl.Top := Y;
  Result := @self;
end;

function TSPCDirectoryEdit.SetSize(X, Y: integer): PSPCDirectoryEdit;
begin
  fControl.Width := X;
  fControl.Height := Y;
  Result := @self;
end;

function TSPCDirectoryEdit.GetFont;
begin
  Result := fFont;
end;

procedure TSPCDirectoryEdit.Initialize;
begin
  fEdit := NewEditBox(fControl, [eoReadOnly]);
  fEdit.Font.FontHeight := -11;
  fControl.Height := fEdit.Height - 1;
  fEdit.Left := 0;
  fEdit.Top := 1;
  fEdit.Height := 17;
  fEdit.Width := fControl.Width - 21;
  fEdit.HasBorder := False;
  fEdit.Color := fColor;
  fEdit.Font.Assign(Font);
  fButton := NewBitBtn(fControl, '...', [], glyphLeft, 0, 1);
  fButton.Font.FontHeight := -11;
  fButton.VerticalAlign := vaCenter;
  fButton.LikeSpeedButton;
  fButton.Width := 17;
  fButton.Height := 17;
  fButton.Top := 0;
  fButton.Left := fEdit.Width;
  fButton.OnClick := DoClick;
  fDirList := NewOpenDirDialog(Title, []);
  fDirList.CenterOnScreen := True;
end;

procedure TSPCDirectoryEdit.SetPath(Value: string);
begin
  if DirectoryExists(Value) then fPath := Value else fPath := '';
  if Length(fPath) = 0 then fEdit.Text := CaptionEmpty else fEdit.Text := fPath;
  if Assigned(fOnChange) then if fCreated then fOnChange(@Self) else fCreated := True;
end;

procedure TSPCDirectoryEdit.DoClick;
begin
  fDirList.InitialPath := Path;
  if fDirList.Execute then begin
    Path := fDirList.Path;
    fEdit.Text := fDirList.Path;
  end;
end;

function TSPCDirectoryEdit.GetHeight: Integer;
begin
  Result := fControl.Height;
end;

procedure TSPCDirectoryEdit.SetHeight(Value: Integer);
begin
  fControl.Height := Value;
end;

function TSPCDirectoryEdit.GetWidth: Integer;
begin
  Result := fControl.Width;
end;

procedure TSPCDirectoryEdit.SetWidth(Value: Integer);
begin
  fControl.Width := Value;
end;

function TSPCDirectoryEdit.GetTop: Integer;
begin
  Result := fControl.Top;
end;

procedure TSPCDirectoryEdit.SetTop(Value: Integer);
begin
  fControl.Top := Value;
end;

function TSPCDirectoryEdit.GetLeft: Integer;
begin
  Result := fControl.Left;
end;

procedure TSPCDirectoryEdit.SetLeft(Value: Integer);
begin
  fControl.Left := Value;
end;

{ TSPCDirectoryList }

function NewTSPCDirectoryListBox;
var
  p                 : PSPCDirectoryList;
  c                 : PControl;
  Shell32           : LongInt;
begin
  c := NewListView(AOwner, lvsDetailNoHeader, [], ImageListSmall, ImageListNormal, ImageListState);
  New(p, create);
  AOwner.Add2AutoFree(p);
  p.fControl := c;
  p.fControl.OnMouseDblClk := p.DoMouseDblClick;
  p.fControl.lvOptions := [lvoRowSelect, lvoInfoTip, lvoAutoArrange];
  p.fCreated := False;
  p.fDirList := NewDirList('', '', 0);
  p.fFont := NewFont;
  p.fDIcons := NewImageList(AOwner);
  p.fDIcons.LoadSystemIcons(True);
  Shell32 := LoadLibrary('shell32.dll');
  p.fFOLDER := NewIcon;
  p.fFOLDER.LoadFromResourceID(Shell32, 4, 16);
  p.fDIcons.ReplaceIcon(0, p.fFOLDER.Handle);
  p.fFOLDER.LoadFromResourceID(Shell32, 5, 16);
  p.fDIcons.ReplaceIcon(1, p.fFOLDER.Handle);
  FreeLibrary(Shell32);
  p.fFOLDER.Free;
  p.fControl.ImageListSmall := p.fDIcons;
  p.fInitialized := 0;
  Result := p;
end;

function TSPCDirectoryList.SetAlign(Value: TControlAlign): PSPCDirectoryList;
begin
  fControl.Align := Value;
  Result := @Self;
end;

procedure TSPCDirectoryList.DoMouseDblClick;
var
  s                 : string;
  i                 : Integer;
begin
  if fControl.lvCurItem > -1 then begin
    s := '';
    if fControl.LVCurItem <= fTotalTree - 1 then begin
      for i := 0 to fControl.LVCurItem do s := s + fControl.lvItems[i, 0] + '\';
    end else begin
      for i := 0 to fTotalTree - 1 do s := s + fControl.lvItems[i, 0] + '\';
      s := s + fControl.lvItems[fControl.lvCurItem, 0];
    end;
    Path := s;
    if Assigned(fOnMouseDblClick) then fOnMouseDblClick(@Self, Mouse);
  end;
end;

destructor TSPCDirectoryList.Destroy;
begin
  fFont.Free;
  inherited;
end;

function TSPCDirectoryList.SetPosition(X, Y: integer): PSPCDirectoryList;
begin
  fControl.Left := X;
  fControl.Top := Y;
  Result := @self;
end;

function TSPCDirectoryList.SetSize(X, Y: integer): PSPCDirectoryList;
begin
  fControl.Width := X;
  fControl.Height := Y;
  Result := @self;
end;

function TSPCDirectoryList.GetFont;
begin
  Result := fFont;
end;

procedure TSPCDirectoryList.SetPath(Value: string);
var
  TPath, fValue     : string;
  i, z              : Integer;
  LastDir           : Cardinal;
  fImgIndex         : Integer;
  Code              : Cardinal;
  fDriveShown       : Boolean;
begin
  fValue := Value;
  fControl.lvBkColor := fColor;
  fControl.lvTextBkColor := fColor;
  if Length(fValue) = 1 then fValue := fValue + ':\';
  if not fCreated then begin
    fCreated := True;
    fControl.LVColAdd('', taRight, fControl.Width);
    //    if fIntegralHeight then
    //    begin
    //      fControl.Height:=(fControl.Height div 16)*16+1;
    //    end;
  end;
  fControl.Clear;
  if DirectoryExists(fValue) then begin
    LastDir := 0;
    fTotalTree := 0;
    if fValue[Length(fValue)] = '\' then TPath := fValue else TPath := fValue + '\';
    fPath := TPath;
    fDriveShown := False;
    fImgIndex := -1;
    repeat
      if fTotalTree > 0 then fImgIndex := 1;
      if not fDriveShown then begin
        fDriveShown := True;
        fImgIndex := FileIconSystemIdx(Copy(TPath, 1, 3));
      end;
      fControl.LVAdd(Copy(TPath, 1, Pos('\', TPath) - 1), fImgIndex, [], 0, 0, 0);
      fControl.LVItemIndent[LastDir] := LastDir;
      Delete(TPath, 1, Pos('\', TPath));
      if DoIndent then Inc(LastDir);
      Inc(fTotalTree);
    until Length(TPath) = 0;
    fDirList.ScanDirectory(fValue, '*.*', FILE_ATTRIBUTE_NORMAL);
    fDirList.Sort([sdrByName]);
    z := -1;
    for i := 0 to fDirList.Count - 1 do begin
      Code := fDirList.Items[i].dwFileAttributes;
      if Code = (Code or $10) then
        if not (fDirList.Names[i] = '.') then
          if not (fDirList.Names[i] = '..') then begin
            Inc(z);
            fControl.LVAdd(fDirList.Names[i], 0, [], 0, 0, 0);
            if DoIndent then fControl.LVItemIndent[z + fTotalTree] := LastDir else fControl.LVItemIndent[z + fTotalTree] := 1;
          end;
    end;
  end else begin
    fPath := '';
  end;
  Inc(fInitialized);
  if fInitialized > 2 then fInitialized := 2;
  if Assigned(OnChange) then if fInitialized = 2 then OnChange(@Self);
  if Assigned(fFileListBox) then fFileListBox.Path := Path;
  fControl.LVColWidth[0] := -2;
end;

function TSPCDirectoryList.GetHeight: Integer;
begin
  Result := fControl.Height;
end;

procedure TSPCDirectoryList.SetHeight(Value: Integer);
begin
  fControl.Height := Value;
end;

function TSPCDirectoryList.GetWidth: Integer;
begin
  Result := fControl.Width;
end;

procedure TSPCDirectoryList.SetWidth(Value: Integer);
begin
  fControl.Width := Value;
end;

function TSPCDirectoryList.GetTop: Integer;
begin
  Result := fControl.Top;
end;

procedure TSPCDirectoryList.SetTop(Value: Integer);
begin
  fControl.Top := Value;
end;

function TSPCDirectoryList.GetLeft: Integer;
begin
  Result := fControl.Left;
end;

procedure TSPCDirectoryList.SetLeft(Value: Integer);
begin
  fControl.Left := Value;
end;

procedure TSPCDirectoryList.SetFileListBox(Value: PSPCFileList);
begin
  fFileListBox := Value;
  fFileListBox.Path := Path;
end;

{ TSPCDriveCombo }

function CheckBit;
var
  fL                : LongInt;
begin
  fL := Value;
  fL := fL shr Index;
  fL := fL and $01;
  Result := (fL = 1);
end;

function NewTSPCDriveComboBox;
var
  p                 : PSPCDriveCombo;
  c                 : PControl;
begin
  c := NewComboBox(AOwner, [coReadOnly, coOwnerDrawVariable]);
  New(p, create);
  AOwner.Add2AutoFree(p);
  p.fControl := c;
  p.fFont := NewFont;
  p.fFont.FontHeight := -8;
  p.fControl.Font.Assign(p.fFont);
  p.fIcons := NewImageList(AOwner);
  p.fIcons.LoadSystemIcons(True);
  p.fAOwner := AOwner;
  p.fControl.OnDrawItem := p.DrawOneItem;
  p.fControl.OnChange := p.DoChange;
  p.fControl.OnMeasureItem := p.DoMeasureItem;
  p.BuildList;
  p.fInitialized := 0;
  p.fControl.Color := $FF0000;
  Result := p;
end;

procedure TSPCDriveCombo.DoChange(Obj: PObj);
begin
  Drive := fControl.Items[fControl.CurIndex][1];
  SetCurrentDirectory(PKOLChar(Drive + ':\'));
  if Assigned(fOnChange) then fOnChange(@Self);
  if Assigned(fDirectoryListBox) then fDirectoryListBox.Path := Drive;
end;

destructor TSPCDriveCombo.Destroy;
begin
  fFont.Free;
  inherited;
end;

function TSPCDriveCombo.SetAlign(Value: TControlAlign): PSPCDriveCombo;
begin
  fControl.Align := Value;
  Result := @Self;
end;

function TSPCDriveCombo.SetPosition(X, Y: integer): PSPCDriveCombo;
begin
  fControl.Left := X;
  fControl.Top := Y;
  Result := @self;
end;

function TSPCDriveCombo.SetSize(X, Y: integer): PSPCDriveCombo;
begin
  fControl.Width := X;
  fControl.Height := Y;
  Result := @self;
end;

function TSPCDriveCombo.GetFont;
begin
  Result := fFont;
end;

procedure TSPCDriveCombo.SetFont(Value: PGraphicTool);
begin
  fFont := Value;
  fControl.Font.Assign(Value);
end;

procedure TSPCDriveCombo.SetDrive;
var
  fC                : KOLChar;
begin
  fControl.Font.Assign(fFont);
  fControl.Color := fColor;
  fC := Value;
  if fControl.SearchFor(fc, 0, True) > -1 then begin
    fDrive := fC;
    fControl.CurIndex := fControl.SearchFor(fc, 0, True);
  end;
  Inc(fInitialized);
  if fInitialized > 2 then fInitialized := 2;
  if Assigned(fOnChange) then if fInitialized = 2 then fOnChange(@Self);
end;

function VolumeID(DriveChar: KOLChar): string;
var
  NotUsed, VolFlags : DWORD;
  Buf               : array[0..MAX_PATH] of KOLChar;
begin
  if GetVolumeInformation(PKOLChar(DriveChar + ':\'), Buf, DWORD(sizeof(Buf)), nil, NotUsed, VolFlags, nil, 0) then
    Result := buf//Copy(Buf, 1, StrLen(Buf))
  else
    Result := '';
end;

function dr_property(path: KOLString): KOLString;
var
  Cpath             : PKOLChar;
  Spath             : KOLChar;
begin
  Result := '';
  Cpath := PKOLChar(Copy(path, 1, 2));
  Spath := Cpath[0];
  case GetDriveType(Cpath) of
    0: Result := '<unknown>'; //Íå èçâåñòåí
    1: Result := '<disabled>'; //Íå ñóùåñòâóåò :)
    DRIVE_REMOVABLE: Result := 'Removable'; //Ôëîïèê
    DRIVE_FIXED: if Length(VolumeID(Spath)) > 0 then Result := VolumeID(Spath) else Result := 'Local Disk'; //HDD
    DRIVE_REMOTE: if Length(VolumeID(Spath)) > 0 then Result := VolumeID(Spath) else Result := 'Net Disk'; //Âíåøíèé íîñèòåëü
    //         DRIVE_REMOTE: if Length(VolumeID(Spath))>0 then Result:=NetworkVolume(Spath) else Result:='Net Disk';//Âíåøíèé íîñèòåëü
    DRIVE_CDROM: if Length(VolumeID(Spath)) > 0 then Result := VolumeID(Spath) else Result := 'Compact Disc'; //CD
    DRIVE_RAMDISK: if Length(VolumeID(Spath)) > 0 then Result := VolumeID(Spath) else Result := 'Removable Disk'; //Âíåøíèé íîñèòåëü
  end;
end;

procedure TSPCDriveCombo.BuildList;
var
  b                 : Byte;
  fFlags            : LongInt;
  fDir              : string;
  //  a                 : integer;
  fFullPath         : string;
  fdr_property      : string;
begin
  GetDir(0, fDir);
  fControl.Clear;
  fFlags := GetLogicalDrives;
  for b := 0 to 25 do if Boolean(fFlags and (1 shl b)) then begin
      fFullPath := Chr(b + $41) + ':';
      fdr_property := dr_property(fFullPath);
      {a :=}fControl.Add(Chr(b + $41) + '  ' + fdr_property);
    end;
  fControl.CurIndex := fControl.SearchFor(fDir[1], 0, True);
  fControl.Update;
end;

function TSPCDriveCombo.DrawOneItem(Sender: PObj; DC: HDC; //aded by tamerlan311
  const Rect: TRect; ItemIdx: Integer; DrawAction: TDrawAction;
  ItemState: TDrawState): Boolean;
var
  T_Rect            : TRect;
  B_Rect            : TRect;
  Ico               : Integer;
begin
  SetBkMode(DC, opaque);
  if ItemIdx > -1 then begin
    //PControl(Sender).CanResize := True;
    T_Rect := Rect;
    B_Rect := Rect;
    T_Rect.Left := Rect.Left + 19;
    B_Rect.Left := Rect.Left + 18;
    PControl(Sender).Canvas.Pen.PenMode := pmCopy;
    PControl(Sender).Canvas.Pen.Color := $0000FF;
    PControl(Sender).Brush.Color := clWindow;
    if (odsFocused in ItemState) or (odsSelected in ItemState) then begin
      SetBkMode(DC, TRANSPARENT);
      PControl(Sender).Canvas.Brush.color := clWindow;
      FillRect(DC, T_Rect, PControl(Sender).Canvas.Brush.Handle);
      if (not (odsFocused in ItemState)) and ((odsSelected in ItemState)) then begin
        PControl(Sender).Canvas.Brush.color := clInactiveBorder;
        SetTextColor(DC, Font.Color);
        fIcons.DrawingStyle := [];
      end else begin
        PControl(Sender).Canvas.Brush.color := clHighLight;
        SetTextColor(DC, $FFFFFF);
        fIcons.DrawingStyle := [dsBlend50];
      end;
      FillRect(DC, T_Rect, PControl(Sender).Canvas.Brush.Handle);
    end else begin
      SetTextColor(DC, Font.Color);
      PControl(Sender).Canvas.Brush.color := clWindow;
      SelectObject(DC, PControl(Sender).Canvas.Brush.Handle);
      FillRect(DC, B_Rect, PControl(Sender).Canvas.Brush.Handle);
      fIcons.DrawingStyle := [];
    end;
    Ico := FileIconSystemIdx(PControl(Sender).Items[ItemIdx][1] + ':\');
    fIcons.Draw(Ico, DC, Rect.Left + 1, Rect.Top);
    DrawText(DC, PKOLChar(PControl(Sender).Items[ItemIdx]), Length(PControl(Sender).Items[ItemIdx]), T_Rect, DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX);
  end;
 // PControl(Sender).Update;
  Result := True;         ///
end;

function TSPCDriveCombo.GetHeight: Integer;
begin
  Result := fControl.Height;
end;

procedure TSPCDriveCombo.SetHeight(Value: Integer);
begin
  fControl.Height := Value;
end;

function TSPCDriveCombo.GetWidth: Integer;
begin
  Result := fControl.Width;
end;

procedure TSPCDriveCombo.SetWidth(Value: Integer);
begin
  fControl.Width := Value;
end;

function TSPCDriveCombo.GetTop: Integer;
begin
  Result := fControl.Top;
end;

procedure TSPCDriveCombo.SetTop(Value: Integer);
begin
  fControl.Top := Value;
end;

function TSPCDriveCombo.GetLeft: Integer;
begin
  Result := fControl.Left;
end;

procedure TSPCDriveCombo.SetLeft(Value: Integer);
begin
  fControl.Left := Value;
end;

function TSPCDriveCombo.DoMeasureItem(Sender: PObj; Idx: Integer): Integer;
begin
  Result := 16;
end;

{ TSPCFileList }

function NewTSPCFileListBox;
var
  p                 : PSPCFileList;
begin
  Options := Options + [loOwnerDrawFixed];
  New(p, Create);
  AOwner.Add2AutoFree(p);
  p.fControl := NewListBox(AOwner, Options);
  //   p.fControl.OnMouseDblClk:=p.DoMouseDblClick;
  p.fControl.OnChange := p.DoSelChange;
  p.fControl.Font.FontHeight := -8;
  p.fFileList := NewDirList('', '', 0);
  p.fControl.OnDrawItem := p.DrawOneItem;
  p.fFont := NewFont;
  p.fIcons := NewImageList(nil);
  p.fIcons.LoadSystemIcons(true);
  p.fControl.OnMouseDblClk := p.DoMouseDblClk;
  p.fControl.Font.FontHeight := -11;
  Result := p;
end;

function TSPCFileList.SetAlign(Value: TControlAlign): PSPCFileList;
begin
  fControl.Align := Value;
  Result := @Self;
end;

procedure TSPCFileList.SetFilters(Value: string);
begin
  fFilters := Value;
  Path := Path;
end;

procedure TSPCFileList.DoSelChange;
begin
  if Assigned(fOnSelChange) then fOnSelChange(@Self);
end;

destructor TSPCFileList.Destroy;
begin
  fFont.Free;
  inherited;
end;

function TSPCFileList.SetPosition(X, Y: integer): PSPCFileList;
begin
  fControl.Left := X;
  fControl.Top := Y;
  Result := @self;
end;

function TSPCFileList.SetSize(X, Y: integer): PSPCFileList;
begin
  fControl.Width := X;
  fControl.Height := Y;
  Result := @self;
end;

function TSPCFileList.GetFont;
begin
  Result := fControl.Font;
end;

procedure TSPCFileList.SetFont(Value: PGraphicTool);
begin
  fControl.Font.Assign(Value);
end;

procedure TSPCFileList.SetPath(Value: KOLstring);
var
  i                 : Integer;
  fValue            : string;
begin
  fValue := Value;
  if Length(fValue) > 0 then begin
    if not (fValue[Length(fValue)] = '\') then fValue := fValue + '\';
  end;
  if DirectoryExists(fValue) then begin
    fFileList.Clear;
    fFileList.ScanDirectoryEx(FileShortPath(fValue), Filters, FILE_ATTRIBUTE_NORMAL and not FILE_ATTRIBUTE_DIRECTORY);
    fControl.Clear;
    fControl.Color := fColor;
    case _SortBy of
      sbName: fFileList.Sort([sdrByName]);
      sbExtention: fFileList.Sort([sdrByExt]);
    end;
    for i := 1 to fFileList.Count do if not fFileList.IsDirectory[i - 1] then fControl.Add(fFileList.Names[i - 1]);
    fPath := fValue;
    if fDoCase = ctLower then for i := 0 to fControl.Count - 1 do fControl.Items[i] := LowerCase(fControl.Items[i]);
    if fDoCase = ctUpper then for i := 0 to fControl.Count - 1 do fControl.Items[i] := UpperCase(fControl.Items[i]);
  end else begin
    fControl.Clear;
    fPath := '';
  end;
  if fIntegralHeight then begin
    fControl.Height := Round(fControl.Height / 16) * 16 + 4;
  end;
end;

procedure TSPCFileList.SetIntegralHeight;
begin
  fIntegralHeight := Value;
  if fIntegralHeight then begin
    fControl.Height := (fControl.Height div 14) * 14 + 6;
  end;
end;

function TSPCFileList.GetFileName: string;
begin
  Result := fControl.Items[fControl.CurIndex];
end;

function TSPCFileList.GetFullFileName: string;
begin
  Result := Path + fControl.Items[fControl.CurIndex]
end;

function TSPCFileList.Count: LongInt;
begin
  Result := fControl.Count;
end;

function TSPCFileList.GetCurIndex: Integer;
begin
  Result := fControl.CurIndex;
end;

procedure TSPCFileList.SetCurIndex(Value: Integer);
begin
  fControl.CurIndex := Value;
end;

procedure TSPCFileList.SetHasBorder(Value: Boolean);
var
  NewStyle          : DWORD;
begin
  if Value then
    fControl.Style := fControl.Style or WS_THICKFRAME
  else begin
    NewStyle := fControl.Style and not (WS_BORDER or WS_THICKFRAME or WS_DLGFRAME or WS_CAPTION
      or WS_MINIMIZEBOX or WS_MAXIMIZEBOX or WS_SYSMENU or WS_HSCROLL);
    if not fControl.IsControl then NewStyle := NewStyle or WS_POPUP;
    fControl.Style := NewStyle;
    fControl.ExStyle := fControl.ExStyle and not (WS_EX_CONTROLPARENT or WS_EX_DLGMODALFRAME
      or WS_EX_WINDOWEDGE or WS_EX_CLIENTEDGE);
  end;
end;

function TSPCFileList.GetSelected(Index: Integer): Boolean;
begin
  if Index > Count - 1 then Result := False else Result := fControl.ItemSelected[Index];
end;

procedure TSPCFileList.SetSelected(Index: Integer; Value: Boolean);
begin
  if Index <= Count - 1 then fControl.ItemSelected[Index] := Value;
end;

function TSPCFileList.TotalSelected: Integer;
var
  i                 : Integer;
begin
  Result := 0;
  if fControl.Count = 0 then Result := -1 else begin
    for i := 0 to fControl.Count - 1 do if fControl.ItemSelected[i] then Result := Result + 1;
  end;
end;

function TSPCFileList.GetItem(Index: Integer): string;
begin
  Result := fControl.Items[Index];
end;

function TSPCFileList.GetHeight: Integer;
begin
  Result := fControl.Height;
end;

procedure TSPCFileList.SetHeight(Value: Integer);
begin
  fControl.Height := Value;
end;

function TSPCFileList.GetWidth: Integer;
begin
  Result := fControl.Width;
end;

procedure TSPCFileList.SetWidth(Value: Integer);
begin
  fControl.Width := Value;
end;

function TSPCFileList.GetTop: Integer;
begin
  Result := fControl.Top;
end;

procedure TSPCFileList.SetTop(Value: Integer);
begin
  fControl.Top := Value;
end;

function TSPCFileList.GetVisible: Boolean; // Edited
begin
  Result := FControl.Visible;
end;

procedure TSPCFileList.SetVisible(Value: Boolean); // Edited
begin
  FControl.Visible := Value;
end;

function TSPCFileList.GetLeft: Integer;
begin
  Result := fControl.Left;
end;

procedure TSPCFileList.SetLeft(Value: Integer);
begin
  fControl.Left := Value;
end;

function TSPCFileList.GetFocused: Boolean;
begin
  Result := fControl.Focused;
end;

procedure TSPCFileList.SetFocused(Value: Boolean);
begin
  fControl.Focused := Value;
end;

function TSPCFileList.DrawOneItem(Sender: PObj; DC: HDC;
  const Rect: TRect; ItemIdx: Integer; DrawAction: TDrawAction;
  ItemState: TDrawState): Boolean;
var
  T_Rect, B_Rect    : TRect;
  Ico               : Integer;
begin
  SetBkMode(DC, opaque);
  if ItemIdx > -1 then begin
    PControl(Sender).CanResize := True;
    T_Rect := Rect;
    B_Rect := Rect;
    T_Rect.Left := Rect.Left + 19;
    B_Rect.Left := Rect.Left + 18;
    PControl(Sender).Canvas.Pen.PenMode := pmCopy;
    PControl(Sender).Canvas.Pen.Color := $0000FF;
    PControl(Sender).Brush.Color := clWindow;
    if (odsFocused in ItemState) or (odsSelected in ItemState) then begin
      SetBkMode(DC, transparent);
      PControl(Sender).Canvas.Brush.color := clWindow;
      FillRect(DC, T_Rect, PControl(Sender).Canvas.Brush.Handle);
      if (not (odsFocused in ItemState)) and ((odsSelected in ItemState)) then begin
        PControl(Sender).Canvas.Brush.color := clInactiveBorder;
        SetTextColor(DC, Font.Color);
        fIcons.DrawingStyle := [];
      end
      else begin
        PControl(Sender).Canvas.Brush.color := clHighLight;
        SetTextColor(DC, $FFFFFF);
        fIcons.DrawingStyle := [dsBlend50];
      end;
      FillRect(DC, T_Rect, PControl(Sender).Canvas.Brush.Handle);
    end else begin
      SetTextColor(DC, Font.Color);
      PControl(Sender).Canvas.Brush.color := clWindow;
      SelectObject(DC, PControl(Sender).Canvas.Brush.Handle);
      FillRect(DC, B_Rect, PControl(Sender).Canvas.Brush.Handle);
      fIcons.DrawingStyle := [];
    end;
    Ico := FileIconSystemIdx(Path + PControl(Sender).Items[ItemIdx]);
    fIcons.Draw(Ico, DC, Rect.Left + 1, Rect.Top);
    DrawText(DC, PKOLChar(PControl(Sender).Items[ItemIdx]), Length(PControl(Sender).Items[ItemIdx]), T_Rect, DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX);
  end;
  PControl(Sender).Update;
  Result := True;         ///
end;

procedure TSPCFileList.DoMouseDblClk(Sender: PControl; var Mouse: TMouseEventData);
begin
  if ExecuteOnDblClk then
    {$IFDEF UNICODE_CTRLS}
    ShellExecuteW
    {$ELSE}
    ShellExecuteA
    {$ENDIF}
    (fControl.Handle, nil, PKOLChar(Path + Sender.Items[CurIndex]), '', '', SW_SHOW)
  else
    if Assigned(fOnMouseDblClick) then fOnMouseDblClick(@Self, Mouse);
end;

procedure TSPCFileList.SetSortBy(Value: TSortBy);
begin
  fSortBy := Value;
  Path := Path;
end;

procedure TSPCFileList.SortByName;
begin
  _SortBy := sbName;
end;

procedure TSPCFileList.SortByExtention;
begin
  _SortBy := sbExtention;
end;

{ TSPCFilterCombo }

function GetLastPos(c: char; s: string): Integer;
var
  i                 : Integer;
begin
  Result := 0;
  for i := 1 to Length(s) do if s[i] = c then Result := i;
end;

function NewTSPCFilterComboBox;
var
  p                 : PSPCFilterCombo;
  c                 : PControl;
begin
  c := NewComboBox(AOwner, [coReadOnly]);
  New(p, create);
  AOwner.Add2AutoFree(p);
  p.fControl := c;
  p.fFont := NewFont;
  p.fControl.Font.Assign(p.fFont);
  p.Font.FontHeight := -8;
  p.fControl.Font.FontHeight := -8;
  p.fControl.OnChange := p.DoChange;
  p.fControl.OnMeasureItem := p.DoMeasureItem;
  p.fFilterItems := NewList;
  p.fCreated := False;
  p.fInitialized := 0;
  Result := p;
end;

function TSPCFilterCombo.SetAlign(Value: TControlAlign): PSPCFilterCombo;
begin
  fControl.Align := Value;
  Result := @Self;
end;

procedure TSPCFilterCombo.Add;
begin
  fFilterItems.Add(TFilterItem.Create);
  TFilterItem(fFilterItems.Items[fFilterItems.Count - 1]).Description := Copy(fNewFilter, 1, Pos('|', fNewFilter) - 1);
  TFilterItem(fFilterItems.Items[fFilterItems.Count - 1]).Filter := Copy(fNewFilter, Pos('|', fNewFilter) + 1, Length(fNewFilter) - Pos('|', fNewFilter));
  BuildList;
end;

procedure TSPCFilterCombo.DeleteItem;
begin
  fFilterItems.Delete(Index);
end;

function TSPCFilterCombo.Count: Integer;
begin
  Result := fFilterItems.Count;
end;

function TSPCFilterCombo.GetFilterItem;
begin
  Result := fFilterItems.Items[Index];
end;

procedure TSPCFilterCombo.Update;
begin
  DoChange(@Self);
end;

procedure TSPCFilterCombo.DoChange(Obj: PObj);
begin
  Filter := TFilterItem(fFilterItems.Items[fControl.CurIndex]).Filter;
  if Assigned(fOnChange) then fOnChange(@Self);
  if Assigned(fFileListBox) then fFileListBox.Filters := Filter;
end;

destructor TSPCFilterCombo.Destroy;
begin
  fFont.Free;
  inherited;
end;

function TSPCFilterCombo.SetPosition(X, Y: integer): PSPCFilterCombo;
begin
  fControl.Left := X;
  fControl.Top := Y;
  Result := @self;
end;

function TSPCFilterCombo.SetSize(X, Y: integer): PSPCFilterCombo;
begin
  fControl.Width := X;
  fControl.Height := Y;
  Result := @self;
end;

function TSPCFilterCombo.GetFont;
begin
  Result := fFont;
  fControl.Color := $FFFFFF;
end;

procedure TSPCFilterCombo.SetFont(Value: PGraphicTool);
begin
  fFont := Value;
end;

procedure TSPCFilterCombo.BuildList;
var
  i                 : Integer;
begin
  fControl.Color := Color;
  fControl.Font.Assign(Font);
  fControl.Clear;
  if fFilterItems.Count > 0 then
    for i := 1 to fFilterItems.Count do fControl.Add(TFilterItem(fFilterItems.Items[i - 1]).Description);
end;

procedure TSPCFilterCombo.SetFilter(Value: string);
begin
  fFilter := Value;
  if Assigned(fOnChange) then fOnChange(@Self);
end;

procedure TSPCFilterCombo.SetCurIndex(Value: Integer);
begin
  fCurIndex := Value;
  fControl.CurIndex := Value;
  Inc(fInitialized);
  if fInitialized > 2 then fInitialized := 2;
  if Assigned(fOnChange) then if fInitialized = 2 then fOnChange(@Self);
end;

function TSPCFilterCombo.GetHeight: Integer;
begin
  Result := fControl.Height;
end;

procedure TSPCFilterCombo.SetHeight(Value: Integer);
begin
  fControl.Height := Value;
end;

function TSPCFilterCombo.GetWidth: Integer;
begin
  Result := fControl.Width;
end;

procedure TSPCFilterCombo.SetWidth(Value: Integer);
begin
  fControl.Width := Value;
end;

function TSPCFilterCombo.GetTop: Integer;
begin
  Result := fControl.Top;
end;

procedure TSPCFilterCombo.SetTop(Value: Integer);
begin
  fControl.Top := Value;
end;

function TSPCFilterCombo.GetLeft: Integer;
begin
  Result := fControl.Left;
end;

procedure TSPCFilterCombo.SetLeft(Value: Integer);
begin
  fControl.Left := Value;
end;

function TSPCFilterCombo.DoMeasureItem(Sender: PObj; Idx: Integer): Integer;
begin
  Result := 16;
end;

function TSPCFilterCombo.GetItem(Index: Integer): string;
begin
  Result := fControl.Items[Index];
end;

procedure TSPCFilterCombo.SetItem(Index: Integer; Value: string);
begin
  if Index + 1 > fFilterItems.Count then fFilterItems.Add(TFilterItem.Create);
  TFilterItem(fFilterItems.Items[Index]).Description := Copy(Value, 1, Pos('|', Value) - 1);
  TFilterItem(fFilterItems.Items[Index]).Filter := Copy(Value, Pos('|', Value) + 1, Length(Value) - Pos('|', Value));
  BuildList;
end;

function TSPCFilterCombo.GetFilter: string;
begin
  Result := TFilterItem(fFilterItems.Items[fControl.CurIndex]).Filter;
end;

function TSPCFilterCombo.GetCurIndex: Integer;
begin
  Result := fControl.CurIndex;
end;

{ TSPCStatus }

function NewTSPCStatusBar;
var
  p                 : PSPCStatus;
  c                 : PControl;
  Style             : DWord;
begin
  Style := $00000000;
  Style := Style or WS_VISIBLE or WS_CHILD or WS_CLIPSIBLINGS or WS_CLIPCHILDREN; //msctls_statusbar32
  c := _NewControl(AOwner, 'msctls_statusbar32', Style, True, nil);
  //  c:=_NewStatusBar(AOwner);
  c.Style := Style;
  c.ExStyle := c.ExStyle xor WS_EX_CLIENTEDGE;
  c.BringToFront;
  New(p, create);
  p.fControl := c;
  Result := p;
end;

destructor TSPCStatus.Destroy;
begin
  fFont.Free;
  inherited;
end;

function TSPCStatus.SetAlign(Value: TControlAlign): PSPCStatus;
begin
  fControl.Align := Value;
  Result := @Self;
end;

function TSPCStatus.SetPosition(X, Y: integer): PSPCStatus;
begin
  fControl.Left := X;
  fControl.Top := Y;
  Result := @self;
end;

function TSPCStatus.SetSize(X, Y: integer): PSPCStatus;
begin
  fControl.Width := X;
  fControl.Height := Y;
  Result := @self;
end;

function TSPCStatus.GetFont;
begin
  Result := fControl.Font;
end;

procedure TSPCStatus.SetFont(Value: PGraphicTool);
begin
  fControl.Font.Assign(Value);
end;

function TSPCStatus.GetHeight: Integer;
begin
  Result := fControl.Height;
end;

procedure TSPCStatus.SetHeight(Value: Integer);
begin
  fControl.Height := Value;
end;

function TSPCStatus.GetWidth: Integer;
begin
  Result := fControl.Width;
end;

procedure TSPCStatus.SetWidth(Value: Integer);
begin
  fControl.Width := Value;
end;

function TSPCStatus.GetTop: Integer;
begin
  Result := fControl.Top;
end;

procedure TSPCStatus.SetTop(Value: Integer);
begin
  fControl.Top := Value;
end;

function TSPCStatus.GetLeft: Integer;
begin
  Result := fControl.Left;
end;

procedure TSPCStatus.SetLeft(Value: Integer);
begin
  fControl.Left := Value;
end;

procedure TSPCStatus.SetSimpleStatusText(Value: string);
begin
  fControl.Caption := Value;
end;

function TSPCStatus.GetSimpleStatusText: string;
begin
  Result := fControl.Caption;
end;

end.