-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclsTreeView.cls
3647 lines (3048 loc) · 122 KB
/
clsTreeView.cls
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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsTreeView"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'/* Rewrite of Carles P.V. api treeview
'/* http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=57047&lngWId=1
'/* Complete rewrite: changed subclasser, removed IPAO, added skinned scrollbars, unicode support
'/* custom checkboxes, and removed ole (will be moved to grid in 1.5)
Implements GXISubclass
Private Const ALLOCATE_SIZE As Long = 100
Private Const CCM_FIRST As Long = &H2000
Private Const CCM_SETUNICODEFORMAT As Long = (CCM_FIRST + 5)
Private Const CCM_GETUNICODEFORMAT As Long = (CCM_FIRST + 6)
Private Const CDDS_PREPAINT As Long = &H1
Private Const CDDS_POSTPAINT As Long = &H2
Private Const CDDS_PREERASE As Long = &H3
Private Const CDDS_POSTERASE As Long = &H4
Private Const CDDS_ITEM As Long = &H10000
Private Const CDDS_ITEMPREPAINT As Long = CDDS_ITEM Or CDDS_PREPAINT
Private Const CDDS_ITEMPOSTPAINT As Long = CDDS_ITEM Or CDDS_POSTPAINT
Private Const CDDS_SUBITEM As Long = &H20000
Private Const CDIS_SELECTED As Long = &H1
Private Const CDIS_GRAYED As Long = &H2
Private Const CDIS_DISABLED As Long = &H4
Private Const CDIS_CHECKED As Long = &H8
Private Const CDIS_FOCUS As Long = &H10
Private Const CDIS_DEFAULT As Long = &H20
Private Const CDIS_HOT As Long = &H40
Private Const CDIS_MARKED As Long = &H80
Private Const CDIS_INDETERMINATE As Long = &H100
Private Const CDRF_DODEFAULT As Long = &H0
Private Const CDRF_NOTIFYITEMDRAW As Long = &H20
Private Const CDRF_NOTIFYSUBITEMDRAW As Long = &H20
Private Const CLR_NONE As Long = &HFFFFFFFF
Private Const COLOR_WINDOW As Long = 5
Private Const COLOR_WINDOWTEXT As Long = 8
Private Const FW_NORMAL As Long = 400
Private Const FW_BOLD As Long = 700
Private Const GW_HWNDNEXT As Long = &H2
Private Const GWL_STYLE As Long = (-16)
Private Const GWL_EXSTYLE As Long = (-20)
Private Const ILC_MASK As Long = &H1
Private Const ILC_COLORDDB As Long = &HFE
Private Const ILC_COLOR32 As Long = &H20
Private Const LF_ANTIALIASED_QUALITY As Long = 4
Private Const LF_CLEARTYPE_QUALITY As Long = 5
Private Const LOGPIXELSY As Long = 90
Private Const MAX_PATH As Long = 260
Private Const MOUSEEVENTF_MOVE As Long = &H1
Private Const MOUSEEVENTF_LEFTDOWN As Long = &H2
Private Const MOUSEEVENTF_LEFTUP As Long = &H4
Private Const H_MAX As Long = &HFFFF + 1
Private Const NM_FIRST As Long = H_MAX
Private Const NM_CLICK As Long = (NM_FIRST - 2)
Private Const NM_DBLCLK As Long = (NM_FIRST - 3)
Private Const NM_RCLICK As Long = (NM_FIRST - 5)
Private Const NM_RDBLCLK As Long = (NM_FIRST - 6)
Private Const NM_SETFOCUS As Long = (NM_FIRST - 7)
Private Const NM_CUSTOMDRAW As Long = (NM_FIRST - 12)
Private Const OLE_FORMAT_ID As Long = &HFFFFB044
Private Const PATH_SEPARATOR As String = "\"
Private Const SII_SWAPMASK As Long = 3
Private Const SII_CHECKED As Long = 2
Private Const SII_UNCHECKED As Long = 1
Private Const SW_SHOW As Long = 5
Private Const SWP_NOSIZE As Long = &H1
Private Const SWP_NOMOVE As Long = &H2
Private Const SWP_NOZORDER As Long = &H4
Private Const SWP_NOACTIVATE As Long = &H10
Private Const SWP_FRAMECHANGED As Long = &H20
Private Const SWP_NOOWNERZORDER As Long = &H200
Private Const T_EXPAND_DELAY As Long = 1000
Private Const TVE_COLLAPSE As Long = &H1
Private Const TVE_EXPAND As Long = &H2
Private Const TVE_TOGGLE As Long = &H3
Private Const TVGN_ROOT As Long = &H0
Private Const TVGN_NEXT As Long = &H1
Private Const TVGN_PREVIOUS As Long = &H2
Private Const TVGN_PARENT As Long = &H3
Private Const TVGN_CHILD As Long = &H4
Private Const TVGN_DROPHILITE As Long = &H8
Private Const TVGN_CARET As Long = &H9
Private Const TVGN_FIRSTVISIBLE As Long = &H5
Private Const TVGN_NEXTVISIBLE As Long = &H6
Private Const TVGN_PREVIOUSVISIBLE As Long = &H7
Private Const TVGN_LASTVISIBLE As Long = &HA
Private Const TVI_ROOT As Long = &HFFFF0000
Private Const TVI_FIRST As Long = &HFFFF0001
Private Const TVI_LAST As Long = &HFFFF0002
Private Const TVI_SORT As Long = &HFFFF0003
Private Const TVIF_TEXT As Long = &H1
Private Const TVIF_IMAGE As Long = &H2
Private Const TVIF_PARAM As Long = &H4
Private Const TVIF_SELECTEDIMAGE As Long = &H20
Private Const TVIF_all As Long = TVIF_TEXT Or TVIF_IMAGE Or TVIF_PARAM Or TVIF_SELECTEDIMAGE
Private Const TVIF_CHILDREN As Long = &H40
Private Const TVIF_STATE As Long = &H8
Private Const TVIF_HANDLE As Long = &H10
Private Const TVIS_SELECTED As Long = &H2
Private Const TVIS_CUT As Long = &H4
Private Const TVIS_DROPHILITED As Long = &H8
Private Const TVIS_BOLD As Long = &H10
Private Const TVIS_EXPANDED As Long = &H20
Private Const TVIS_EXPANDEDONCE As Long = &H40
Private Const TVIS_STATEIMAGEMASK As Long = &HF000
Private Const TVHT_NOWHERE As Long = &H1
Private Const TVHT_ONITEMICON As Long = &H2
Private Const TVHT_ONITEMLABEL As Long = &H4
Private Const TVHT_ONITEMINDENT As Long = &H8
Private Const TVHT_ONITEMBUTTON As Long = &H10
Private Const TVHT_ONITEMRIGHT As Long = &H20
Private Const TVHT_ONITEMSTATEICON As Long = &H40
Private Const TVHT_ABOVE As Long = &H100
Private Const TVHT_BELOW As Long = &H200
Private Const TVHT_TORIGHT As Long = &H400
Private Const TVHT_TOLEFT As Long = &H800
Private Const TVHT_ONITEM As Long = TVHT_ONITEMICON Or TVHT_ONITEMLABEL Or TVHT_ONITEMSTATEICON
Private Const TV_FIRST As Long = &H1100
Private Const TVM_INSERTITEMA As Long = (TV_FIRST + 0)
Private Const TVM_DELETEITEM As Long = (TV_FIRST + 1)
Private Const TVM_EXPAND As Long = (TV_FIRST + 2)
Private Const TVM_GETITEMRECT As Long = (TV_FIRST + 4)
Private Const TVM_GETCOUNT As Long = (TV_FIRST + 5)
Private Const TVM_GETINDENT As Long = (TV_FIRST + 6)
Private Const TVM_SETINDENT As Long = (TV_FIRST + 7)
Private Const TVM_GETIMAGELIST As Long = (TV_FIRST + 8)
Private Const TVM_SETIMAGELIST As Long = (TV_FIRST + 9)
Private Const TVM_GETNEXTITEM As Long = (TV_FIRST + 10)
Private Const TVM_SELECTITEM As Long = (TV_FIRST + 11)
Private Const TVM_GETITEMA As Long = (TV_FIRST + 12)
Private Const TVM_SETITEMA As Long = (TV_FIRST + 13)
Private Const TVM_EDITLABELA As Long = (TV_FIRST + 14)
Private Const TVM_GETEDITCONTROL As Long = (TV_FIRST + 15)
Private Const TVM_HITTEST As Long = (TV_FIRST + 17)
Private Const TVM_CREATEDRAGIMAGE As Long = (TV_FIRST + 18)
Private Const TVM_SORTCHILDREN As Long = (TV_FIRST + 19)
Private Const TVM_ENSUREVISIBLE As Long = (TV_FIRST + 20)
Private Const TVM_ENDEDITLABELNOW As Long = (TV_FIRST + 22)
Private Const TVM_SETINSERTMARK As Long = (TV_FIRST + 26)
Private Const TVM_SETITEMHEIGHT As Long = (TV_FIRST + 27)
Private Const TVM_GETITEMHEIGHT As Long = (TV_FIRST + 28)
Private Const TVM_SETBKCOLOR As Long = (TV_FIRST + 29)
Private Const TVM_SETTEXTCOLOR As Long = (TV_FIRST + 30)
Private Const TVM_GETBKCOLOR As Long = (TV_FIRST + 31)
Private Const TVM_GETTEXTCOLOR As Long = (TV_FIRST + 32)
Private Const TVM_SETINSERTMARKCOLOR As Long = (TV_FIRST + 37)
Private Const TVM_GETINSERTMARKCOLOR As Long = (TV_FIRST + 38)
Private Const TVM_SETLINECOLOR As Long = (TV_FIRST + 40)
Private Const TVM_GETLINECOLOR As Long = (TV_FIRST + 41)
Private Const TVM_INSERTITEMW As Long = (TV_FIRST + 50)
Private Const TVM_GETITEMW As Long = (TV_FIRST + 62)
Private Const TVM_SETITEMW As Long = (TV_FIRST + 63)
Private Const TVM_EDITLABELW As Long = (TV_FIRST + 65)
Private Const TVN_FIRST As Long = -400
Private Const TVN_SELCHANGINGA As Long = (TVN_FIRST - 1)
Private Const TVN_SELCHANGEDA As Long = (TVN_FIRST - 2)
Private Const TVN_ITEMEXPANDINGA As Long = (TVN_FIRST - 5)
Private Const TVN_ITEMEXPANDEDA As Long = (TVN_FIRST - 6)
Private Const TVN_BEGINDRAGA As Long = (TVN_FIRST - 7)
Private Const TVN_DELETEITEMA As Long = (TVN_FIRST - 9)
Private Const TVN_BEGINLABELEDITA As Long = (TVN_FIRST - 10)
Private Const TVN_ENDLABELEDITA As Long = (TVN_FIRST - 11)
Private Const TVN_SELCHANGINGW As Long = (TVN_FIRST - 50)
Private Const TVN_SELCHANGEDW As Long = (TVN_FIRST - 51)
Private Const TVN_ITEMEXPANDINGW As Long = (TVN_FIRST - 54)
Private Const TVN_ITEMEXPANDEDW As Long = (TVN_FIRST - 55)
Private Const TVN_BEGINDRAGW As Long = (TVN_FIRST - 56)
Private Const TVN_DELETEITEMW As Long = (TVN_FIRST - 58)
Private Const TVN_BEGINLABELEDITW As Long = (TVN_FIRST - 59)
Private Const TVN_ENDLABELEDITW As Long = (TVN_FIRST - 60)
Private Const TVS_HASBUTTONS As Long = &H1
Private Const TVS_HASLINES As Long = &H2
Private Const TVS_LINESATROOT As Long = &H4
Private Const TVS_EDITLABELS As Long = &H8
Private Const TVS_DISABLEDRAGDROP As Long = &H10
Private Const TVS_SHOWSELALWAYS As Long = &H20
Private Const TVS_CHECKBOXES As Long = &H100
Private Const TVS_TRACKSELECT As Long = &H200
Private Const TVS_SINGLEEXPAND As Long = &H400
Private Const TVS_FULLROWSELECT As Long = &H1000
Private Const TVSIL_NORMAL As Long = &H0
Private Const TVSIL_STATE As Long = &H2
Private Const VER_PLATFORM_WIN32_NT As Long = 2
Private Const VK_LBUTTON As Long = &H1
Private Const VK_TAB As Long = &H9
Private Const WC_TREEVIEW As String = "SysTreeView32"
Private Const WM_SIZE As Long = &H5
Private Const WM_SETFOCUS As Long = &H7
Private Const WM_KILLFOCUS As Long = &H8
Private Const WM_SETREDRAW As Long = &HB
Private Const WM_SETFONT As Long = &H30
Private Const WM_MOUSEACTIVATE As Long = &H21
Private Const WM_NOTIFY As Long = &H4E
Private Const WM_KEYDOWN As Long = &H100
Private Const WM_KEYUP As Long = &H101
Private Const WM_CHAR As Long = &H102
Private Const WM_TIMER As Long = &H113
Private Const WM_HSCROLL As Long = &H114
Private Const WM_VSCROLL As Long = &H115
Private Const WM_MOUSEMOVE As Long = &H200
Private Const WM_LBUTTONUP As Long = &H202
Private Const WM_LBUTTONDOWN As Long = &H201
Private Const WM_RBUTTONDOWN As Long = &H204
Private Const WM_RBUTTONUP As Long = &H205
Private Const WM_MBUTTONDOWN As Long = &H207
Private Const WM_MBUTTONUP As Long = &H208
Private Const WM_MOUSELEAVE As Long = &H2A3
Private Const WS_TABSTOP As Long = &H10000
Private Const WS_BORDER As Long = &H800000
Private Const WS_CHILD As Long = &H40000000
Private Const WS_EX_CLIENTEDGE As Long = &H200
Private Const WS_EX_RTLREADING As Long = &H2000
Private Const WS_EX_LEFTSCROLLBAR As Long = &H4000
Private Const SB_LINEUP As Long = 0
Private Const SB_LINELEFT As Long = 0
Private Const SB_LINEDOWN As Long = 1
Private Const SB_LINERIGHT As Long = 1
Private Const SB_PAGEUP As Long = 2
Private Const SB_PAGELEFT As Long = 2
Private Const SB_PAGEDOWN As Long = 3
Private Const SB_PAGERIGHT As Long = 3
Private Const SB_TOP As Long = 6
Private Const SB_LEFT As Long = 6
Private Const SB_BOTTOM As Long = 7
Private Const SB_RIGHT As Long = 7
Private Const SB_ENDSCROLL As Long = 8
Private Enum TRACKMOUSEEVENT_FLAGS
TME_HOVER = &H1
TME_LEAVE = &H2
TME_QUERY = &H40000000
TME_CANCEL = &H80000000
End Enum
Public Enum ETVThemeLuminence
estThemeSoft = 0&
estThemePastel = 1&
estThemeHard = 2&
End Enum
Public Enum ETVThemeStyle
etvAzure = 0&
etvClassic = 1&
etvGloss = 2&
etvMetallic = 3&
etvXPSilver = 4&
etvXPBlue = 5&
etvXPGreen = 6&
etvVista = 7&
End Enum
Public Enum ETVBorderStyle
tbsNone = 0&
tbsFixedSingle = 1&
End Enum
Public Enum ETVScrollConstants
tvsHome = 0&
tvsPageUp = 1&
tvsUp = 2&
tvsDown = 3&
tvsPageDown = 4&
tvsEnd = 5&
tvsLeft = 6&
tvsPageLeft = 7&
tvsLineLeft = 8&
tvsLineRight = 9&
tvsPageRight = 10&
tvsRight = 11&
End Enum
Private Enum ETVStateConstants
tvcStateCut = TVIS_CUT
tvcStateDropHilited = TVIS_DROPHILITED
tvcStateBold = TVIS_BOLD
tvcStateExpanded = TVIS_EXPANDED
tvcStateExpandedOnce = TVIS_EXPANDEDONCE
End Enum
Private Enum SYSTEM_METRICS
SM_CXSCREEN = 0&
SM_CYSCREEN = 1&
SM_CXVSCROLL = 2&
SM_CYHSCROLL = 3&
SM_CYCAPTION = 4&
SM_CXBORDER = 5&
SM_CYBORDER = 6&
SM_CYVTHUMB = 9&
SM_CXHTHUMB = 10&
SM_CXICON = 11&
SM_CYICON = 12&
SM_CXCURSOR = 13&
SM_CYCURSOR = 14&
SM_CYMENU = 15&
SM_CXFULLSCREEN = 16&
SM_CYFULLSCREEN = 17&
SM_CYKANJIWINDOW = 18&
SM_MOUSEPRESENT = 19&
SM_CYVSCROLL = 20&
SM_CXHSCROLL = 21&
SM_CXMIN = 28&
SM_CYMIN = 29&
SM_CXSIZE = 30&
SM_CYSIZE = 31&
SM_CXFRAME = 32&
SM_CYFRAME = 33&
SM_CXMINTRACK = 34&
SM_CYMINTRACK = 35&
SM_CXSMICON = 49&
SM_CYSMICON = 50&
SM_CYSMCAPTION = 51&
SM_CXMINIMIZED = 57&
SM_CYMINIMIZED = 58&
SM_CXMAXTRACK = 59&
SM_CYMAXTRACK = 60&
SM_CXMAXIMIZED = 61&
SM_CYMAXIMIZED = 62&
End Enum
Private Type TVITEMA
Mask As Long
hItem As Long
State As Long
stateMask As Long
pszText As String
cchTextMax As Long
iImage As Long
iSelectedImage As Long
cChildren As Long
lParam As Long
End Type
Private Type TVITEMW
Mask As Long
hItem As Long
State As Long
stateMask As Long
pszText As Long
cchTextMax As Long
iImage As Long
iSelectedImage As Long
cChildren As Long
lParam As Long
End Type
Private Type TVITEMEXA
Mask As Long
hItem As Long
State As Long
stateMask As Long
pszText As String
cchTextMax As Long
iImage As Long
iSelectedImage As Long
cChildren As Long
lParam As Long
iIntegral As Long
End Type
Private Type TVINSERTSTRUCTA
hParent As Long
hInsertAfter As Long
Item As TVITEMEXA
End Type
Private Type TVITEMEXW
Mask As Long
hItem As Long
State As Long
stateMask As Long
pszText As Long
cchTextMax As Long
iImage As Long
iSelectedImage As Long
cChildren As Long
lParam As Long
iIntegral As Long
End Type
Private Type TVINSERTSTRUCTW
hParent As Long
hInsertAfter As Long
Item As TVITEMEXW
End Type
Private Type NMHDR
hwndFrom As Long
idfrom As Long
code As Long
End Type
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type NMTREEVIEW
hdr As NMHDR
action As Long
itemOld As TVITEMW
itemNew As TVITEMW
ptDrag As POINTAPI
End Type
Private Type NMTVDISPINFO
hdr As NMHDR
Item As TVITEMW
End Type
Private Type TVHITTESTINFO
pt As POINTAPI
flags As Long
hItem As Long
End Type
Private Type TRACKMOUSEEVENT_STRUCT
cbSize As Long
dwFlags As TRACKMOUSEEVENT_FLAGS
hwndTrack As Long
dwHoverTime As Long
End Type
Private Type RECT
left As Long
top As Long
Right As Long
Bottom As Long
End Type
Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(32) As Byte
End Type
Private Type tSubData
hwnd As Long
nAddrSub As Long
nAddrOrig As Long
nMsgCntA As Long
nMsgCntB As Long
aMsgTblA() As Long
aMsgTblB() As Long
sCode As String
End Type
Private Type NMCUSTOMDRAW
hdr As NMHDR
dwDrawStage As Long
hdc As Long
rc As RECT
dwItemSpec As Long
uItemState As Long
lItemlParam As Long
End Type
Private Type NMTVCUSTOMDRAW
nmcmd As NMCUSTOMDRAW
clrText As Long
clrTextBk As Long
iLevel As Long
End Type
Private Type NODE_DATA
hNode As Long
sKey As String
sTag As String
End Type
Private Type OSVERSIONINFO
dwVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion(0 To 127) As Byte
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInfo As OSVERSIONINFO) As Long
Private Declare Function ImageList_Create Lib "comctl32" (ByVal MinCx As Long, _
ByVal MinCy As Long, _
ByVal flags As Long, _
ByVal cInitial As Long, _
ByVal cGrow As Long) As Long
Private Declare Function ImageList_Add Lib "comctl32" (ByVal hImageList As Long, _
ByVal hBitmap As Long, _
ByVal hBitmapMask As Long) As Long
Private Declare Function ImageList_AddMasked Lib "comctl32" (ByVal hImageList As Long, _
ByVal hbmImage As Long, _
ByVal crMask As Long) As Long
Private Declare Function ImageList_AddIcon Lib "comctl32" (ByVal hImageList As Long, _
ByVal hicon As Long) As Long
Private Declare Function ImageList_GetIconSize Lib "comctl32" (ByVal hIml As Long, _
cx As Long, _
cy As Long) As Long
Private Declare Function ImageList_Destroy Lib "comctl32" (ByVal hImageList As Long) As Long
Private Declare Function ImageList_GetImageCount Lib "comctl32" (ByVal hImageList As Long) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lpLibFileName As String) As Long
Private Declare Function TrackMouseEvent Lib "user32" (lpEventTrack As TRACKMOUSEEVENT_STRUCT) As Long
Private Declare Function TrackMouseEventComCtl Lib "comctl32" Alias "_TrackMouseEvent" (lpEventTrack As TRACKMOUSEEVENT_STRUCT) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, _
lpPoint As POINTAPI) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, _
lpPoint As POINTAPI) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, _
lpRect As RECT) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, _
lpRect As RECT) As Long
Private Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, _
lpSrc1Rect As RECT, _
lpSrc2Rect As RECT) As Long
Private Declare Function EqualRect Lib "user32" (lpRect1 As RECT, _
lpRect2 As RECT) As Long
Private Declare Function PtInRect Lib "user32" (lpRect As RECT, _
ByVal x As Long, _
ByVal y As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _
ByVal nIndex As Long) As Long
Private Declare Function CreateFontIndirectA Lib "gdi32" (lpLogFont As LOGFONT) As Long
Private Declare Function CreateFontIndirectW Lib "gdi32" (lpLogFont As LOGFONT) As Long
Private Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, _
ByVal nNumerator As Long, _
ByVal nDenominator As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function OleTranslateColor Lib "olepro32" (ByVal OLE_COLOR As Long, _
ByVal HPALETTE As Long, _
pccolorref As Long) As Long
Private Declare Sub InitCommonControls Lib "comctl32" ()
Private Declare Function CreateWindowExA Lib "user32" (ByVal dwExStyle As Long, _
ByVal lpClassName As String, _
ByVal lpWindowName As String, _
ByVal dwStyle As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hWndParent As Long, _
ByVal hMenu As Long, _
ByVal hInstance As Long, _
lpParam As Any) As Long
Private Declare Function CreateWindowExW Lib "user32" (ByVal dwExStyle As Long, _
ByVal lpClassName As Long, _
ByVal lpWindowName As Long, _
ByVal dwStyle As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hWndParent As Long, _
ByVal hMenu As Long, _
ByVal hInstance As Long, _
lpParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal bRepaint As Long) As Long
Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowLongW Lib "user32" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLongA Lib "user32" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function GetWindowLongW Lib "user32" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, _
lpvSource As Any, _
ByVal cbCopy As Long)
Private Declare Function SendMessageA Lib "user32" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function SendMessageW Lib "user32" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function SendMessageLongA Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Declare Function SendMessageLongW Lib "user32" Alias "SendMessageW" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Long
Private Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function timeGetTime Lib "winmm" () As Long
Private Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _
ByVal lpProcName As String) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As SYSTEM_METRICS) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _
ByVal hdc As Long) As Long
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Long
Private Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long
Private Declare Function lstrcpyW Lib "kernel32" (ByVal lpString1 As Long, _
ByVal lpString2 As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, _
ByVal wCmd As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, _
ByVal fEnable As Long) As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, _
ByVal dx As Long, _
ByVal dy As Long, _
ByVal cButtons As Long, _
ByVal dwExtraInfo As Long)
Private Declare Function GetMessageExtraInfo Lib "user32" () As Long
Private Declare Function ImageList_Remove Lib "comctl32.dll" (ByVal hIml As Long, _
ByVal I As Long) As Long
Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, _
ByVal crColor As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, _
ByVal crColor As Long) As Long
Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, _
ByVal x As Long, _
ByVal y As Long) As Long
Private Declare Function SetWindowTheme Lib "uxtheme.dll" (ByVal hwnd As Long, _
ByVal pszSubAppName As Long, _
ByVal pszSubIdList As Long) As Long
Private Declare Function EraseRect Lib "user32" Alias "InvalidateRect" (ByVal hwnd As Long, _
lpRect As RECT, _
ByVal bErase As Long) As Long
Public Event Click()
Public Event NodeClick(ByVal hNode As Long)
Public Event NodeCheck(ByVal hNode As Long)
Public Event NodeDblClick(ByVal hNode As Long)
Public Event SelectionChanged()
Public Event BeforeExpand(ByVal hNode As Long, ByVal ExpandedOnce As Boolean)
Public Event AfterExpand(ByVal hNode As Long, ByVal ExpandedOnce As Boolean)
Public Event Collapse(ByVal hNode As Long)
Public Event BeforeLabelEdit(ByVal hNode As Long, Cancel As Long)
Public Event AfterLabelEdit(ByVal hNode As Long, Cancel As Long, NewString As String)
Public Event KeyDown(KeyCode As Long, Shift As Long)
Public Event KeyPress(KeyAscii As Long)
Public Event KeyUp(KeyCode As Long, Shift As Long)
Public Event MouseDown(Button As Long, Shift As Long, x As Long, y As Long)
Public Event MouseMove(Button As Long, Shift As Long, x As Long, y As Long)
Public Event MouseUp(Button As Long, Shift As Long, x As Long, y As Long)
Public Event MouseEnter()
Public Event MouseLeave()
'Public Event Resize()
Public Event OLEStartDrag(Data As DataObject, AllowedEffects As Long)
Public Event OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)
Public Event OLEDragOver(Data As DataObject, Effect As Long, Button As Long, Shift As Long, x As Single, y As Single, State As Long)
Public Event OLEDragDrop(Data As DataObject, Effect As Long, Button As Long, Shift As Long, x As Single, y As Single)
Public Event OLECompleteDrag(Effect As Long)
Private m_bNodeClick As Boolean
Private m_bCheckBoxes As Boolean
Private m_bFullRowSelect As Boolean
Private m_bHasButtons As Boolean
Private m_bHasLines As Boolean
Private m_bHasRootLines As Boolean
Private m_bHideSelection As Boolean
Private m_bLabelEdit As Boolean
Private m_bSingleExpand As Boolean
Private m_bTrackSelect As Boolean
Private m_bOLEDragAutoExpand As Boolean
Private m_bInitialized As Boolean
Private m_bHoldDeletePostProcess As Boolean
Private m_bTrack As Boolean
Private m_bTrackUser32 As Boolean
Private m_bInControl As Boolean
Private m_bNodeDropInsertAfter As Boolean
Private m_bIsNt As Boolean
Private m_bIsXp As Boolean
Private m_bUseUnicode As Boolean
Private m_bScrollBarLeftAlign As Boolean
Private m_bVisible As Boolean
Private m_bEnabled As Boolean
Private m_bFontRightLeading As Boolean
Private m_lGridHwnd As Long
Private m_lSelectedBackColor As Long
Private m_lDisabledBackColor As Long
Private m_lDisabledForeColor As Long
Private m_lFocusBackColor As Long
Private m_lFocusForeColor As Long
Private m_lBackColor As Long
Private m_lForeColor As Long
Private m_lHeight As Long
Private m_lWidth As Long
Private m_hModShell32 As Long
Private m_lTVHwnd As Long
Private m_lImlNodeHndl As Long
Private m_lImageListCount As Long
Private m_lHFont As Long
Private m_lXCoord As Long
Private m_lYCoord As Long
Private m_lNodeDrag As Long
Private m_lNodeDrop As Long
Private m_lNodeCount As Long
Private m_lExpandCounter As Long
Private m_lParentHwnd As Long
Private m_lImlStateHndl As Long
Private m_lOLEDragMode As Long
Private m_eCheckBoxSkinStyle As ETVThemeStyle
Private m_eThemeLuminence As ETVThemeLuminence
Private m_eScrollBarSkinStyle As ETVThemeStyle
Private m_IChecked As StdPicture
Private m_IChkDisabled As StdPicture
Private m_IUnChecked As StdPicture
Private m_cKey As Collection
Private m_uNodeData() As NODE_DATA
Private m_cChkCheckDc As clsStoreDc
Private m_cRender As clsRender
Private m_cSkinScrollBars As clsSkinScrollbars
Private WithEvents m_oFont As StdFont
Attribute m_oFont.VB_VarHelpID = -1
Private m_cTreeSubclass As GXMSubclass
Private Sub m_oFont_FontChanged(ByVal PropertyName As String)
Set Font = m_oFont
End Sub
'**********************************************************************
'* CONSTRUCTORS
'**********************************************************************
Private Sub Class_Initialize()
m_hModShell32 = LoadLibraryA("shell32.dll")
InitCommonControls
m_bEnabled = True
m_lSelectedBackColor = GetSysColor(vbButtonFace And &H1F&)
m_lFocusBackColor = GetSysColor(vbHighlight And &H1F&)
m_lFocusForeColor = GetSysColor(vbHighlightText And &H1F&)
m_lDisabledForeColor = &H999999
m_lDisabledBackColor = &HCCCCCC
Set m_oFont = New StdFont
Set m_cRender = New clsRender
Set m_cTreeSubclass = New GXMSubclass
ReDim m_uNodeData(0 To 1)
Set m_cKey = New Collection
End Sub
Private Function CreateTreeView() As Boolean
Dim lExStyle As Long
Dim lTVStyle As Long
'/* base styles
lTVStyle = WS_CHILD Or WS_TABSTOP Or TVS_SHOWSELALWAYS Or TVS_DISABLEDRAGDROP
'/* extended style
lExStyle = WS_EX_CLIENTEDGE
'/* left align scrollbar
If m_bScrollBarLeftAlign Then
lExStyle = lExStyle Or WS_EX_LEFTSCROLLBAR
End If
If m_bFontRightLeading Then
lExStyle = lExStyle Or WS_EX_RTLREADING
End If
'/* create the treeview
If m_bIsNt Then
m_lTVHwnd = CreateWindowExW(lExStyle, StrPtr(WC_TREEVIEW), StrPtr(""), lTVStyle, 0&, 0&, 0&, 0&, m_lParentHwnd, 0&, App.hInstance, ByVal 0&)
Else
m_lTVHwnd = CreateWindowExA(lExStyle, WC_TREEVIEW, "", lTVStyle, 0&, 0&, 0&, 0&, m_lParentHwnd, 0&, App.hInstance, ByVal 0&)
End If
If m_bIsXp Then
SetWindowTheme m_lTVHwnd, StrPtr(" "), StrPtr(" ")
End If
'/* set defaults
If Not (m_lTVHwnd = 0) Then
SendMessageLongA m_lTVHwnd, TVM_SETBKCOLOR, 0&, GetSysColor(COLOR_WINDOW)
SendMessageLongA m_lTVHwnd, TVM_SETTEXTCOLOR, 0&, GetSysColor(COLOR_WINDOWTEXT)
'Set m_oFont = Ambient.Font
m_oFont_FontChanged vbNullString
'/* show the control
ShowWindow m_lTVHwnd, SW_SHOW
CreateTreeView = True
End If
End Function
Public Function Initialize(ByVal lParentHwnd As Long, _
ByVal lHeight As Long, _
ByVal lWidth As Long) As Boolean
'/* initialize treeview
If Not m_bInitialized Then
'/* owner handle
m_lHeight = lHeight
m_lWidth = lWidth
m_lParentHwnd = lParentHwnd
VersionCheck
Initialize = CreateTreeView()
UseUnicode = True
If Not (m_lTVHwnd = 0) Then
TreeAttach
m_lXCoord = -1
m_lYCoord = -1
m_bInitialized = True
End If
End If
End Function
Public Function IsUnicode(ByVal sText As String) As Boolean
'/* test for unicode
'/* good link: http://www.unicodeactivex.com/UnicodeTutorialVb.htm
Dim lLen As Long
Dim bLen As Long
Dim bmap() As Byte
If LenB(sText) Then
bmap = sText
bLen = UBound(bmap)
For lLen = 1 To bLen Step 2
If (bmap(lLen) > 0) Then
IsUnicode = True
Exit For
End If
Next lLen
End If
End Function
Private Function PointerToString(ByVal lpString As Long) As String
'/* get string from pointer
Dim lLen As Long
If Not (lpString = 0) Then
lLen = lstrlenW(ByVal lpString)
If Not (lLen = 0) Then
'/* allocate string with nLen chars
PointerToString = String$(lLen, Chr$(0))
lstrcpyW StrPtr(PointerToString), lpString