-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExtListView.pas
3240 lines (2894 loc) · 99.5 KB
/
ExtListView.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
{$I DFS.INC} { Standard defines for all Delphi Free Stuff components }
{.$DEFINE DFS_DEBUG}
{.$DEFINE DFS_TRY_BACKGROUND_IMAGE}
{------------------------------------------------------------------------------}
{ TdfsExtListView v3.72 }
{------------------------------------------------------------------------------}
{ A list view control that enables access to the new style types provieded }
{ by the updated list view control. The updated list view is provided in }
{ the COMCTL32.DLL file that comes with Microsoft's new internet software. }
{ }
{ Copyright 1998-2001, Brad Stowers. All Rights Reserved. }
{ }
{ Copyright: }
{ All Delphi Free Stuff (hereafter "DFS") source code is copyrighted by }
{ Bradley D. Stowers (hereafter "author"), and shall remain the exclusive }
{ property of the author. }
{ }
{ Distribution Rights: }
{ You are granted a non-exlusive, royalty-free right to produce and distribute }
{ compiled binary files (executables, DLLs, etc.) that are built with any of }
{ the DFS source code unless specifically stated otherwise. }
{ You are further granted permission to redistribute any of the DFS source }
{ code in source code form, provided that the original archive as found on the }
{ DFS web site (http://www.delphifreestuff.com) is distributed unmodified. For }
{ example, if you create a descendant of TDFSColorButton, you must include in }
{ the distribution package the colorbtn.zip file in the exact form that you }
{ downloaded it from http://www.delphifreestuff.com/mine/files/colorbtn.zip. }
{ }
{ Restrictions: }
{ Without the express written consent of the author, you may not: }
{ * Distribute modified versions of any DFS source code by itself. You must }
{ include the original archive as you found it at the DFS site. }
{ * Sell or lease any portion of DFS source code. You are, of course, free }
{ to sell any of your own original code that works with, enhances, etc. }
{ DFS source code. }
{ * Distribute DFS source code for profit. }
{ }
{ Warranty: }
{ There is absolutely no warranty of any kind whatsoever with any of the DFS }
{ source code (hereafter "software"). The software is provided to you "AS-IS", }
{ and all risks and losses associated with it's use are assumed by you. In no }
{ event shall the author of the softare, Bradley D. Stowers, be held }
{ accountable for any damages or losses that may occur from use or misuse of }
{ the software. }
{ }
{ Support: }
{ Support is provided via the DFS Support Forum, which is a web-based message }
{ system. You can find it at http://www.delphifreestuff.com/discus/ }
{ All DFS source code is provided free of charge. As such, I can not guarantee }
{ any support whatsoever. While I do try to answer all questions that I }
{ receive, and address all problems that are reported to me, you must }
{ understand that I simply can not guarantee that this will always be so. }
{ }
{ Clarifications: }
{ If you need any further information, please feel free to contact me directly.}
{ This agreement can be found online at my site in the "Miscellaneous" section.}
{------------------------------------------------------------------------------}
{ The lateset version of my components are always available on the web at: }
{ http://www.delphifreestuff.com/ }
{ See ELV.txt for notes, known issues, and revision history. }
{------------------------------------------------------------------------------}
{ Date last modified: June 28, 2001 }
{------------------------------------------------------------------------------}
unit ExtListView;
interface
{$IFNDEF DFS_WIN32}
ERROR! This unit only available for Delphi 2.0 or higher!!!
{$ENDIF}
uses
Windows, Messages, Classes, Controls, ComCtrls, CommCtrl, SysUtils, Graphics,
{$IFDEF DFS_COMPILER_4_UP}
ImgList,
{$ENDIF}
StdCtrls, Menus, EnhListView;
const
{ This shuts up C++Builder 3 about the redefiniton being different. There
seems to be no equivalent in C1. Sorry. }
{$IFDEF DFS_CPPB_3_UP}
{$EXTERNALSYM DFS_COMPONENT_VERSION}
{$ENDIF}
DFS_COMPONENT_VERSION = 'TdfsExtListView v3.72';
// Setting a subitem image (lvxSubItemImages ExtendStyle) to -1 does not
// properly clear the image for the subitem. The current COMCTL32.DLL
// implementation does not seem to store this value and instead it gets a
// random value assigned to it. The work-around that I have found is to set
// the index to a value that does not exist in the image list. To make this
// a bit easier, I have declared this constant. Assigning this value to
// SubItem_ImageIndex[itemindex] will clear the image from the subitem as long
// as your image list does not have more than 2,147,483,646 images in it. :)
const
ELV_NO_SUBITEM_IMAGE = MAXINT - 1;
// C3 and D4 CommCtrl.pas have almost everything we need
{$IFDEF DFS_CPPB_3_UP}
{$DEFINE DFS_C3D4COMMCTRL}
{$ELSE} {$IFDEF DFS_DELPHI_4_UP}
{$DEFINE DFS_C3D4COMMCTRL}
{$ENDIF} {$ENDIF}
{$IFNDEF DFS_C3D4COMMCTRL}
type
TLVDispInfo = TLVDispInfoA; // Borland forgot this one in D2, D3 & C1s
{$ENDIF}
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVIF_INDENT = $0010;
LVIF_NORECOMPUTE = $0800;
{.$IFDEF DFS_DELPHI_2}
{ These are in COMMCTRL unit
LVCF_FMT = $0001;
LVCF_WIDTH = $0002;
LVCF_TEXT = $0004;
LVCF_SUBITEM = $0008;
}
{.$ENDIF}
LVCF_IMAGE = $0010;
LVCF_ORDER = $0020;
{.$IFDEF DFS_DELPHI_2}
{ These are in COMMCTRL unit
LVCFMT_LEFT = $0000;
LVCFMT_RIGHT = $0001;
LVCFMT_CENTER = $0002;
LVCFMT_JUSTIFYMASK = $0003;
}
{.$ENDIF}
LVCFMT_IMAGE = $0800; // Item displays an image from an image list.
LVCFMT_BITMAP_ON_RIGHT = $1000; // Image appears to right of Text.
LVCFMT_COL_HAS_IMAGES = $8000; // Undocumented.
LVIS_ACTIVATING = $0020;
{$ENDIF}
type
PLVItemEx = ^TLVItemEx;
TLVItemEx = packed record
mask: UINT;
iItem: Integer;
iSubItem: Integer;
state: UINT;
stateMask: UINT;
pszText: PAnsiChar;
cchTextMax: Integer;
iImage: Integer;
lParam: LPARAM;
iIndent: integer;
end;
PLVDispInfoEx = ^TLVDispInfoEx;
TLVDispInfoEx = packed record
hdr: TNMHDR;
item: TLVItemEx;
end;
TLVColumnEx = packed record
mask: UINT;
fmt: Integer;
cx: Integer;
pszText: PAnsiChar;
cchTextMax: Integer;
iSubItem: Integer;
iImage: integer; // New
iOrder: integer; // New
end;
// These functions already exist, and there is no way to override them, so I'll
// just rename them and you can use them as best you can.
function ListView_GetColumnEx(LVWnd: HWND; iCol: Integer;
var pcol: TLVColumnEx): Bool;
function ListView_SetColumnEx(LVWnd: HWnd; iCol: Integer;
const pcol: TLVColumnEx): Bool;
function ListView_InsertColumnEx(LVWnd: HWND; iCol: Integer;
const pcol: TLVColumnEx): Integer;
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVM_GETHEADER = LVM_FIRST + 31;
function ListView_GetHeader(LVWnd: HWnd): HWnd;
{$ENDIF}
{$IFNDEF DFS_COMPILER_3_UP}
const
LVM_SETICONSPACING = LVM_FIRST + 53;
// -1 for cx and cy means we'll use the default (system settings)
// 0 for cx or cy means use the current setting (allows you to change just one
// param)
function ListView_SetIconSpacing(LVWnd: HWnd; cx, cy: integer): DWORD;
const
LVS_EX_GRIDLINES = $00000001; // Report mode only.
LVS_EX_SUBITEMIMAGES = $00000002; // Report mode only.
LVS_EX_CHECKBOXES = $00000004;
LVS_EX_TRACKSELECT = $00000008;
LVS_EX_HEADERDRAGDROP = $00000010; // Report mode only.
LVS_EX_FULLROWSELECT = $00000020; // Report mode only.
LVS_EX_ONECLICKACTIVATE = $00000040;
LVS_EX_TWOCLICKACTIVATE = $00000080;
LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54; // optional wParam = mask
function ListView_SetExtendedListViewStyle(LVWnd: HWnd; ExStyle: LPARAM): DWORD;
const
LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55;
function ListView_GetExtendedListViewStyle(LVWnd: HWnd): DWORD;
{$ENDIF}
(* These were already defined in everything...
const
LVIR_BOUNDS = 0;
LVIR_ICON = 1;
LVIR_LABEL = 2;
LVIR_SELECTBOUNDS = 3;
*)
{$IFDEF DFS_COMPILER_2}
const
LVM_GETSUBITEMRECT = LVM_FIRST + 56;
function ListView_GetSubItemRect(LVWnd: HWnd; ParentItem, SubItem,
Code: integer; var Rect: TRect): boolean;
const
LVM_SUBITEMHITTEST = LVM_FIRST + 57;
{$ENDIF}
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVS_EX_FLATSB = $00000100;
LVS_EX_REGIONAL = $00000200;
LVS_EX_INFOTIP = $00000400;
LVS_EX_UNDERLINEHOT = $00000800;
LVS_EX_UNDERLINECOLD = $00001000;
LVS_EX_MULTIWORKAREAS = $00002000;
// Pass the LVS_EX_* styles you want to modify in Mask and ExStyle will apply
// only to those. Others will be left in current state. For example, if you
// pass LVS_EX_FULLROWSELECT for Mask and 0 for ExStyle, the
// LVS_EX_FULLROWSELECT style will be cleared, but all other styles will remain
// the same.
function ListView_SetExtendedListViewStyleEx(LVWnd: HWnd; Mask: DWord;
ExStyle: LPARAM): DWORD;
{$ENDIF}
// Should be COMPILER not DELPHI, but can't get Builder 5 to compile it.
{$IFNDEF DFS_CPPB}
{$IFNDEF DFS_DELPHI_7_UP}
const
LVS_EX_LABELTIP = $00004000; // Requires ComCtl32.DLL v5.80
{$ENDIF}
{$ENDIF}
(*
{$IFNDEF DFS_COMPILER_7_UP}
const
LVS_EX_LABELTIP = $00004000; // Requires ComCtl32.DLL v5.80
{$ENDIF}
*)
{$IFNDEF DFS_C3D4COMMCTRL}
// C3 & D4 users don't need this because their COMMCTRL.PAS file has it right
// and they can simply use the existing TLVHitTestInfo and
// ListView_SubItemHitTest()
type
PLVHitTestInfoEx = ^TLVHitTestInfoEx;
TLVHitTestInfoEx = packed record
pt: TPoint;
flags: UINT;
iItem: integer;
iSubItem: integer;
end;
function ListView_SubItemHitTestEx(LVWnd: HWnd;
var HitTestInfo: TLVHitTestInfoEx): integer;
{$ENDIF}
{$IFNDEF DFS_COMPILER_3_UP}
const
LVM_SETCOLUMNORDERARRAY = LVM_FIRST + 58;
function ListView_SetColumnOrderArray(LVWnd: HWnd; Count: integer;
IntArray: PIntArray): boolean;
const
LVM_GETCOLUMNORDERARRAY = LVM_FIRST + 59;
function ListView_GetColumnOrderArray(LVWnd: HWnd; Count: integer;
IntArray: PIntArray): boolean;
const
LVM_SETHOTITEM = LVM_FIRST + 60;
function ListView_SetHotItem(LVWnd: HWnd; Item: integer): integer;
const
LVM_GETHOTITEM = LVM_FIRST + 61;
function ListView_GetHotItem(LVWnd: HWnd): integer;
const
LVM_SETHOTCURSOR = LVM_FIRST + 62;
function ListView_SetHotCursor(LVWnd: HWnd; Cursor: HCursor): HCursor;
const
LVM_GETHOTCURSOR = LVM_FIRST + 63;
function ListView_GetHotCursor(LVWnd: HWnd): HCursor;
const
LVM_APPROXIMATEVIEWRECT = LVM_FIRST + 64;
function ListView_ApproximateViewRect(LVWnd: HWnd; Width, Height,
Count: integer): DWORD;
const
LVM_SETWORKAREA = LVM_FIRST + 65;
function ListView_SetWorkArea(LVWnd: HWnd; const Rect: TRect): boolean;
function ListView_GetCheckState(LVWnd: HWnd; Index: UINT): boolean;
procedure ListView_SetCheckState(LVWnd: HWnd; Index: UINT; Checked: boolean);
{$ENDIF}
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVSICF_NOINVALIDATEALL = $00000001;
LVSICF_NOSCROLL = $00000002;
procedure ListView_SetItemCountEx(LVWnd: HWnd; Items: integer; Flags: DWORD);
{$ENDIF}
{$IFNDEF DFS_COMPILER_3_UP}
const
// New list view style flags.
LVS_OWNERDATA = $1000; // Specifies a "virtual" control.
// New notification messages.
LVN_ODCACHEHINT = LVN_FIRST-13;
LVN_ODFINDITEMA = LVN_FIRST-52;
LVN_ODFINDITEMW = LVN_FIRST-79;
LVN_ODFINDITEM = LVN_ODFINDITEMA;
{$ENDIF}
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVN_ITEMACTIVATE = LVN_FIRST-14;
LVN_ODSTATECHANGED = LVN_FIRST-15;
LVN_MARQUEEBEGIN = LVN_FIRST-56;
{$ENDIF}
{$IFNDEF DFS_COMPILER_3_UP}
type
PNMCacheHint = ^TNMCacheHint;
TNMCacheHint = packed record
hdr: TNMHDR;
iFrom: integer;
iTo: integer;
end;
PNMFindItem = ^TNMFindItem;
TNMFindItem = packed record
hdr: TNMHDR;
iStart: integer;
lvif: TLVFindInfo;
end;
{$ENDIF}
type
PNMODStateChange = ^TNMODStateChange;
TNMODStateChange = packed record
hdr: TNMHDR;
iFrom: integer;
iTo: integer;
uNewState: UINT;
uOldState: UINT;
end;
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVM_GETSELECTIONMARK = (LVM_FIRST + 66);
function ListView_GetSelectionMark(LVWnd: HWnd): integer;
const
LVM_SETSELECTIONMARK = (LVM_FIRST + 67);
function ListView_SetSelectionMark(LVWnd: HWnd; iIndex: integer): integer;
const
LVM_SETHOVERTIME = (LVM_FIRST + 71);
function ListView_SetHoverTime(LVWnd: HWnd; dwHoverTimeMS: DWORD): DWORD;
const
LVM_GETHOVERTIME = (LVM_FIRST + 72);
function ListView_GetHoverTime(LVWnd: HWnd): DWORD;
const
LVM_SETTOOLTIPS = (LVM_FIRST + 74);
function ListView_SetToolTips(LVWnd, NewWnd: HWnd): HWnd;
const
LVM_GETTOOLTIPS = (LVM_FIRST + 78);
function ListView_GetToolTips(LVWnd: HWnd): HWnd;
{$ENDIF}
type
PLVBkImageA = ^TLVBkImageA;
TLVBkImageA = packed record
ulFlags: ULONG; // LVBKIF_*
hbm: HBITMAP;
pszImage: PChar;
cchImageMax: UINT;
xOffsetPercent: integer;
yOffsetPercent: integer;
end;
PLVBkImageW = ^TLVBkImageW;
TLVBkImageW = packed record
ulFlags: ULONG; // LVBKIF_*
hbm: HBITMAP;
pszImage: PWideChar;
cchImageMax: UINT;
xOffsetPercent: integer;
yOffsetPercent: integer;
end;
PLVBkImage = PLVBkImageA;
TLVBkImage = TLVBkImageA;
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVBKIF_SOURCE_NONE = $00000000;
LVBKIF_SOURCE_HBITMAP = $00000001;
LVBKIF_SOURCE_URL = $00000002;
LVBKIF_SOURCE_MASK = $00000003;
LVBKIF_STYLE_NORMAL = $00000000;
LVBKIF_STYLE_TILE = $00000010;
LVBKIF_STYLE_MASK = $00000010;
LVM_SETBKIMAGEA = (LVM_FIRST + 68);
LVM_SETBKIMAGEW = (LVM_FIRST + 138);
LVM_GETBKIMAGEA = (LVM_FIRST + 69);
LVM_GETBKIMAGEW = (LVM_FIRST + 139);
const
LVM_SETBKIMAGE = LVM_SETBKIMAGEA;
function ListView_SetBkImage(LVWnd: HWnd; plvbki: PLVBkImage): BOOL;
const
LVM_GETBKIMAGE = LVM_GETBKIMAGEA;
function ListView_GetBkImage(LVWnd: HWnd; plvbki: PLVBkImage): BOOL;
const
LVN_HOTTRACK = (LVN_FIRST-21);
{$ENDIF}
type
PNMLVGetInfoTipA = ^TNMLVGetInfoTipA;
TNMLVGetInfoTipA = packed record
hdr: TNMHDR;
dwFlags: DWORD;
pszText: PChar;
cchTextMax: integer;
iItem: integer;
iSubItem: integer;
lParam: LPARAM;
end;
PNMLVGetInfoTipW = ^TNMLVGetInfoTipW;
TNMLVGetInfoTipW = packed record
hdr: TNMHDR;
dwFlags: DWORD;
pszText: PWideChar;
cchTextMax: integer;
iItem: integer;
iSubItem: integer;
lParam: LPARAM;
end;
PNMLVGetInfoTip = PNMLVGetInfoTipA;
TNMLVGetInfoTip = TNMLVGetInfoTipA;
{$IFNDEF DFS_C3D4COMMCTRL}
// NMLVGETINFOTIPA.dwFlag values
const
LVGIT_UNFOLDED = $0001;
LVN_GETINFOTIPA = (LVN_FIRST-57);
LVN_GETINFOTIPW = (LVN_FIRST-58);
LVN_GETINFOTIP = LVN_GETINFOTIPA;
{$ENDIF}
type
EELVException = class(Exception);
EELVOldComCtl = class(EELVException);
// New extended style flags converted to set format (RPM = Report Mode Only).
// lvxGridlines: Adds grid lines to seperate items and columns. RPM
// lvxSubItemImages: Allows images to be displayed for subitems. RPM
// lvxCheckboxes: Adds checkboxes to items. Checked items are stored
// internally as selected items.
// lvxTrackSelect: Tracks the mouse and highlights the item it currently
// positioned over by changing it's color. If mouse is left over an
// item for a brief period of time, it will be automatically selected.
// lvxHeaderDragDrop: Allows headers to be dragged to new positions and
// dropped, allowing users to reorder column information.
// lvxFullRowSelect: Allows user to click anywhere on an item to select it,
// highlighting the entire length of the item. Without this style,
// users must click inside the Text of column 0. It is only useful in
// vsReport view style.
// lvxOneClickActivate: Sends an LVN_ITEMACTIVATE notification message to
// the parent when the user clicks an item.
// lvxTwoClickActivate: Sends an LVN_ITEMACTIVATE notification message to
// the parent when the user double clicks an item.
// lvxFlatScrollBar: Enables flat scroll bars in the list view.
// lvxInfoTip: Enables the OnInfoTip event that allows notification and/or
// modification of a tooltip before it is displayed. Only allowed for
// vsIcon ViewStyle.
// lvxUnderlineHot: Causes hot items to be displayed with underlined Text.
// This style is ignored if lvxOneClickActivate or lvxTwoClickActivate
// is not set.
// lvxUnderlineCold: Causes nonhot items to be displayed with underlined
// Text. This style is ignored if lvxOneClickActivate is not set.
// lvxLabelTip: If a partially hidden label in any list view mode lacks
// tooltip text, the list view control will unfold the label. If this
// style is not set, the list view control will unfold partly hidden
// labels only for the large icon mode. Requires ComCtl32.dll v5.80.
TLVExtendedStyle = (lvxGridLines, lvxSubItemImages, lvxCheckboxes,
lvxTrackSelect, lvxHeaderDragDrop, lvxFullRowSelect, lvxOneClickActivate,
lvxTwoClickActivate, lvxFlatScrollBar, lvxInfoTip, lvxUnderlineHot,
lvxUnderlineCold, lvxLabelTip);
// A set of the new style bits.
TLVExtendedStyles = set of TLVExtendedStyle;
TLVItemCountFlag = (lvsicfNoInvalidateAll, lvsicfNoScroll);
TLVItemCountFlags = set of TLVItemCountFlag;
TLVVMMaskItem = (lvifText, lvifImage, lvifParam, lvifState, lvifIndent);
TLVVMMaskItems = set of TLVVMMaskItem;
TLVVMStateMaskItem = (lvisCut, lvisDropHighlighted, lvisFocused, lvisSelected,
lvisOverlayMask);
TLVVMStateMaskItems = set of TLVVMStateMaskItem;
TColumnImageAlign = (ciaLeftOfText, ciaRightOfText);
TLVItemCheckedEvent = procedure (Sender: TObject; ItemIndex: integer;
Checked: boolean) of object;
TLVMarqueeBeginEvent = procedure(Sender: TObject;
var CanBegin: boolean) of object;
TLVItemActivateEvent = TNotifyEvent;
TLVInfoTipEvent = procedure(Sender: TObject; ItemIndex, SubItemIndex: integer;
Current: string; var Additional: string) of object;
TLVHotTrackEvent = procedure(Sender: TObject; var ItemIndex: integer;
SubItemIndex: integer; Location: TPoint;
var AllowSelect: boolean) of object;
TLVVMGetItemInfoEvent = procedure(Sender: TObject; Item, SubItem: integer;
var Mask: TLVVMMaskItems; var Image: integer; var OverlayImage,
StateImage: word; var Param: LPARAM; var State: UINT; var StateMask: UINT;
var Indent: integer; var Text: string) of object;
TLVVMCacheHintEvent = procedure(Sender: TObject;
var HintInfo: TNMCacheHint) of object;
TLVVMFindItemEvent = procedure(Sender: TObject; var FindInfo: TNMFindItem;
var Found: integer) of object;
TLVVMStateChangedEvent = procedure(Sender: TObject;
var StateInfo: TNMODStateChange) of object;
TLVVMCaptionEditedEvent = procedure (Sender: TObject; Item: integer;
Canceled: boolean; const Text: string) of object;
{$IFNDEF DFS_COMPILER_4_UP}
TLVSubItemImageEvent = procedure(Sender: TObject; Item: TListItem; SubItem: Integer;
var ImageIndex: Integer) of object;
{$ENDIF}
TCustomExtListView = class; { forward declaration }
{$IFDEF DFS_TRY_BACKGROUND_IMAGE}
// Class for BackgroundImage property
TELVBackgroundImage = class(TPersistent)
private
FOwningListView: TCustomExtListView;
FFilename: string;
FBrushBmp: TBitmap;
FTile: boolean;
FXOffsetPercent: integer;
FYOffsetPercent: integer;
protected
procedure SetFilename(const Val: string);
procedure SetTile(Val: boolean);
procedure SetXOffsetPercent(Val: integer);
procedure SetYOffsetPercent(Val: integer);
procedure ApplyToListView; virtual;
public
constructor Create(AOwner: TCustomExtListView); virtual;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
published
property Filename: string
read FFilename
write SetFilename;
property Tile: boolean
read FTile
write SetTile
default FALSE;
property XOffsetPercent: integer
read FXOffsetPercent
write SetXOffsetPercent
default 0;
property YOffsetPercent: integer
read FYOffsetPercent
write SetYOffsetPercent
default 0;
end;
{$ENDIF}
// Class for saved settings
TdfsExtLVSaveSettings = class(TdfsEnhLVSaveSettings)
private
FSaveColumnOrder: boolean;
public
constructor Create; override;
procedure StoreColumnOrder(ColCount: integer;
const IntArray: array of integer);
procedure ReadColumnOrder(ColCount: integer;
var IntArray: array of integer);
published
property SaveColumnOrder: boolean
read FSaveColumnOrder
write FSaveColumnOrder
default TRUE;
end;
TdfsExtListColumn = class(TCollectionItem)
private
FSmallImageIndex: Integer;
FImageAlignment : TColumnImageAlign;
FAllowResize: boolean;
procedure DoChange;
procedure SetSmallImageIndex(Value: Integer);
procedure SetImageAlignment(Value: TColumnImageAlign);
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
published
property ImageIndex: integer
read FSmallImageIndex
write SetSmallImageIndex
default -1;
property ImageAlignment: TColumnImageAlign
read FImageAlignment
write SetImageAlignment
default ciaRightOfText;
property AllowResize: boolean
read FAllowResize
write FAllowResize
default TRUE;
end;
TdfsExtListColumns = class(TCollection)
private
FListView: TCustomExtListView;
function GetItem(Index: Integer): TdfsExtListColumn;
procedure SetItem(Index: Integer; Value: TdfsExtListColumn);
protected
function GetOwner: TPersistent; {$IFDEF DFS_COMPILER_3_UP} override; {$ENDIF}
procedure Update(Item: TCollectionItem); override;
public
constructor Create(AListView: TCustomExtListView);
procedure Assign(Source: TPersistent); override;
function Add: TdfsExtListColumn;
procedure Refresh;
property ListView: TCustomExtListView
read FListView;
property Items[Index: Integer]: TdfsExtListColumn
read GetItem
write SetItem;
default;
end;
// The new class.
TCustomExtListView = class(TCustomEnhListView)
private
FExtendedStyles: TLVExtendedStyles;
FColumnOrder: PIntArray;
FColumnOrderCount: integer;
FColumnsFormat: TdfsExtListColumns;
FVirtualMode: boolean;
FSaveSettings: TdfsExtLVSaveSettings;
FColumnsFormatChangeLink: TChangeLink;
FSelectionMark: integer;
FHoverTime: Longint;
FRequireComCtlUpdate: boolean;
{$IFDEF DFS_TRY_BACKGROUND_IMAGE}
FBackgroundImage: TELVBackgroundImage;
{$ENDIF}
FItemCountEx: integer;
FItemCountExFlags: TLVItemCountFlags;
FRecreateStream: TMemoryStream;
{$IFDEF DFS_COMPILER_4_UP}
FInhibitFeedData: boolean;
{$ENDIF}
FChecked: boolean;
FCheckedListItemIndex: integer;
FOnItemChecked: TLVItemCheckedEvent;
FOnMarqueeBegin: TLVMarqueeBeginEvent;
FOnItemActivate: TLVItemActivateEvent;
FOnHotTrack: TLVHotTrackEvent;
FOnInfoTip: TLVInfoTipEvent;
FOnVMGetItemInfo: TLVVMGetItemInfoEvent;
FOnVMCacheHint: TLVVMCacheHintEvent;
FOnVMFindItem: TLVVMFindItemEvent;
FOnVMStateChanged: TLVVMStateChangedEvent;
FOnVMCaptionEdited: TLVVMCaptionEditedEvent;
// Function to convert from our set type to expected API value.
function SetValueToAPIValue(Styles: TLVExtendedStyles): LPARAM;
function SetValueFromAPIValue(Styles: DWORD): TLVExtendedStyles;
procedure ColumnHeaderImagesChange(Sender: TObject);
procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY;
procedure WMNotify(var Message: TWMNotify); message WM_NOTIFY;
function GetItemIndent(Index: integer): Integer;
procedure SetItemIndent(Index: integer; Value: Integer);
{$IFDEF DFS_COMPILER_4_UP}
procedure FeedOwnerDataMode(Sender: TObject; Item: TListItem);
{$ENDIF}
protected
// Property method for setting styles.
procedure SetExtendedStyles(Val: TLVExtendedStyles);
function GetExtendedStyles: TLVExtendedStyles;
function GetHeaderHandle: HWnd;
function GetSubItemRect(Item, SubItem: integer; Index: integer): TRect;
procedure SetHotItem(Val: integer);
function GetHotItem: integer;
procedure SetHotCursor(const Val: HCursor);
function GetHotCursor: HCursor;
procedure SetWorkArea(Rect: TRect);
procedure SetCheckState(Index: integer; Checked: boolean);
function GetCheckState(Index: integer): boolean;
procedure SetVirtualMode(Val: boolean);
procedure SetColumnsFormat(Value: TdfsExtListColumns);
function GetSubItemImageIndex(Item, SubItem: integer): integer;
procedure SetSubItemImageIndex(Item, SubItem, Value: integer);
function GetSelectionMark: integer;
procedure SetSelectionMark(Val: integer);
function GetHoverTime: Longint;
procedure SetHoverTime(Val: Longint);
procedure SetRequireComCtlUpdate(Value: boolean);
{$IFDEF DFS_TRY_BACKGROUND_IMAGE}
procedure SetBackgroundImage(Value: TELVBackgroundImage);
{$ENDIF}
function GetStateImages: {$IFDEF DFS_COMPILER_4_UP} TCustomImageList; {$ELSE} TImageList; {$ENDIF}
procedure SetStateImages(Value: {$IFDEF DFS_COMPILER_4_UP} TCustomImageList {$ELSE} TImageList {$ENDIF});
function GetSmallImages: {$IFDEF DFS_COMPILER_4_UP} TCustomImageList; {$ELSE} TImageList; {$ENDIF}
procedure SetSmallImages(Value: {$IFDEF DFS_COMPILER_4_UP} TCustomImageList {$ELSE} TImageList {$ENDIF});
function GetShowSortArrows: boolean;
procedure SetShowSortArrows(Value: boolean);
function GetVersion: string; override;
function GetSubItemText(Index, SubItem: integer): string; override;
function ActualColumnIndex(Index: integer): integer; override;
function GetActualColumn(Index: integer): TListColumn; override;
procedure DestroyWnd; override;
procedure RestoreChecks;
procedure SaveChecks;
procedure MeasureItem(var Height: UINT); override;
procedure DrawItem(var Canvas: TCanvas; Index: Integer; Rect: TRect;
State: TOwnerDrawState; var DefaultDrawing,
FullRowSelect: boolean); override;
procedure DrawSubItem(Index, SubItem: Integer; Rect: TRect;
State: TOwnerDrawState; var DefaultDrawing: boolean); override;
procedure DefaultDrawHeader(var Canvas: TCanvas; Index: Integer;
var Rect: TRect; Selected: boolean); override;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure Loaded; override;
procedure DefaultDrawItem(Index: Integer; Rect: TRect;
State: TOwnerDrawState; FullRowSelect: boolean); override;
procedure DefaultDrawSubItem(Index, SubItem: integer; Rect: TRect;
State: TOwnerDrawState); override;
// Event method handlers -- fire the events if they exist.
procedure ItemChecked(ItemIndex: integer; Checked: boolean); virtual;
function MarqueeBegin: boolean; virtual;
procedure ItemActivate; virtual;
function HotTrack(var Item: TNMListView): boolean; virtual;
procedure GetInfoTip(InfoTip: PNMLVGetInfoTip); virtual;
procedure VMGetDispInfo(var ItemInfo: TLVItemEx); virtual;
procedure VMCacheHint(var HintInfo: TNMCacheHint); virtual;
function VMFindItem(var FindInfo: TNMFindItem): integer; virtual;
procedure VMStateChanged(var StateInfo: TNMODStateChange); virtual;
procedure VMCaptionEdited(Item: integer; Canceled: boolean; const Text: string);
// These should be redeclared as PUBLIC as needed.
property HeaderHandle: HWnd
read GetHeaderHandle;
property SubItem_BoundsRect[Item: integer; SubItem: integer]: TRect
index LVIR_BOUNDS
read GetSubItemRect;
property SubItem_IconRect[Item: integer; SubItem: integer]: TRect
index LVIR_ICON
read GetSubItemRect;
property SubItem_LabelRect[Item: integer; SubItem: integer]: TRect
index LVIR_LABEL
read GetSubItemRect;
property SubItem_SelectBoundsRect[Item: integer; SubItem: integer]: TRect
index LVIR_SELECTBOUNDS
read GetSubItemRect;
property HotItem: integer
read GetHotItem
write SetHotItem;
property HotCursor: HCursor
read GetHotCursor
write SetHotCursor;
property WorkArea: TRect
write SetWorkArea;
property IsChecked[Index: integer]: boolean
read GetCheckState
write SetCheckState;
property SubItem_ImageIndex[Item: integer; SubItem: integer]: integer
read GetSubItemImageIndex
write SetSubItemImageIndex;
property SelectionMark: integer
read GetSelectionMark
write SetSelectionMark;
property ItemIndent[Index: integer]: integer
read GetItemIndent
write SetItemIndent;
// These should be redeclared as PUBLIC or PUBLISHED as needed
property ExtendedStyles: TLVExtendedStyles
read GetExtendedStyles
write SetExtendedStyles
default [lvxInfoTip];
property VirtualMode: boolean
read FVirtualMode
write SetVirtualMode
default FALSE;
property HoverTime: Longint
read GetHoverTime
write SetHoverTime
default -1;
property RequireComCtlUpdate: boolean
read FRequireComCtlUpdate
write SetRequireComCtlUpdate
default FALSE;
{$IFDEF DFS_TRY_BACKGROUND_IMAGE}
property BackgroundImage: TELVBackgroundImage
read FBackgroundImage
write SetBackgroundImage;
{$ENDIF}
// Autosave settings property.
property SaveSettings: TdfsExtLVSaveSettings
read FSaveSettings
write FSaveSettings;
property ColumnsFormat: TdfsExtListColumns
read FColumnsFormat
write SetColumnsFormat;
// Events
property OnItemChecked: TLVItemCheckedEvent
read FOnItemChecked
write FOnItemChecked;
property OnMarqueeBegin: TLVMarqueeBeginEvent
read FOnMarqueeBegin
write FOnMarqueeBegin;
property OnItemActivate: TLVItemActivateEvent
read FOnItemActivate
write FOnItemActivate;
property OnHotTrack: TLVHotTrackEvent
read FOnHotTrack
write FOnHotTrack;
property OnInfoTip: TLVInfoTipEvent
read FOnInfoTip
write FOnInfoTip;
property OnVMGetItemInfo: TLVVMGetItemInfoEvent
read FOnVMGetItemInfo
write FOnVMGetItemInfo;
property OnVMCacheHint: TLVVMCacheHintEvent
read FOnVMCacheHint
write FOnVMCacheHint;
property OnVMFindItem: TLVVMFindItemEvent
read FOnVMFindItem
write FOnVMFindItem;
property OnVMStateChanged: TLVVMStateChangedEvent
read FOnVMStateChanged
write FOnVMStateChanged;
property OnVMCaptionEdited: TLVVMCaptionEditedEvent
read FOnVMCaptionEdited
write FOnVMCaptionEdited;
property ShowSortArrows: boolean
read GetShowSortArrows
write SetShowSortArrows
stored TRUE
default FALSE;
// Redeclare so we can reset checkboxes.
property StateImages: {$IFDEF DFS_COMPILER_4_UP} TCustomImageList {$ELSE} TImageList {$ENDIF}
read GetStateImages
write SetStateImages;
// Redeclare so we can know when it changes and hook into it.
property SmallImages: {$IFDEF DFS_COMPILER_4_UP} TCustomImageList {$ELSE} TImageList {$ENDIF}
read GetSmallImages
write SetSmallImages;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
// Force reset of column image information
procedure UpdateColumnsImages;
procedure UpdateColumnImage(Index: integer);
procedure SetIconSpacing(X, Y: integer);
function GetSubItemAt(X, Y: integer): string;
procedure SetColumnOrder(Count: integer; const IntArray: array of integer);
function GetColumnOrder(Count: integer;
var IntArray: array of integer): boolean;
function ApproximateViewRect(Count: integer;
const Proposed: TPoint): TPoint;
procedure SetItemCountEx(Count: integer; Flags: TLVItemCountFlags);
function StoreSettings: boolean; override;
function WriteSettings: boolean; override;
function LoadSettings: boolean; override;
function ReadSettings: boolean; override;
function CheckComCtlVersion(MajorHi, MajorLo,
MinorHi, MinorLo: word): boolean;
procedure ELV_EditCaption(Item: integer);
function ELV_GetNextItem(StartItem: integer; Direction: TSearchDirection;
States: TItemStates): integer;
procedure ELV_SetItemState(Index: integer; States: TItemStates;
Setting: boolean);
end;
TdfsExtListView = class(TCustomExtListView)
public
property LastColumnClicked;
property CurrentColumnWidth;
property HeaderHandle;
property SubItem_BoundsRect;
property SubItem_IconRect;
property SubItem_LabelRect;
property SubItem_SelectBoundsRect;
property HotItem;
property HotCursor;
property WorkArea;
property IsChecked;
property SubItem_ImageIndex;
property SelectionMark;
property ItemIndent;
property CurrentSortAscending;
published
property Columns;
property ColumnSearch;
property HideSelection;
property ExtendedStyles;
property VirtualMode;
property HoverTime;
property RequireComCtlUpdate;
{$IFDEF BACKGROUND_FIXED}
property BackgroundImage;
{$ENDIF}
property NoColumnResize;
property SaveSettings;
property ColumnsFormat;