-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCConsoul.cls
1347 lines (1226 loc) · 44.7 KB
/
CConsoul.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
END
Attribute VB_Name = "CConsoul"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'CConsoul.bas
' VB/A wrapper for the Consoul library
'
'(C) 2018, devinfo.net, Développement Informatique Services, Francesco Foti
'Library docs: https://consoul.net/docs/reference/index.htm
'VBA SDK docs: https://consoul.net/docs/sdk/vba/index.htm
#If MSACCESS Then
Option Compare Database
#End If
Option Explicit
Public Enum eConsoulCreateAttributes
LW_CREATE_FILLEDVEMPTY = 1
LW_AUTOADJUST_ON_MAXCHARWIDTH = 2
LW_NO_AUTOREDRAW = 4
LW_RENDERMODEBYLINE = 8
LW_SEND_MOUSEMOVE = 16 'Use SendMessage(), not for VB/A w/o subclassing
LW_TRACK_ZONES = 32
LW_SENDMESSAGE_NOCALLBACKS = 64
LW_MULTIZONECLICK = 128
LW_BKCOLSPILL = 256
End Enum
Public Enum eWmMouseButton
WM_LBUTTONDOWN = &H201
WM_LBUTTONUP = &H202
WM_LBUTTONDBLCLK = &H203
WM_RBUTTONDOWN = &H204
WM_RBUTTONUP = &H205
WM_RBUTTONDBLCLK = &H206
WM_MBUTTONDOWN = &H207
WM_MBUTTONUP = &H208
WM_MBUTTONDBLCLK = &H209
WM_XBUTTONDOWN = &H20B
WM_XBUTTONUP = &H20C
WM_XBUTTONDBLCLK = &H20D
End Enum
Public Enum eRenderMode
rmContinuous = 0
rmByLine = 1
End Enum
Public Enum ePaintCallbackMode 'bit 0 and 1 used
WMPAINTCBK_NONE = 0
WMPAINTCBK_BEFORE = 1
WMPAINTCBK_AFTER = 2
End Enum
Public Enum eLineVerticalLocation
elsTop
elsBottom
End Enum
#If Win64 Then
'Consoul API 64bits declarations
Private Declare PtrSafe Function CSClear Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSCreateLogWindow Lib "consoul_010205_64.dll" _
(ByVal hwndParent As LongPtr, _
ByVal X As Long, ByVal Y As Long, ByVal Width As Long, ByVal Height As Long, _
ByVal lBackColor As Long, ByVal lForeColor As Long, _
ByVal sFontName As LongPtr, ByVal iFontSize As Integer, _
ByVal iQueueSize As Integer, ByVal pwCreateAttribs As Integer) As LongPtr
Private Declare PtrSafe Function CSDestroyLogWindow Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetAutoRedraw Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetCaretBlinkMs Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetCaretHeight Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetCaretPos Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByRef wRow As Integer, _
ByRef wCol As Integer _
) As Integer
Private Declare PtrSafe Function CSGetCaretWidth Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetCharHeight Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetCharWidth Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetFontUnicodeRange Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal lIndex As Long, _
ByVal lRetLow As LongPtr, _
ByVal lRetCount As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetHoverCursor Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As LongPtr
Private Declare PtrSafe Function CSGetLineHeight Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetLinePadding Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wTopOrBottom As Integer _
) As Integer
Private Declare PtrSafe Function CSGetLineSpacing Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wTopOrBottom As Integer _
) As Integer
Private Declare PtrSafe Function CSGetLineText Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wLine As Integer, _
ByVal wBufferCharLen As Integer, _
ByVal lpStringBuffer As LongPtr, _
ByVal wAsVt100 As Integer _
) As Integer
Private Declare PtrSafe Function CSGetMaxCharWidth Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetMaxVisibleCols Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetMaxVisibleRows Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetMouseCursor Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As LongPtr
Private Declare PtrSafe Function CSGetMultiZoneClick Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetQueueCapacity Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetRenderMode Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetTopLine Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetTrackZones Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetUseCallbacks Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetVersion Lib "consoul_010205_64.dll" ( _
ByVal lpStringBuffer As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetZoneTag Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wLine As Integer, _
ByVal wZoneID As Integer, _
ByVal wBufferCharLen As Integer, _
ByVal lpStringBuffer As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetZoneText Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wLine As Integer, _
ByVal wZoneID As Integer, _
ByVal wBufferCharLen As Integer, _
ByVal lpStringBuffer As LongPtr, _
ByVal wAsVt100 As Integer _
) As Integer
Private Declare PtrSafe Function CSIsCaretVisible Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSLineCount Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSLoadFontUnicodeRanges Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Long
Private Declare Function CSPaintOnDC Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal hdc As LongPtr, _
ByVal lWidth As Long, _
ByVal lHeight As Long, _
ByVal iStartLine As Integer, _
ByVal iEndLine As Integer _
) As Integer
Private Declare PtrSafe Function CSPopLines Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wPopCount As Integer _
) As Integer
Private Declare PtrSafe Function CSPushLine Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal lpszString As LongPtr, _
ByVal wNoParsing As Integer _
) As Integer
Private Declare PtrSafe Function CSRedrawLine Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal iLine As Integer _
) As Integer
Private Declare PtrSafe Function CSRefreshWindow Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSReplaceZone Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wLine As Integer, _
ByVal wZoneID As Integer, _
ByVal lpszReplaceBy As LongPtr, _
ByVal wNoParsing As Integer _
) As Integer
Private Declare PtrSafe Function CSResetAllLines Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Integer
Private Declare PtrSafe Function CSSetAlphaTransparency Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal bPercent As Byte _
) As Integer
Private Declare PtrSafe Function CSSetAutoRedraw Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wAutoRedraw As Integer _
) As Integer
Private Declare PtrSafe Function CSSetCaretBlinkMs Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wMillisecs As Integer _
) As Integer
Private Declare PtrSafe Function CSSetCaretHeight Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wHeight As Integer _
) As Integer
Private Declare PtrSafe Function CSSetCaretPos Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wRow As Integer, _
ByVal wCol As Integer _
) As Integer
Private Declare PtrSafe Function CSSetCaretWidth Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wWidth As Integer _
) As Integer
Private Declare PtrSafe Function CSSetColorTransparency Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal bPercent As Byte, _
ByVal lColorRef As Long, _
ByVal bEnabled As Byte _
) As Integer
Private Declare PtrSafe Function CSSetHoverCursor Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal hCursor As LongPtr _
) As Integer
Private Declare PtrSafe Function CSSetLine Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal iLine As Integer, _
ByVal lpszString As LongPtr, _
ByVal wNoParsing As Integer, _
ByVal wNoUpdate As Integer _
) As Integer
Private Declare PtrSafe Function CSSetLinePadding Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wSpacing As Integer, _
ByVal wTopOrBottom As Integer _
) As Integer
Private Declare PtrSafe Function CSSetLineSpacing Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wSpacing As Integer, _
ByVal wTopOrBottom As Integer _
) As Integer
Private Declare PtrSafe Function CSSetMouseCursor Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal hCursor As LongPtr _
) As Integer
Private Declare PtrSafe Function CSGetMultiZoneClick Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wMulti As Integer _
) As Integer
Private Declare PtrSafe Function CSSetRenderMode Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wRenderMode As Integer _
) As Integer
Private Declare PtrSafe Function CSSetTrackZones Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wTrack As Integer _
) As Integer
Private Declare PtrSafe Function CSSetUseCallbacks Lib "consoul_010205_32.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wUseCallbacks As Integer _
) As Integer
Private Declare PtrSafe Function CSShowCaret Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal wShow As Integer _
) As Integer
Private Declare PtrSafe Function CSTextWidth Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr, _
ByVal lpszText As LongPtr, _
ByVal lDTFlags As Long _
) As Integer
Private Declare PtrSafe Function CSUnloadFontUnicodeRanges Lib "consoul_010205_64.dll" ( _
ByVal hWnd As LongPtr _
) As Long
'(Undocumented functions)
Private Declare PtrSafe Function CSClickAtCaretPos Lib "consoul_010205_64.dll" (ByVal hWnd As LongPtr, ByVal plClickMsg As Long) As Integer
Private Declare PtrSafe Function CSGetLongestLineWidth Lib "consoul_010205_64.dll" (ByVal hWnd As LongPtr) As Long
Private Declare PtrSafe Function CSSetAutoAdjustWidth Lib "consoul_010205_64.dll" (ByVal hWnd As LongPtr, ByVal pwAutoAdjustWidth As Integer) As Integer
Private Declare PtrSafe Function CSGetAutoAdjustWidth Lib "consoul_010205_64.dll" (ByVal hWnd As LongPtr) As Integer
'Set callbacks
Private Declare PtrSafe Function CSSetOnMouseButtonCallback Lib "consoul_010205_64.dll" (ByVal hWnd As LongPtr, ByVal pEvtProc As LongPtr) As Integer
Private Declare PtrSafe Function CSSetOnVirtuaLineCallback Lib "consoul_010205_64.dll" (ByVal hWnd As LongPtr, ByVal pEvtProc As LongPtr) As Integer
Private Declare PtrSafe Function CSSetOnWmPaintCallback Lib "consoul_010205_64.dll" (ByVal hWnd As LongPtr, ByVal pwCbkMode As Integer, ByVal pEvtProc As LongPtr) As Integer
Private Declare PtrSafe Function CSSetOnDrawZoneCallback Lib "consoul_010205_64.dll" (ByVal hWnd As LongPtr, ByVal pEvtProc As LongPtr) As Integer
'Win32 API rarely used outside this class
Private Declare PtrSafe Function SetScrollPos Lib "user32" (ByVal hWnd As LongPtr, ByVal nBar As Long, ByVal nPos As Long, ByVal bRedraw As Long) As Long
#Else
'Consoul API 32bits declarations
Private Declare Function CSClear Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSCreateLogWindow Lib "consoul_010205_32.dll" ( _
ByVal hwndParent As Long, _
ByVal X As Long, ByVal Y As Long, ByVal Width As Long, ByVal Height As Long, _
ByVal lBackColor As Long, ByVal lForeColor As Long, _
ByVal sFontName As Long, ByVal iFontSize As Integer, _
ByVal iQueueSize As Integer, ByVal wCreateAttribs As Integer _
) As Long
Private Declare Function CSDestroyLogWindow Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetAutoRedraw Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetCaretBlinkMs Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetCaretHeight Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetCaretPos Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByRef wRow As Integer, _
ByRef wCol As Integer _
) As Integer
Private Declare Function CSGetCaretWidth Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetCharHeight Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetCharWidth Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetFontUnicodeRange Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal lIndex As Long, _
ByVal lRetLow As Long, _
ByVal lRetCount As Long _
) As Integer
Private Declare Function CSGetHoverCursor Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Long
Private Declare Function CSGetLineHeight Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetLinePadding Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wTopOrBottom As Integer _
) As Integer
Private Declare Function CSGetLineSpacing Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wTopOrBottom As Integer _
) As Integer
Private Declare Function CSGetLineText Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wLine As Integer, _
ByVal wBufferCharLen As Integer, _
ByVal lpszStringBuffer As Long, _
ByVal wAsVt100 As Integer _
) As Integer
Private Declare Function CSGetMaxCharWidth Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetMaxVisibleCols Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetMaxVisibleRows Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetMouseCursor Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Long
Private Declare Function CSGetMultiZoneClick Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetQueueCapacity Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetRenderMode Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetTopLine Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetTrackZones Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetUseCallbacks Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSGetVersion Lib "consoul_010205_32.dll" ( _
ByVal lpStringBuffer As Long _
) As Integer
Private Declare Function CSGetZoneTag Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wLine As Integer, _
ByVal wZoneID As Integer, _
ByVal wBufferCharLen As Integer, _
ByVal lpStringBuffer As Long _
) As Integer
Private Declare Function CSGetZoneText Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wLine As Integer, _
ByVal wZoneID As Integer, _
ByVal wBufferCharLen As Integer, _
ByVal lpStringBuffer As Long, _
ByVal wAsVt100 As Integer _
) As Integer
Private Declare Function CSIsCaretVisible Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSLineCount Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSLoadFontUnicodeRanges Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Long
Private Declare Function CSPaintOnDC Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal hdc As Long, _
ByVal lWidth As Long, _
ByVal lHeight As Long, _
ByVal iStartLine As Integer, _
ByVal iEndLine As Integer _
) As Integer
Private Declare Function CSPopLines Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wPopCount As Integer _
) As Integer
Private Declare Function CSPushLine Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal lpszString As Long, _
ByVal wNoParsing As Integer _
) As Integer
Private Declare Function CSRedrawLine Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal iLine As Integer _
) As Integer
Private Declare Function CSRefreshWindow Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSReplaceZone Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wLine As Integer, _
ByVal wZoneID As Integer, _
ByVal lpszReplaceBy As Long, _
ByVal wNoParsing As Integer _
) As Integer
Private Declare Function CSResetAllLines Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
Private Declare Function CSSetAlphaTransparency Lib "consoul_010205_32.dll" ( _
ByVal hWnd As LongPtr, _
ByVal bPercent As Byte _
) As Integer
Private Declare Function CSSetAutoRedraw Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wAutoRedraw As Integer _
) As Integer
Private Declare Function CSSetCaretBlinkMs Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wMillisecs As Integer _
) As Integer
Private Declare Function CSSetCaretHeight Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wHeight As Integer _
) As Integer
Private Declare Function CSSetCaretPos Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wRow As Integer, _
ByVal wCol As Integer _
) As Integer
Private Declare Function CSSetCaretWidth Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wWidth As Integer _
) As Integer
Private Declare PtrSafe Function CSSetColorTransparency Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal bPercent As Byte, _
ByVal lColorRef As Long, _
ByVal bEnabled As Byte _
) As Integer
Private Declare Function CSSetHoverCursor Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal hCursor As Long _
) As Integer
Private Declare Function CSSetLine Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal iLine As Integer, _
ByVal lpszString As Long, _
ByVal wNoParsing As Integer, _
ByVal wNoUpdate As Integer _
) As Integer
Private Declare Function CSSetLinePadding Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wSpacing As Integer, _
ByVal wTopOrBottom As Integer _
) As Integer
Private Declare Function CSSetLineSpacing Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wSpacing As Integer, _
ByVal wTopOrBottom As Integer _
) As Integer
Private Declare Function CSSetMouseCursor Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal hCursor As Long _
) As Integer
Private Declare Function CSSetMultiZoneClick Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wMulti As Integer _
) As Integer
Private Declare Function CSSetRenderMode Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wRenderMode As Integer _
) As Integer
Private Declare Function CSSetTrackZones Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wTrack As Integer _
) As Integer
Private Declare Function CSSetUseCallbacks Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wUseCallbacks As Integer _
) As Integer
Private Declare Function CSShowCaret Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal wShow As Integer _
) As Integer
Private Declare Function CSTextWidth Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long, _
ByVal lpszText As Long, _
ByVal lDTFlags As Long _
) As Integer
Private Declare Function CSUnloadFontUnicodeRanges Lib "consoul_010205_32.dll" ( _
ByVal hWnd As Long _
) As Integer
'(Undocumented functions)
Private Declare Function CSClickAtCaretPos Lib "consoul_010205_32.dll" (ByVal hWnd As Long, ByVal plClickMsg As Long) As Integer
Private Declare Function CSGetLongestLineWidth Lib "consoul_010205_32.dll" (ByVal hWnd As Long) As Long
Private Declare Function CSSetAutoAdjustWidth Lib "consoul_010205_32.dll" (ByVal hWnd As Long, ByVal pwAutoAdjustWidth As Integer) As Integer
Private Declare Function CSGetAutoAdjustWidth Lib "consoul_010205_32.dll" (ByVal hWnd As Long) As Integer
'Set callbacks
Private Declare Function CSSetOnMouseButtonCallback Lib "consoul_010205_32.dll" (ByVal hWnd As Long, ByVal pEvtProc As Long) As Integer
Private Declare Function CSSetOnVirtuaLineCallback Lib "consoul_010205_32.dll" (ByVal hWnd As Long, ByVal pEvtProc As Long) As Integer
Private Declare Function CSSetOnWmPaintCallback Lib "consoul_010205_32.dll" (ByVal hWnd As Long, ByVal pwCbkMode As Integer, ByVal pEvtProc As Long) As Integer
Private Declare Function CSSetOnDrawZoneCallback Lib "consoul_010205_32.dll" (ByVal hWnd As Long, ByVal pEvtProc As Long) As Integer
'Win32 API rarely used outside this class
Private Declare Function SetScrollPos Lib "user32" (ByVal hWnd As Long, ByVal nBar As Long, ByVal nPos As Long, ByVal bRedraw As Long) As Long
#End If
'Private class members
#If Win64 Then
Private mhWnd As LongPtr
Private mhWndParent As LongPtr
#Else
Private mhWnd As Long
Private mhWndParent As Long
#End If
Private msBuffer As String
'Public properties (free r/w access, w/o property proc)
Public FontName As String
Public FontSize As Integer
Public WindowTitle As String
Public BackColor As Long
Public ForeColor As Long
Public MaxCapacity As Integer
Public WithFrame As Boolean
'Track window position and dimensions
Private mrcWindow As RECT
Private Sub Class_Initialize()
' Set some defaults
Me.FontName = "Courier New"
Me.FontSize = 14
Me.WindowTitle = "Consoul Window"
Me.BackColor = vbBlack
Me.ForeColor = RGB(200, 200, 200)
Me.WithFrame = False
End Sub
Private Sub Class_Terminate()
If mhWnd <> 0 Then
Call CSDestroyLogWindow(mhWnd)
mhWnd = 0
End If
End Sub
' -------- Class properties & events
#If Win64 Then
Public Property Get hwndParent() As LongPtr
#Else
Public Property Get hwndParent() As Long
#End If
hwndParent = mhWndParent
End Property
#If Win64 Then
Public Property Get hWnd() As LongPtr
#Else
Public Property Get hWnd() As Long
#End If
hWnd = mhWnd
End Property
'The number of text lines in the windows queue
Public Property Get LineCount() As Integer
LineCount = CSLineCount(mhWnd)
End Property
Public Property Get TopLine() As Integer
If mhWnd <> 0 Then TopLine = CSGetTopLine(mhWnd)
End Property
Public Property Get CharWidth() As Integer
If mhWnd <> 0 Then CharWidth = CSGetCharWidth(mhWnd)
End Property
Public Property Get MaxCharWidth() As Integer
If mhWnd <> 0 Then MaxCharWidth = CSGetMaxCharWidth(mhWnd)
End Property
Public Property Get CharHeight() As Integer
If mhWnd <> 0 Then CharHeight = CSGetCharHeight(mhWnd)
End Property
Public Property Get MaxVisibleCols() As Integer
If mhWnd <> 0 Then MaxVisibleCols = CSGetMaxVisibleCols(mhWnd)
End Property
Public Property Get MaxVisibleRows() As Integer
If mhWnd <> 0 Then MaxVisibleRows = CSGetMaxVisibleRows(mhWnd)
End Property
Public Property Get ConsoulVersion() As String
Dim sBuffer As String
Dim i As Integer
sBuffer = Space$(25) 'at least 25 chars as specs tell
Call CSGetVersion(StrPtr(sBuffer))
sBuffer = StrConv(sBuffer, vbUnicode)
i = InStr(1, sBuffer, Chr$(0))
If i > 0 Then
sBuffer = left$(sBuffer, i - 1)
End If
ConsoulVersion = sBuffer
End Property
Public Property Get MultiZoneClick() As Boolean
If mhWnd Then
MultiZoneClick = CBool(CSGetMultiZoneClick(mhWnd))
End If
End Property
Public Property Let TrackZones(ByVal pfAllowed As Boolean)
If mhWnd Then
CSSetTrackZones mhWnd, Abs(CInt(pfAllowed))
End If
End Property
Public Property Get TrackZones() As Boolean
If mhWnd Then
TrackZones = CBool(CSGetTrackZones(mhWnd))
End If
End Property
Public Property Let MultiZoneClick(ByVal pfAllowed As Boolean)
If mhWnd Then
CSSetMultiZoneClick mhWnd, Abs(CInt(pfAllowed))
End If
End Property
Public Property Get CaretWidth() As Integer
If mhWnd Then
CaretWidth = CSGetCaretWidth(mhWnd)
End If
End Property
Public Property Let CaretWidth(ByVal piNewWidth As Integer)
If mhWnd Then
Call CSSetCaretWidth(mhWnd, piNewWidth)
End If
End Property
Public Property Get CaretHeight() As Integer
If mhWnd Then
CaretHeight = CSGetCaretHeight(mhWnd)
End If
End Property
Public Property Let CaretHeight(ByVal piNewHeight As Integer)
If mhWnd Then
Call CSSetCaretHeight(mhWnd, piNewHeight)
End If
End Property
Public Property Get AutoAdjustWidth() As Boolean
If mhWnd Then
AutoAdjustWidth = CSGetAutoAdjustWidth(mhWnd)
End If
End Property
Public Property Let AutoAdjustWidth(ByVal pfAutoAdjustWidth As Boolean)
If mhWnd Then
Call CSSetAutoAdjustWidth(mhWnd, Abs(CInt(pfAutoAdjustWidth)))
End If
End Property
Public Property Get left() As Integer
left = mrcWindow.left
End Property
Public Property Get Top() As Integer
Top = mrcWindow.Top
End Property
Public Property Get Width() As Integer
Width = (mrcWindow.Bottom - mrcWindow.Top)
End Property
Public Property Get Height() As Integer
Height = (mrcWindow.Right - mrcWindow.left)
End Property
Public Sub GetSizeAndPosRect(ByRef prcRetSize As RECT)
apiCopyRect prcRetSize, mrcWindow
End Sub
Public Sub SetSizeAndPosRect(ByRef prcSizeAndPos As RECT, Optional ByVal bRepaint As Long = 1)
With prcSizeAndPos
Me.MoveWindow .left, .Top, .Right - .left, .Bottom - .Top, bRepaint
End With
End Sub
#If Win64 Then
Public Function Attach( _
ByVal phWndParent As LongPtr, _
ByVal X As Long, ByVal Y As Long, ByVal Width As Long, ByVal Height As Long, _
Optional ByVal OnMouseBtnEvtProc As LongPtr = 0, _
Optional ByVal OnZoneDrawEvtProc As LongPtr = 0, _
Optional ByVal OnVirtuaLineEvtProc As LongPtr = 0, _
Optional ByVal piCreateAttributes As eConsoulCreateAttributes = LW_RENDERMODEBYLINE) As Boolean
#Else
Public Function Attach( _
ByVal phWndParent As Long, _
ByVal X As Long, ByVal Y As Long, ByVal Width As Long, ByVal Height As Long, _
Optional ByVal OnMouseBtnEvtProc As LongPtr = 0, _
Optional ByVal OnZoneDrawEvtProc As LongPtr = 0, _
Optional ByVal OnVirtuaLineEvtProc As LongPtr = 0, _
Optional ByVal piCreateAttributes As eConsoulCreateAttributes = LW_RENDERMODEBYLINE) As Boolean
#End If
mhWnd = CSCreateLogWindow( _
phWndParent, _
X, Y, Width, Height, _
Me.BackColor, Me.ForeColor, _
StrPtr(Me.FontName), Me.FontSize, _
Me.MaxCapacity, _
CInt(piCreateAttributes))
If mhWnd <> 0 Then
'if no max capacity was provided, consoul decides for us
If Me.MaxCapacity = 0 Then Me.MaxCapacity = CSGetQueueCapacity(mhWnd)
mhWndParent = phWndParent 'Used when creating log windows to set parent
If OnMouseBtnEvtProc <> 0 Then
Call CSSetOnMouseButtonCallback(mhWnd, OnMouseBtnEvtProc)
End If
If OnZoneDrawEvtProc <> 0 Then
Call CSSetOnDrawZoneCallback(mhWnd, OnZoneDrawEvtProc)
End If
If OnVirtuaLineEvtProc <> 0 Then
Call CSSetOnVirtuaLineCallback(mhWnd, OnVirtuaLineEvtProc)
End If
End If
Attach = True
End Function
#If Win64 Then
Public Sub SetMouseButtonCallback(ByVal lpProcAddress As LongPtr)
#Else
Public Sub SetMouseButtonCallback(ByVal lpProcAddress As Long)
#End If
If mhWnd <> 0 Then
Call CSSetOnMouseButtonCallback(mhWnd, lpProcAddress)
End If
End Sub
#If Win64 Then
Public Sub SetDrawZoneCallback(ByVal lpProcAddress As LongPtr)
#Else
Public Sub SetDrawZoneCallback(ByVal lpProcAddress As Long)
#End If
If mhWnd <> 0 Then
Call CSSetOnDrawZoneCallback(mhWnd, lpProcAddress)
End If
End Sub
#If Win64 Then
Public Sub SetVirtuaLineCallback(ByVal lpProcAddress As LongPtr)
#Else
Public Sub SetVirtuaLineCallback(ByVal lpProcAddress As Long)
#End If
If mhWnd <> 0 Then
Call CSSetOnVirtuaLineCallback(mhWnd, lpProcAddress)
End If
End Sub
#If Win64 Then
Public Sub SetWmPaintCallback(ByVal pwCbkModeBits As ePaintCallbackMode, ByVal lpProcAddress As LongPtr)
#Else
Public Sub SetWmPaintCallback(ByVal pwCbkModeBits As ePaintCallbackMode, ByVal lpProcAddress As Long)
#End If
If mhWnd <> 0 Then
Call CSSetOnWmPaintCallback(mhWnd, pwCbkModeBits, lpProcAddress)
End If
End Sub
Public Sub Detach()
If mhWnd <> 0 Then CSDestroyLogWindow mhWnd
mhWnd = 0
End Sub
Public Property Get AutoRedraw() As Boolean
If mhWnd <> 0 Then
AutoRedraw = CBool(CSGetAutoRedraw(mhWnd))
Exit Property
End If
AutoRedraw = True
End Property
Public Property Let AutoRedraw(ByVal pfFlag As Boolean)
If mhWnd <> 0 Then
Call CSSetAutoRedraw(mhWnd, Abs(CInt(pfFlag)))
End If
End Property
Public Property Get RenderMode() As eRenderMode
If mhWnd <> 0 Then
RenderMode = CSGetRenderMode(mhWnd)
End If
End Property
Public Property Let RenderMode(ByVal peMode As eRenderMode)
If mhWnd <> 0 Then
Call CSSetRenderMode(mhWnd, CInt(peMode))
End If
End Property
Public Property Get TextWidth(ByVal psText As String, Optional ByVal plDTFlags As Long = 0&) As Integer
If mhWnd <> 0 Then
TextWidth = CSTextWidth(mhWnd, StrPtr(psText), plDTFlags)
End If
End Property
' -------- Win32 API wrappers / facilitators
Public Sub GetClientRect(ByRef prcClient As RECT)
If mhWnd <> 0 Then Call apiGetClientRect(mhWnd, prcClient)
End Sub
Public Sub GetParentClientRect(ByRef prcClient As RECT)
If mhWnd <> 0 Then
If mhWndParent > 0 Then
Call apiGetClientRect(mhWndParent, prcClient)
End If
End If
End Sub
Public Function GetClientWidth() As Integer
If mhWnd = 0 Then Exit Function
Dim rcClient As RECT
Call apiGetClientRect(mhWnd, rcClient)
GetClientWidth = rcClient.Right - rcClient.left
End Function
Public Function GetClientHeight() As Integer
If mhWnd = 0 Then Exit Function
Dim rcClient As RECT
Call apiGetClientRect(mhWnd, rcClient)
GetClientHeight = rcClient.Bottom - rcClient.Top
End Function
Public Sub ShowWindow(ByVal pfVisible As Boolean)
If mhWnd <> 0 Then apiShowWindow mhWnd, IIf(pfVisible, SW_SHOW, SW_HIDE)
End Sub
Public Sub MoveWindow(ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, Optional ByVal bRepaint As Long = 1)
If mhWnd <> 0 Then
apiMoveWindow mhWnd, X, Y, nWidth, nHeight, bRepaint
With mrcWindow
.left = X
.Top = Y
.Right = X + nWidth
.Bottom = Y + nHeight
End With
End If
End Sub
Public Sub BringWindowToTop()
If mhWnd <> 0 Then apiBringWindowToTop (mhWnd)
End Sub
#If Win64 Then
Public Sub SetWindowPos(ByVal phWndInsertAfter As LongPtr, ByVal px As Long, ByVal py As Long, ByVal nWidth As Long, ByVal nHeight As Long, Optional ByVal pwFlags As Long = 0&)
#Else
Public Sub SetWindowPos(ByVal phWndInsertAfter As Long, ByVal px As Long, ByVal py As Long, ByVal nWidth As Long, ByVal nHeight As Long, Optional ByVal pwFlags As Long = 0&)
#End If
If mhWnd <> 0 Then
Dim X As Integer
Dim Y As Integer
Dim iWidth As Integer
Dim iHeight As Integer
X = mrcWindow.left
Y = mrcWindow.Top
iWidth = mrcWindow.Right - mrcWindow.left
iHeight = mrcWindow.Bottom - mrcWindow.Top
apiSetWindowPos mhWnd, phWndInsertAfter, px, py, nWidth, nHeight, pwFlags
If Not (pwFlags And SWP_NOREPOSITION) Then 'adjust member variables tracking position
X = px
Y = py
End If
If Not (pwFlags And SWP_NOSIZE) Then 'adjust member variables tracking size
iWidth = nWidth
iHeight = nHeight
End If
apiSetRect mrcWindow, X, Y, X + iWidth, X + iHeight
End If
End Sub
' -------- Console output methods
'Append a chunk of text to the internal console line buffer.
'The internal buffer is pushed in the console's window queue
'at the next OutputLn call.
Public Sub Output(ByVal psLine As String)
If mhWnd <> 0 Then msBuffer = msBuffer & psLine
End Sub
'Push the msBuffer (text line buffer) in the window's queue, and,
'Consoul will immediately render the console window
'if AutoRedraw is True, scroll it if necessary.
Public Function OutputLn(ByVal psLine As String, Optional ByVal piQBColorText As Variant, Optional ByVal pfNoParsing As Variant) As Integer
Dim iLine As Integer
If mhWnd <> 0 Then
If IsMissing(pfNoParsing) Then pfNoParsing = False
If Not IsMissing(piQBColorText) Then
msBuffer = VT_FCOLOR(QBColor(piQBColorText)) & msBuffer
End If
msBuffer = msBuffer & psLine & VT_RESET()
iLine = CSPushLine(mhWnd, StrPtr(msBuffer), Abs(CInt(pfNoParsing)))
msBuffer = ""
End If
OutputLn = iLine
End Function
Public Function PushVirtualLine() As Integer
PushVirtualLine = CSPushLine(mhWnd, 0&, 1)
End Function
'Change the text of an existing console line.
'piLine is the index of the line in the window queue [1..LineCount].
'Call RedrawLine after that to update the console window display accordingly.
Public Sub SetLine(ByVal piLine As Integer, ByVal psText As String, Optional ByVal pfNoParsing As Boolean = False, Optional ByVal pfRedrawLine As Boolean = False)
If mhWnd <> 0 Then
Call CSSetLine(mhWnd, piLine, StrPtr(psText), Abs(CInt(pfNoParsing)), Abs(CInt(Not pfRedrawLine)))
End If
End Sub
Public Sub ResetVirtualLine(ByVal piLine As Integer, Optional ByVal pfRedrawLine As Boolean = False)
If mhWnd <> 0 Then
Call CSSetLine(mhWnd, piLine, 0&, 0, Abs(CInt(Not pfRedrawLine)))
End If
End Sub
Public Sub MakeLineVirtual(ByVal piLine As Integer, Optional ByVal pfRedrawLine As Boolean = False)
If mhWnd <> 0 Then
Call CSSetLine(mhWnd, piLine, 0, 0, Abs(CInt(Not pfRedrawLine)))
End If
End Sub