-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathucShellTree.twin
9186 lines (8351 loc) · 361 KB
/
ucShellTree.twin
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
[FormDesignerId("152922CC-D332-4D27-BEF0-7D0887461FEF")]
[ClassId("85A86C8E-6760-4A3A-9829-9757C29E1A60")]
[InterfaceId("C0C3AAC5-88FC-49E2-B061-151FDB8E0BAC")]
[EventInterfaceId("1D32F2E5-68B8-4168-B712-C80C57BC83BB")]
[COMControl]
[Description("ShellControls ucShellTree")]
Public Class ucShellTree
Option Explicit
Private Const mVersionStr As String = "Shell Tree Control 2.9.2"
#Region "README"
''*********************************************************************************************
'ShellControls TB
'{88049843-B8DE-4955-BD3B-E6A5790F5217}
'
'ucShellTree.twin
'Shell Tree Control v2.9.2 - twinBASIC Implementation
'
'Author: fafalone
'(c) 2018-2024
'
'For questions, comments, and bug reports, stop by the project thread:
'http://www.vbforums.com/showthread.php?862137-ucShellTree-Full-featured-Shell-Tree-UserControl
'
'
'This twinBASIC version doesn't use tlb since upgrading oleexp to x64 compatibility wasn't
'happening... all oleexp imports are handled by an x64 compatible successor to
'oleexp: WinDevLib.
'
'
'----------------------------------------ABOUT-------------------------------------------
'This UserControl displays a TreeView of the Windows Shell, similar to the one
'found in Explorer. While there are other controls that are similar, and there's
'also the INamespaceTreeControl that actually hosts an Explorer TreeView, this has
'the advantage that it has modern styling and features that weren't available before
'Windows Vista, but being completely done in VB provides customizations that are
'not possible with the hosted object.
'
'-------------------------------------REQUIREMENTS---------------------------------------
'-Windows Vista or newer
'-oleexp.tlb v4.42 or higher
'
'STRONGLY RECOMMENDED: Common Controls 6.0 manifest. Partial and exclusion checkboxes will
' not work, visual styling is effected, and other features may not work
' as well.
'-------------------------------------KEY FEATURES---------------------------------------
'-Displays complete Explorer-type tree with either Desktop or Computer as the root folder.
'-Tri-state checkboxes show partial selections when check mode is enabled
'-Supports drag/drop with modern drag images and drag-over-highlighting (including
' expanding on hover), based on my cDropTarget project. Can drop on all valid drop targets:
' folders, zip files, programs, shortcuts to them, etc.
'-Right-click shows the standard Explorer context menu for the clicked item
'-Automatically monitors for changes (item created, deleted, renamed) and updates the
' tree accordingly.
'-Option to show files as well
'-Can automatically expand to a given path. NOTE: OpenToPath/OpenToItem can only be used
' after loading; to open to a path on your Form_Load or Main() routine, use .InitialPath
'-InfoTips with several lines of details depending on file type are shown as ToolTips
'-Filter option can limit the type of files displayed (or even folders)
'-Can rename in place using LabelEdit
'-Can (optionally) treat .zip/.cab files as a folder
'-Optional additional root entry for 'Favorites' that shows the Links folder.
'-Browses the Network folder too and returns paths as \\Share\etcetc
'-Complete Unicode support
'
'
'---------------------------------------CHANGELOG----------------------------------------
'v2.9.2
'
'Special thanks to VBForums user Mith for his incredible work helping with new features
'and bug fixes! Credit goes to him for most of the changes in 2.9.2 alpha and final.
'
'-Added ShowOnlyFileCheckboxes option: When Checkboxes = True and ShowFiles = True, will
' show checkboxes only for files.
'
'-Try to load cached icons first
'
'-Minor sizing adjustment to eliminate 4px border.
'
'-(Bug fix) Default share/shortcut overlays not showing.
'
'-(Bug fix) New icon methods didn't properly support running without ComCtl6.
'
'-(Bug fix) Always Show extensions wasn't working.
'
'-(Bug fix) Disabling of Wow64 redirection wasn't reverted on terminate.
'
'-(Bug fix) If DPI awareness was on, IconSize would continuously grow.
'
'v2.9.2 (ALPHA, 29 Jan 2024)
'-New FileExtensions property to choose between following Explorer's setting for hiding
' known extensions, over forcing them to always show.
'
'-Added property CheckedPathCount.
'
'-Added UserOption mNeverExpandZip, to prevent expansion of .zip when ShowFiles = True.
'
'-(Bug fix) Border property not restored correctly due to re-reading it with the wrong
' name from the property bag.
'
'-(Bug fix) Opening to a custom root would add the root as a child of itself.
'
'v2.9.1 (Released Jan 27th, 2024)
'-(Bug fix) AutoCheck = False not respected when expanding a checked folder (thanks to
' VBForums user Mith for report and fix)
'
'-(Bug fix) When AutoCheck = False and CheckBoxes = True is set at runtime, checkboxes
' improperly cycled through partial checks. This is currently fixed as a work-
' around that will not work properly if ExclusionChecks = True (and AutoCheck
' = False), but it may be some time before I Can run down a proper fix.
'
'
'v2.9 (Release Jan 15th, 2024)
'-Now using a mirrored image list to support arbitrary icon size.
'
'v2.8 R2
'-Updated tbShellLib to 2.6.62 with fixed hex literals, and fixed a couple ones in this
' control.
'
'v2.8
'
'(R1) IPAO hooking code integrated so as to not conflict with ucShellBrowse.
'
'-Added Indentation property to get/set the indent width of TreeView items.
'
'-Added functions InsertItemByPath and InsertItemByPidl, to insert other locations into
' places on the tree. If you leave the parent blank, the items will be added under the
' root. Note that the parent must already be visible (you can call OpenToPath/Item).
'
'-Quick Access replaced Favorites in the Windows 10 Explorer tree; this project can now
' optionally do the same with the ShowQuickAccessOnWin10 option. ShowFavorites must be
' enabled as well, then this option True (the default) to replace it.
'
'-Automatically expanding Computer/ThisPC is now an option, AutoExpandComputer, and also
' there's an option to automatically expand Libraries as well, AutoExpandLibaries. Both
' are true by default, and are only applied if ComputerAsRoot is false and no custom
' root is being used.
'
'-Added selected node operations: SelectedNode[s]Expand, SelectedNode[s]Collapse, and
' SelectedNode[s]Toggle (toggle collapsed or expanded).
'
'-RefreshTreeView now preserves which item is selected.
'
'-Can now disable Wow64 redirection. Note: This is per-thread, so it should only be
' done once; if using with ucShellBrowse only one should have the option enabled, and
' it applies to both (and everything else in the thread).
'
'-If Multiselect was enabled, the MultiselectChange event and ItemClick event fired, but
' the ItemSelect event did not. It now does.
'
'-(Bug fix) Various issues with .CheckedPaths not matching what's seen on the tree have
' been fixed by syncing the check data before reporting it. .ExcludedPaths does
' this too now.
'
'-(Bug fix) SelectedItems did not fill in the string array of paths.
'
'-(Bug fix) Renamed items did not have their name updated in the TreeView (though the rename
' itself succeeded)
'
'v2.7 (Released 25 Jan 2022)
'
'-Added ShowHiddenItems/ShowSuperHidden options
'
'-Added EnableShellMenu option to control whether the right-click menu pops up.
'
'-Added SetFocusOnTree method.
'
'-Added public event for UserControl_EnterFocus and UserControl_ExitFocus (EnterFocus
' and ExitFocus, respectively).
'
'-(Bug fix) Keyboard focus never went to ucTreeView when on a form with ucShellBrowse.
'
'v2.6 (Released 03 Apr 2021)
'
'-Eliminated the need to use a variable to keep tracking of dir change operations when
' combining this control with a ucShellBrowse control; previously you'd handle a path
' change notification from the browser with
' If bChanging = False Then
' bChanging = True
' ucShellTree1.OpenToItem siItem, False
' bChanging = False
' End If
' Now you no long need the bChanging variable.
'
'-Added SelectNone sub, which will clear all selected items (supports multiselect).
'
'-Added ItemSelectByShellItem event. I wanted to just include an IShellItem member in
' ItemSelect, but the backwards compatibility concerns are too great. This event will
' also include all the information of ItemSelect if you want to fully switch over.
'-Did the same for ItemClick->ItemClickByShellItem
'
'-For MultiSelect, added the MultiSelectChange event, which includes an IShellItemArray
' of selected items as well as a name list and full path list
'
'-(Bug fix) Using On Error Resume Next to handle an uninitialized array in the Terminate
' event caused the control to freeze on compile or on run after changes if
' you were using it as an OCX.
'
'
'v2.5 R2 (Released 15 Dec 2020)
'
'-(Bug fix) Navigation in unmapped Network locations wouldn't expand properly. This may
' also have effected other items, as the bug involves scenarios where two
' IShellItem.GetDisplayName calls for the same location return a different case
' at a different time, which resulted in an infinite loop looking for something
' that should have been there, because case differed unexpectedly.
'
'v2.5 (Released 09 Dec 2020)
'
'-Added BackColor and ForeColor (text) options.
'
'-Added some missing style options: AutoHScroll, NoIndentState, TrackSelect, and
' ShowSelAlways. The latter two are enabled by default.
'
'-Added RefreshTreeView function. There already is 'ResetTreeView', but that restores the
' tree to its state on load. RefreshTreeView resets it then expands all the folders that
' were previously expanded, which will make any updates in the folders that were visible
' as they're loaded from scratch.
'
'-To perform the refresh, a list is generated of not all folders, but just one per end
' node, otherwise there'd be potentially hundreds of useless OpenToPath calls.
' This list is available if you want to view or save it through the new GetExpansionState
' function. If you want to load a saved list, also added LoadExpansionState. You can pass
' any list of full paths in a string delimited by a | if desired.
'
'-(Bug fix) If a portable device (e.g. phone, camera) was connected while the control was
' running, it wouldn't be added to the tree.
'
'v2.4 (Released 20 Sep 2020)
'
'-Extended Verbs for the Shell Context Menu is now an option. If it's set to False (the
' default), you will need to hold down Shift when bringing up the menu to show the
' additional items, the same way it works in Explorer.
'
'-(Bug fix) Eliminated all non-explicit types that were defined in the type library, so
' that no further conflicts with Public versions are possible.
'
'v2.3 (Released 19 August 2020)
'
'-(Bug fix) Extended styles were being cleared improperly. Checkboxes, ExclusionChecks,
' FadingExpandos, and MultiSelect would not turn off once enabled.
'
'v2.2 (Released 23 April 2020)
'
'-Added DropFiles event and DragStart event.
'
'-Added Multiselect option. MSDN says "Not supported, do not use." but this style appears
' to be working without issue. Be advised, this deprecated status means that it could cease
' to work in future versions of Windows without notice.
' This effects dragging items, and a new Public Sub SelectedItems has been added; these are
' the only places multiselect currently effects.
'
'-Added DisableDragDrop option if you want to disable it.
'
'
'v2.17 (Released 15 Mar 2020)
'
'-(Bug fix) The default overlays that should always stay on weren't showing (Link/Share)
'
'v2.16 (Released 05 Mar 2020)
'
'-Made extended overlays, found in programs such as TortoiseSVN and Dropbox, a default-off
' option due to the extreme performance cost (a factor of 10-100).
'
'v2.15 (Released 19 Feb 2020)
'
'-(Bug fix) If a Private Enum defined in a UserControl had the same name as one that
' is defined in a module containing Sub Main, placing more than one of the
' UserControl in a project caused the control to be grayed out and then an
' app crash when any other control was initially added to the form.
' To fix this, all API enums in this control have been prefixed with ucsb_
' If you're modifying the code of this control, just keep that in mind.
' No change is needed for using this control or any other code as they're
' all Private.
'
'-(Bug fix) In ensuring a USB device is already added after OpenToItem, the GetNodeByPath
' function did not handle USB paths properly, so additional USB device entries
' were added to the tree.
'
'v2.14
'
'-(Bug fix) If a USB media device (phone, camera, etc-- no drive letter) was added after
' the program started, it could not be added to the TreeView-- there was some
' issue with an infinite loop where it kept finding the parent but not adding
' the child. I couldn't figure out where it was going wrong, so implemented a
' workaround where the control checks whether it's being asked to navigate to
' one of these devices, and if it is, manually ensures the device is added.
' After that, subfolder adding works fine, you can directly navigate to a deep
' path and all the subfolders will be added; the issue was just adding the
' device itself.
'
'-(Bug fix) The control uses the SHChangeNotifyRegister API without its own declare; there
' is a declare in the typelib, and since it wasn't declared explicitly, any
' Public version in a project module would take precedence, which sometimes
' caused Type Mismatch errors if the declare was slightly different.
'
'v2.13
'
'-InfoTips are now cached on first load.
'
'-Now store fully qualified pidls for each item, which enables compatibility with the search
' folders generated by ucShellBrowse's new search method (ISearchFolderItemFactory), as these
' for some reason lack a relative pidl even though other direct children of the desktop do not.
' There may be other types of objects lacking a relative pidl as well; this can only increase
' the number of item types supported.
'
'-(Bug fix) In Design Mode, the control displayed "Shell Tree Control 1.0" instead of the current
' version number. It now gets the info from mVersionStr on Line #2 of this module.
'
'v2.12 (Released 16 June 2019)
'-(Bug fix) On Windows 10, when browsing some virtual devices, like connected phones or cameras,
' the SHCreateItemFromParsingName fails when 2 levels or deeper. Changed navigation,
' selection generation, and other features to have full pidl records to fall back on.
'
'v2.11 (Released 15 Feb 2019 - Critical bug fix only)
'-(Bug fix) Previous fix regarding PathMatchSpecW resulted in always loading the Computer
' folder as root.
'
'v2.1 (Released 30 Jan 2019)
'-The font for the TreeView is now a standard property. (Borrowed from Krool's
' TreeView. Thanks!)
'
'-Shell context menu tips are now passed in the StatusMessage event.
'
'-Filter now supports multiple patterns separated by semi-colon.
'
'-Replaced Border property with BorderStyle, which has several more options.
'
'-(Bug fix) If the control was on a secondary form, unloading that form did not unload
' the control, and it stayed loaded in the background until the whole program
' ended. Thanks to dz32 and Eduardo- for figuring out the solution.
'
'-(Bug fix) Fixed automatic navigation not expanding when a parent of a parent was
' collapsed; only the immediate parent was checked previously.
'
'-(Bug fix) Custom Roots were checked for validity with PathMatchSpecW, which does
' not support virtual locations. Now it's checked by going ahead and trying
' to create the IShellItem for it, allowing roots like ::{GUID}
'v2
'
'-You can now specify a custom folder as root*. Changeable during runtime.
'-Added PathGetCheck and PathSetCheck functions. The Set function also has an option to
' expand to show the given path in the event it's not yet visible.
'
'-The OpenToPath/OpenToItem functions now have an option to just expand to but not select
' the item, primarily for the check set function but available in general; default=select.
'
'-The .InitialPath property is deprecated. The creation sequence has changed, you can
' now just use OpenPath in your Form_Load (or equiv.) event. It remains for compatibility.
'
'-Added RootHasCheckbox option to set whether or not one appears (when checkboxes are enabled).
'
'-Added ExclusionChecks option, which adds an additional checkbox state- a red x. The .ExcludedPaths
' method functions in the same way as the .CheckedPaths method to retrieve paths in this state (they
' are not counted as checked).
'
'-Added ExplorerStyle option to allow control over whether the Explorer visual style is applied.
'
'-Added HorizontalScroll option, to set whether the tree expands without needed HScroll.
'
'-Adjusted the RootHasCheckbox option so that if it's changed at runtime, the correct state is set.
'
'-Changed disable criteria such that valid file drop targets are excepted from normal disabled prop
' list. This was mainly to get the Recycle Bin enabled since it's completely browsable. Other items
' remain disabled. (You can change this in TVExpandFolder if desired).
'
'-Added Autocheck option for control over whether partial checks are shown and whether parent and
' child items are automatically changed according to a new check action.
'
'-The control will now fall back to plain checkboxes if no Common Control 6 manifest is present, but
' all autocheck functionality is unavailable (even checking all children of a checked parent).
' Previously checkboxes were not present at all without a manifest.
'
'(Bug fix) The outer edge of the control on dragover indicated a droptarget on no item but
' seemingly valid; it now correctly shows no drop is possible.
'
'(Bug fix) Invalid (malformed/corrupt) shortcut files caused an error that wasn't handled, so
' the item enumeration when expanding a folder stopped when it reached it.
'
'(Bug fix) When you call GetParent on your user folder, you get the desktop instead of \Users\,
' this caused some issues with auto-navigating.
'
'(Control/code) So I thought you needed to supply your own check imagelist for partial checkboxes,
' since the extended style wasn't working, but it turned out the problem was just that
' you can't set the TVS_CHECKBOXES style; just TVS_EX_PARTIALCHECKBOXES. So the images
' have been removed, which eliminates transparency issues and will keep the appearance
' the same as the OS.
'
'-------
'* - Technical note: This can be any path string/identifier resolvable by SHCreateItemFromParsingName
'
'*********************************************************************************************
#End Region
'USER OPTIONS
'The following are meant to be toggled based on your preferences:
Private Const dbg_PrintToImmediate As Boolean = False 'This control has very extensive debug information, you may not want
'to see that in your IDE.
Private Const dbg_IncludeDate As Boolean = True 'Prefix all Debug output with the date and time, [yyyy-mm-dd Hh:Mm:Ss]
Private Const dbg_RaiseEvent As Boolean = True 'Raise DebugMessage event
Private Const dbg_MinLevel As Long = 0& 'Only fire debug statement if iLvl >= this value
Private Const mNeverExpandZip As Boolean = False 'Never expand a zip under any circumstances.
'-----------------------------------------------------------------------------------------------
#Region "ProjectDeclares"
Implements IDropTarget
Implements IOleInPlaceActiveObjectVB
Implements IObjectSafety
Public Event StatusMessage(sMsg As String)
Public Event ItemClick(sName As String, sFullPath As String, bFolder As Boolean, nButton As Long, hItem As LongPtr)
Public Event ItemClickByShellItem(siItem As IShellItem, sName As String, sFullPath As String, bFolder As Boolean, nButton As Long, hItem As LongPtr)
Public Event ItemSelect(sName As String, sFullPath As String, bFolder As Boolean, hItem As LongPtr)
Public Event ItemSelectByShellItem(siItem As IShellItem, sName As String, sFullPath As String, bFolder As Boolean, hItem As LongPtr)
Public Event MultiSelectChange(siaItems As IShellItemArray, sNames() As String, sFullPaths() As String)
Public Event ItemCheck(sName As String, sFullPath As String, bFolder As Boolean, fCheck As Long, hItem As LongPtr)
Public Event ItemExpand(sName As String, sFullPath As String, hItem As LongPtr)
Public Event ItemCollapse(sName As String, sFullPath As String, hItem As LongPtr)
Public Event TreeKeyDown(VKey As Integer)
Public Event ItemRename(sNameOld As String, sNameNew As String, sFullPathOld As String, sFullPathNew As String, bFolder As Boolean, hItem As LongPtr)
Public Event Initialized()
Public Event DropFiles(sFiles() As String, siaFiles As IShellItemArray, doDropped As IDataObject, sDropParent As String, siDropParent As IShellItem, dwDropEffect As DROPEFFECTS, dwKeyState As Long, ptPointX As Long, ptPointY As Long)
Public Event DragStart(sFiles() As String, siaDragged As IShellItemArray, pdoDragged As IDataObject)
Public Event EnterFocus()
Public Event ExitFocus()
Public Event DebugMessage(sMsg As String, iLevel As Integer)
Private m_ScaleX As Single, m_ScaleY As Single
Private bLoadDone As Boolean
Private pDTH As IDropTargetHelper
Private Const CLSID_DragDropHelper = "{4657278A-411B-11D2-839A-00C04FD918D0}"
Private m_hWnd As LongPtr
Private bRegDD As Boolean
Private psfCur As IShellFolder
Private siaSelected As IShellItemArray
Private sSelectedItems() As String
Private siaSIH As IShellItemArray
Private lUDTC As Long, sUDsz As String
Private mTmrProc As LongPtr
Private idTmr As LongPtr
Private mRefreshPaths() As String
Private bIsWinVistaOrGreater As Boolean 'This control will not run on XP or lower
Private bIsWin7OrGreater As Boolean
Private bIsWin8OrGreater As Boolean
Private bIsWin10OrGreater As Boolean
Private bIsWow64 As Boolean
Private lWow64Data As Long
Private hFontTV As LongPtr
Private WithEvents PropFont As StdFont
Private mIFMain As IFont
Private lLoopTrack As Long
Private mBkm As Boolean
Private m_hRoot As LongPtr
Private m_hFav As LongPtr
Private mCustomRoot As String
Private Const mCustomRoot_def As String = ""
Private bCustRt As Boolean
Private bQkAc As Boolean
Private sUserFolder As String
Private sUserDesktop As String
Private himlTV As LongPtr
Private himl16 As LongPtr
Private himl32 As LongPtr
Private himl48 As LongPtr
Private himl64 As LongPtr
Private himl96 As LongPtr
Private himl128 As LongPtr
Private himl256 As LongPtr
Private imlSysJM As IImageList
Private imlSysSM As IImageList
Private mIconSize As Long
Private Const mDefIconSize As Long = 24
Private gdipToken As LongPtr
Private Type SysImgCacheEntry
sysimlid As Long
limlidx As Long
End Type
Private SysImgCache() As SysImgCacheEntry
Private nSysImgCache As Long
Private bOvrAdded(16) As Boolean
Private Type TVEntry
bFolder As Boolean
bZip As Boolean
bLink As Boolean
bFavorite As Boolean
sFullPath As String
sName As String
sNameFull As String
sParentFull As String
sLinkTarget As String
sInfoTip As String
LinkPIDL As LongPtr
bLinkIsFolder As Boolean
bDropTarget As Boolean
hNode As LongPtr
hParentNode As LongPtr
nIcon As Long
nOverlay As Long
dwAttrib As SFGAOF
Checked As Boolean
Excluded As Boolean
bDisabled As Boolean
bDeleted As Boolean
pidlFQPar As LongPtr
pidlRel As LongPtr
pidlFQ As LongPtr
bIsDefItem As Boolean
End Type
Private TVEntries() As TVEntry
Private nCur As Long
Private TVVisMap() As TVEntry
Private nTVVis As Long
Private bFlagRecurseOI As Boolean
Private fRefreshing As Long
Private hTVD As LongPtr
Private ICtxMenu2 As IContextMenu2
Private ICtxMenu3 As IContextMenu3
Private Const wIDSel As Long = 3000&
Private bSetParents As Boolean
Private bFilling As Boolean
Private gPaths() As String
Private nPaths As Long
Private gExPaths() As String
Private nExPaths As Long
Private nItr As LongPtr
Private hSysIL As LongPtr
Private pIML As IImageList
Private g_fDeleting As Boolean
Private fNoExpand As Long
Private sFavPath As String
Private siSelected As IShellItem
Private sSelectedItem As String
Private gCurSelIdx As LongPtr
Private m_hSHNotify As Long
Private Const WM_SHNOTIFY = &H477
Private hLEEdit As LongPtr
Private sOldLEText As String
Private bRNf As Boolean
Private Const sQuickAccess = "shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}"
Private Const sComp = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
Private Const sLibRoot = "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\"
Private Const lnLibRoot As Long = 41& 'length
Private ddRightButton As Boolean
Private bNoDrop As Boolean
Private lHover1 As Long, lHover2 As Long
Private bFlagBlockClkExp As Boolean
Private hItemBlocked As LongPtr
Private bBlockExec As Boolean
Private bNavigating As Boolean
Private fLoad As Long
Private sDesktopPath As String
Private m_cbSort As LongPtr
Private m_sAltDrop As String
Private szNavWav As String
Private xHover As Long, yHover As Long
Private bHoverFired As Boolean
Private sFolder As String
Private bAbort As Boolean
Private bNoTarget As Boolean
Private lItemIndex As LongPtr
Private mDragOver As String
Private mDropTipMsg As String
Private mDropTipIns As String
Private mDropTipImg As DROPIMAGETYPE
Private mDefEffect As DROPEFFECTS
Private mAllowedEffects As DROPEFFECTS
Private mDataObj As IDataObject
Private lvDragOverIdx As Long
Private IsComCtl6 As Boolean
Private lParamSort As LongPtr
Private clrBack As stdole.OLE_COLOR
Private clrFore As stdole.OLE_COLOR
Private mCheckboxes As Boolean
Private Const mCheckboxes_def As Boolean = False
Private mExCheckboxes As Boolean
Private Const mExCheckboxes_def As Boolean = False
Private mAutocheck As Boolean
Private Const mAutocheck_def As Boolean = True
Private mExplorerStyle As Boolean
Private Const mExplorerStyle_def As Boolean = True
Private mExpandZip As Boolean
Private Const mExpandZip_def As Boolean = False
Private mShowFiles As Boolean
Private Const mShowFiles_def As Boolean = False
Private mFadeExpandos As Boolean
Private Const mFadeExpandos_def As Boolean = True
Private mShowLines As Boolean
Private Const mShowLines_def As Boolean = False
Private mHasButtons As Boolean
Private Const mHasButtons_def As Boolean = True
Private mSingleExpand As Boolean
Private Const mSingleExpand_def As Boolean = False
Private mMultiSel As Boolean
Private Const mDefMultiSel As Boolean = False
Private mShowOnlyFileCheckbox As Boolean
Private Const mDefShowOnlyFileCheckbox As Boolean = False
Private mDisableDD As Boolean
Private Const mDefDisableDD As Boolean = False
Private mComputerAsRoot As Boolean
Private Const mComputerAsRoot_def As Boolean = False
Private mFullRowSelect As Boolean
Private Const mFullRowSelect_def As Boolean = True
Private mFilter As String
Private Const mFilter_def As String = "*.*"
Private mIndent As Long
Private Const mDefIndent As Long = 19
Private mFilterFilesOnly As Boolean
Private Const mFilterFilesOnly_def As Boolean = True
Private mInfoTipOnFiles As Boolean
Private Const mInfoTipOnFiles_def As Boolean = True
Private m_TrackSel As Boolean
Private Const m_def_TrackSel As Boolean = True
Private mShowSelAlw As Boolean
Private Const mDefShowSelAlw As Boolean = True
Private mExpandOnLabelClick As Boolean
Private Const mExpandOnLabelClick_def As Boolean = False
Private mNoIndState As Boolean
Private Const mDefNoIndState As Boolean = False
Private mAutoHS As Boolean
Private Const mDefAutoHS As Boolean = True
Private mInfoTipOnFolders As Boolean
Private Const mInfoTipOnFolders_def As Boolean = False
Private mNavSound As Boolean
Private Const mNavSound_def As Boolean = True
Private mFavorites As Boolean
Private Const mFavorites_def As Boolean = True
Private mSHCN As Boolean
Private Const mSHCN_def As Boolean = True
Private mLabelEdit As Boolean
Private Const mLabelEdit_def As Boolean = True
Private mNameColors As Boolean
Private Const mNameColors_def As Boolean = True
Private m_SysClrText As Long
Private mExtOverlay As Boolean
Private Const m_def_ExtOverlay As Boolean = False
Private mAlwaysShowExtVerbs As Boolean
Private Const mDefAlwaysShowExtVerbs As Boolean = False
Private m_EnableShellMenu As Boolean
Private Const m_def_EnableShellMenu As Boolean = True
Private m_Win10QA As Boolean
Private Const m_def_Win10QA As Boolean = True
Private mExpComp As Boolean
Private Const mDefExpComp As Boolean = True
Private mExpLib As Boolean
Private Const mDefExpLib As Boolean = True
Private m_NoWow64 As Boolean
Private Const m_def_NoWow64 As Boolean = False
#If TWINBASIC Then
[EnumId("869CCDEE-23AD-4F26-BC13-E75177292A05")]
#End If
Public Enum ST_HDN_PREF
STHP_UseExplorer = 0&
STHP_AlwaysShow = 1&
STHP_AlwaysHide = 2&
End Enum
Private m_HiddenPref As ST_HDN_PREF
Private Const m_def_HiddenPref As Long = 0&
Private mHPInExp As Boolean
#If TWINBASIC Then
[EnumId("869CCDEE-23AD-4F26-BC13-E75177292A06")]
#End If
Public Enum ST_SPRHDN_PREF
STSHP_UseExplorer = 0&
STSHP_AlwaysShow = 1&
STSHP_AlwaysHide = 2&
End Enum
Private m_SuperHiddenPref As ST_SPRHDN_PREF
Private Const m_def_SuperHiddenPref As Long = 0&
Private mSHPInExp As Boolean
#If TWINBASIC Then
[EnumId("869CCDEE-23AD-4F26-BC13-E75177292A07")]
#End If
Public Enum ST_EXT_PREF
STEP_UseExplorer = 0&
STEP_AlwaysShow = 1&
End Enum
Private m_ForceExt As ST_EXT_PREF
Private Const m_def_ForceExt As Long = 0&
Private mExSetExt As Boolean
'Private mBorder As Boolean
'Private Const mBorder_def As Boolean = True
#If TWINBASIC Then
[EnumId("869CCDEE-23AD-4F26-BC13-E75177292A08")]
#End If
Public Enum ST_BORDERSTYLE
STBS_None = 0&
STBS_Standard = 1&
STBS_Thick = 2&
STBS_Thicker = 3&
End Enum
Private mBorder As ST_BORDERSTYLE
Private Const mBorder_def As Long = 1&
Private mInitialPath As String
Private Const mInitialPath_def As String = ""
Private mRootHasCheckbox As Boolean
Private Const mRootHasCheckbox_def As Boolean = False
Private mHScroll As Boolean
Private Const mHScroll_def As Boolean = True
Private lRaiseHover As Long
Private Const m_def_lRaiseHover As Long = 2500&
Private bTopLostFocus As Boolean
Private bHasFocus As Boolean
Private hBmpBack As LongPtr
#End Region
#Region "APIDeclares"
'------------------------------------------------------------
'BEGIN STANDARD APIs AND SYSTEM CONSTANTS
'I'm going to try to have a bitmap background at some point, but it's not ready yet.
Private Type PAINTSTRUCT
hDC As LongPtr
fErase As Long
rcPaint As RECT
fRestore As Long
fIncUpdate As Long
rgbReserved(32) As Byte
End Type
Private Type BITMAP
BMType As Long
BMWidth As Long
BMHeight As Long
BMWidthBytes As Long
BMPlanes As Integer
BMBitsPixel As Integer
BMBits As LongPtr
End Type
Private Declare PtrSafe Function BeginPaint Lib "user32" (ByVal hWnd As LongPtr, lpPaint As PAINTSTRUCT) As LongPtr
Private Declare PtrSafe Function EndPaint Lib "user32" (ByVal hWnd As LongPtr, lpPaint As PAINTSTRUCT) As Long
Private Declare PtrSafe Function SelectObject Lib "gdi32" (ByVal hDC As LongPtr, ByVal hObject As LongPtr) As LongPtr
Private Declare PtrSafe Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As LongPtr) As LongPtr
Private Declare PtrSafe Function StretchBlt Lib "gdi32.dll" (ByVal hDC As LongPtr, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As LongPtr, ByVal XSrc As Long, ByVal YSrc As Long, ByVal hSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Declare PtrSafe Function DeleteDC Lib "gdi32" (ByVal hDC As LongPtr) As Long
Private Declare PtrSafe Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As LongPtr, ByVal nCount As Long, lpObject As Any) As Long
Private Declare PtrSafe Function SetBkMode Lib "gdi32" (ByVal hDC As LongPtr, ByVal nBkMode As Long) As Long
Private Declare PtrSafe Function TransparentBlt Lib "msimg32" (ByVal hDestDC As LongPtr, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As LongPtr, ByVal XSrc As Long, ByVal YSrc As Long, ByVal nWidthSrc As Long, ByVal nHeightSrc As Long, ByVal crTransparent As Long) As Long
Private Const TRANSPARENT = 1&
Private Const OPAQUE = 2&
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As LongPtr)
Private Declare PtrSafe Sub CoTaskMemFree Lib "ole32" (ByVal pv As LongPtr)
Private Declare PtrSafe Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectW" (ByRef lpLogFont As LOGFONT) As LongPtr
Private Declare PtrSafe Function CreatePopupMenu Lib "user32" () As LongPtr
Private Declare PtrSafe Function CreateWindowEx Lib "user32" Alias "CreateWindowExW" (ByVal dwExStyle As Long, ByVal lpClassName As LongPtr, ByVal lpWindowName As LongPtr, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As LongPtr, ByVal hMenu As LongPtr, ByVal hInstance As LongPtr, lpParam As Any) As LongPtr
Private Declare PtrSafe Function DeleteObject Lib "gdi32" (ByVal hObject As LongPtr) As Long
Private Declare PtrSafe Function DestroyIcon Lib "user32.dll" (ByVal hIcon As LongPtr) As Long
Private Declare PtrSafe Function DestroyMenu Lib "user32" (ByVal hMenu As LongPtr) As Long
Private Declare PtrSafe Function DestroyWindow Lib "user32" (ByVal hWnd As LongPtr) As Long
Private Declare PtrSafe Function DispatchMessage Lib "user32" Alias "DispatchMessageW" (ByRef lpMsg As Any) As LongPtr
Private Declare PtrSafe Function DllGetVersion Lib "comctl32" (ByRef pdvi As DLLVERSIONINFO) As Long
Private Declare PtrSafe Function EnableWindow Lib "user32" (ByVal hWnd As LongPtr, ByVal fEnable As Long) As Long
Private Declare PtrSafe Function FindResourceW Lib "kernel32" (ByVal hInstance As LongPtr, ByVal lpName As LongPtr, ByVal lpType As LongPtr) As LongPtr
Private Declare PtrSafe Function FreeLibrary Lib "kernel32" (ByVal hLibModule As LongPtr) As Long
Private Declare PtrSafe Function GetAsyncKeyState Lib "user32.dll" (ByVal VKey As Long) As Integer
Private Declare PtrSafe Function GetClientRect Lib "user32" (ByVal hWnd As LongPtr, lpRect As RECT) As Long
Private Declare PtrSafe Function GetCurrentProcess Lib "kernel32" () As LongPtr
Private Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As Any) As Long
Private Declare PtrSafe Function GetDC Lib "user32" (ByVal hWnd As LongPtr) As LongPtr
Private Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hDC As LongPtr, ByVal nIndex As Long) As Long
Private Declare PtrSafe Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare PtrSafe Function GetMenuItemCount Lib "user32" (ByVal hMenu As LongPtr) As Long
Private Declare PtrSafe Function GetMenuItemID Lib "user32" (ByVal hMenu As LongPtr, ByVal nPos As Long) As Long
Private Declare PtrSafe Function GetObjectW Lib "gdi32" (ByVal hObject As LongPtr, ByVal nCount As Long, lpObject As Any) As Long
Private Declare PtrSafe Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Private Declare PtrSafe Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As SystemMetrics) As Long
Private Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long
Private Declare PtrSafe Function ImageList_ReplaceIcon Lib "comctl32.dll" (ByVal himl As LongPtr, ByVal i As Long, ByVal hIcon As LongPtr) As Long
Private Declare PtrSafe Function InsertMenuItemW Lib "user32" (ByVal hMenu As LongPtr, ByVal uItem As Long, ByVal fByPosition As Boolean, lpmii As MENUITEMINFOW) As Boolean
Private Declare PtrSafe Function IsEqualGUID Lib "ole32" (iid1 As UUID, iid2 As UUID) As Long
Private Declare PtrSafe Function IsWow64Process Lib "kernel32.dll" (ByVal hProcess As LongPtr, ByRef Wow64Process As Long) As Long
Private Declare PtrSafe Function KillTimer Lib "user32" (ByVal hWnd As LongPtr, ByVal uIDEvent As LongPtr) As Long
Private Declare PtrSafe Function LoadCursor Lib "user32" Alias "LoadCursorW" (ByVal hInstance As LongPtr, ByVal lpCursorName As Any) As LongPtr
Private Declare PtrSafe Function LoadLibraryW Lib "kernel32" (ByVal lpLibFileName As LongPtr) As LongPtr
Private Declare PtrSafe Function LoadResource Lib "kernel32" (ByVal hInstance As LongPtr, ByVal hResInfo As LongPtr) As LongPtr
Private Declare PtrSafe Function LockResource Lib "kernel32" (ByVal hResData As LongPtr) As LongPtr
Private Declare PtrSafe Function lstrcpyA Lib "kernel32" (lpString1 As Any, lpString2 As Any) As LongPtr
Private Declare PtrSafe Function lstrlenA Lib "kernel32" (lpString As Any) As Long
Private Declare PtrSafe Function lstrlenW Lib "kernel32" (lpString As Any) As Long
Private Declare PtrSafe Function MessageBoxW Lib "user32.dll" (ByVal hWnd As LongPtr, ByVal lpText As LongPtr, ByVal lpCaption As LongPtr, ByVal wType As Long) As Long
Private Declare PtrSafe Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As Long
Private Declare PtrSafe Function OleGetClipboard Lib "ole32" (ppDataObj As IDataObject) As Long
Private Declare PtrSafe Function OleTranslateColor Lib "oleaut32" (ByVal Color As Long, ByVal hpal As LongPtr, ByRef RGBResult As Long) As Long
Private Declare PtrSafe Function PathFileExistsW Lib "shlwapi" (ByVal lpszPath As LongPtr) As Long
Private Declare PtrSafe Function PathIsDirectoryW Lib "shlwapi" (ByVal lpszPath As LongPtr) As Long
Private Declare PtrSafe Function PathMatchSpecW Lib "shlwapi" (ByVal pszFileParam As LongPtr, ByVal pszSpec As LongPtr) As Long
Private Declare PtrSafe Function PathMatchSpecExW Lib "shlwapi" (ByVal pszFile As LongPtr, ByVal pszSpec As LongPtr, ByVal dwFlags As ucst_PMS_Flags) As Long
Private Declare PtrSafe Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As MSG, ByVal hWnd As LongPtr, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Declare PtrSafe Function PlaySound Lib "winmm.dll" Alias "PlaySoundW" (ByVal lpszName As LongPtr, ByVal hModule As LongPtr, ByVal dwFlags As ucst_SND_FLAGS) As Long
Private Declare PtrSafe Function PSFormatPropertyValue Lib "propsys.dll" (ByVal pps As LongPtr, ByVal ppd As LongPtr, ByVal pdff As PROPDESC_FORMAT_FLAGS, ppszDisplay As LongPtr) As Long
Private Declare PtrSafe Function RedrawWindow Lib "user32" (ByVal hWnd As LongPtr, ByVal lprcUpdate As LongPtr, ByVal hrgnUpdate As LongPtr, ByVal fuRedraw As Long) As Long
Private Declare PtrSafe Function RegisterClipboardFormatW Lib "user32" (ByVal lpszFormat As LongPtr) As Long
Private Declare PtrSafe Function RegisterDragDrop Lib "ole32" (ByVal hWnd As LongPtr, ByVal DropTarget As IDropTarget) As Long
Private Declare PtrSafe Function ReleaseDC Lib "user32" (ByVal hWnd As LongPtr, ByVal hDC As LongPtr) As Long
Private Declare PtrSafe Function RevokeDragDrop Lib "ole32" (ByVal hWnd As LongPtr) As Long
Private Declare PtrSafe Function ScreenToClient Lib "user32" (ByVal hWnd As LongPtr, lpPoint As Any) As Long ' lpPoint As POINT) As Long
Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr
Private Declare PtrSafe Function SendMessageW Lib "user32" (ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr
Private Declare PtrSafe Function SetCursor Lib "user32" (ByVal hCursor As LongPtr) As LongPtr
Private Declare PtrSafe Function SetFocusAPI Lib "user32" Alias "SetFocus" (ByVal hWnd As LongPtr) As LongPtr
Private Declare PtrSafe Function SetTimer Lib "user32" (ByVal hWnd As LongPtr, ByVal nIDEvent As LongPtr, ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As LongPtr
Private Declare PtrSafe Function SetWindowPos Lib "user32" (ByVal hWnd As LongPtr, ByVal hWndInsertAfter As LongPtr, ByVal X As Long, ByVal Y As Long, ByVal CX As Long, ByVal cy As Long, ByVal wFlags As ucst_SWP_Flags) As Long
Private Declare PtrSafe Function SetWindowTheme Lib "uxtheme" (ByVal hWnd As LongPtr, ByVal pszSubAppName As LongPtr, ByVal pszSubIdList As LongPtr) As Long
Private Declare PtrSafe Function SHDoDragDrop Lib "Shell32" (ByVal hWnd As LongPtr, ByVal pdtobj As LongPtr, ByVal pdsrc As LongPtr, ByVal dwEffect As Long, pdwEffect As Long) As Long
Private Declare PtrSafe Function SHFileOperationW Lib "Shell32" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Declare PtrSafe Function SHGetFileInfo Lib "shell32" Alias "SHGetFileInfoA" (ByVal pszPath As Any, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As ucst_SHGFI_flags) As LongPtr
Private Declare PtrSafe Function SHGetFolderLocation Lib "shell32.dll" (ByVal hWndOwner As LongPtr, ByVal nFolder As Long, ByVal hToken As LongPtr, ByVal dwReserved As Long, ppidl As LongPtr) As Long
Private Declare PtrSafe Function SHGetImageList Lib "shell32.dll" (ByVal iImageList As ucst_ShellImageListFlags, ByRef riid As UUID, ByRef ppv As Any) As Long
Private Declare PtrSafe Function SHGetKnownFolderIDList Lib "Shell32" (rfid As Any, ByVal dwFlags As Long, ByVal hToken As LongPtr, pidl As LongPtr) As Long
Private Declare PtrSafe Sub SHGetSetSettings Lib "shell32.dll" (ByRef lpss As SHELLSTATE, ByVal dwMask As SFS_MASK, Optional ByVal bSet As Long)
Private Declare PtrSafe Function SHGetSettings Lib "Shell32" (lpsfs As Integer, ByVal dwMask As SFS_MASK) As Long
Private Declare PtrSafe Function StrCmpLogicalW Lib "shlwapi" (ByVal lpStr1 As LongPtr, ByVal lpStr2 As LongPtr) As Long
Private Declare PtrSafe Function SysReAllocString Lib "oleaut32.dll" (ByVal pBSTR As LongPtr, Optional ByVal pszStrPtr As LongPtr) As Long
Private Declare PtrSafe Function TrackPopupMenu Lib "user32" (ByVal hMenu As LongPtr, ByVal wFlags As ucst_TPM_wFlags, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As LongPtr, lpRC As Any) As Long
Private Declare PtrSafe Function TranslateMessage Lib "user32" (ByRef lpMsg As Any) As Long
Private Declare PtrSafe Function UpdateWindow Lib "user32" (ByVal hWnd As LongPtr) As Long
Private Declare PtrSafe Function Wow64DisableWow64FsRedirection Lib "kernel32" (pOldVal As Long) As Long
Private Declare PtrSafe Function Wow64RevertWow64FsRedirection Lib "kernel32" (pOldVal As Long) As Long
#If Win64 Then
Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongPtrW" (ByVal hWnd As LongPtr, ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongPtrW" (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
#Else
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongW" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongW" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
#End If
Private Declare PtrSafe Function DefSubclassProc Lib "comctl32.dll" Alias "#413" (ByVal hWnd As LongPtr, ByVal uMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
Private Declare PtrSafe Function SetWindowSubclass Lib "comctl32.dll" Alias "#410" (ByVal hWnd As LongPtr, ByVal pfnSubclass As LongPtr, ByVal uIdSubclass As LongPtr, Optional ByVal dwRefData As LongPtr) As Long
Private Declare PtrSafe Function RemoveWindowSubclass Lib "comctl32.dll" Alias "#412" (ByVal hWnd As LongPtr, ByVal pfnSubclass As LongPtr, ByVal uIdSubclass As LongPtr) As Long
Private Type MSG
hWnd As LongPtr
message As Long
wParam As LongPtr
lParam As LongPtr
Time As Long
PT As POINT
End Type
Private Const PM_NOREMOVE As Long = 0&
Private Const PM_REMOVE As Long = 1&
'
Private Const CLR_NONE = &HFFFFFFFF
Private Const RDW_UPDATENOW As Long = &H100
Private Const RDW_INVALIDATE As Long = &H1
Private Const RDW_ERASE As Long = &H4
Private Const RDW_ALLCHILDREN As Long = &H80
Private Type VS_FIXEDFILEINFO
dwSignature As Long
dwStrucVersionl As Integer ' e.g. = &h0000 = 0
dwStrucVersionh As Integer ' e.g. = &h0042 = .42
dwFileVersionMSl As Integer ' e.g. = &h0003 = 3
dwFileVersionMSh As Integer ' e.g. = &h0075 = .75
dwFileVersionLSl As Integer ' e.g. = &h0000 = 0
dwFileVersionLSh As Integer ' e.g. = &h0031 = .31
dwProductVersionMSl As Integer ' e.g. = &h0003 = 3
dwProductVersionMSh As Integer ' e.g. = &h0010 = .1
dwProductVersionLSl As Integer ' e.g. = &h0000 = 0
dwProductVersionLSh As Integer ' e.g. = &h0031 = .31
dwFileFlagsMask As Long ' = &h3F for version "0.42"
dwFileFlags As Long ' e.g. VFF_DEBUG Or VFF_PRERELEASE
dwFileOS As Long ' e.g. VOS_DOS_WINDOWS16
dwFileType As Long ' e.g. VFT_DRIVER
dwFileSubtype As Long ' e.g. VFT2_DRV_KEYBOARD
dwFileDateMS As Long ' e.g. 0
dwFileDateLS As Long ' e.g. 0
End Type
Private Type VS_VERSIONINFO_FIXED_PORTION
wLength As Integer
wValueLength As Integer
wType As Integer
szKey(1 To 16) As Integer 'Unicode "VS_VERSION_INFO" & vbNullChar.
Padding1(1 To 1) As Integer 'Pad next field to DWORD boundary.
Value As VS_FIXEDFILEINFO
End Type
Private Const RT_VERSION = 16
Private Enum ucst_SWP_Flags
SWP_NOSIZE = &H1
SWP_NOMOVE = &H2
SWP_NOZORDER = &H4
SWP_NOREDRAW = &H8
SWP_NOACTIVATE = &H10
SWP_FRAMECHANGED = &H20
SWP_DRAWFRAME = &H20
SWP_SHOWWINDOW = &H40
SWP_HIDEWINDOW = &H80
SWP_NOCOPYBITS = &H100
SWP_NOREPOSITION = &H200
SWP_NOSENDCHANGING = &H400
SWP_DEFERERASE = &H2000
SWP_ASYNCWINDOWPOS = &H4000
End Enum
Private Const SM_CYFRAME As Long = 33
Private Const SM_CYCAPTION = 4
Private Const IDC_ARROW = 32512&
Private Const IDC_WAIT = 32514&
Private Const COLOR_WINDOWTEXT = 8
Private Const UNICODE_NOCHAR = &HFFFF
Private Const LOGPIXELSX = 88
Private Const LOGPIXELSY = 90
Private Const LF_FACESIZE As Long = 32
Private Const FW_NORMAL As Long = 400
Private Const FW_BOLD As Long = 700
Private Const DEFAULT_QUALITY As Long = 0
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(0 To ((LF_FACESIZE * 2) - 1)) As Byte
End Type
Private Type DLLVERSIONINFO
cbSize As Long
dwMajor As Long
dwMinor As Long