-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathLV_A.ahk
883 lines (857 loc) · 30.5 KB
/
LV_A.ahk
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
; ---------------------------------------------------------------------------------------
; Advanced Library for ListViews
; by Dadepp
; Version 1.1 (minor bugfixes)
; http://www.autohotkey.com/forum/viewtopic.php?t=43242
; ---------------------------------------------------------------------------------------
;
; Warning: This uses the OnNotify Message handler. If you already have an
; OnNotify handler please merge these two lines into your script:
;
; if lva_hWndInfo(NumGet(lParam + 0),2)
; return lva_OnNotifyProg(wParam, lParam, msg, hwnd)
;
; If this is not done, the coloring can not take place!
; If there is NO OnNotify handler in the script, please set one by using:
;
; OnMessage("0x4E", "LVA_OnNotify")
;
; ---------------------------------------------------------------------------------------
; Notes:
; A Color Reference inside these functions are the same as with AHK itself:
; Either the name of one of the 16 Standart Colors
; (http://www.autohotkey.com/docs/commands/Progress.htm#colors)
; or an RGB color reference such as 0x0000FF (the 0x is optional).
; So if a color reference is to be used these are all equal:
; red = rEd = Red = 0xFF0000 = 0xfF0000 = FF0000 = ff0000 = fF0000
;
; All row and column numbers are 1-Based indexes !!
; ---------------------------------------------------------------------------------------
;
; List of functions the User may call:
;
; ---------------------------------------------------------------------------------------
;
; LVA_OnNotify(wParam, lParam, msg, hwnd)
;
; The OnNotify handler that can be used, if no OnNotify handler is already in place
; Please dont use otherwise! Only for use with "OnMessage("0x4E", "LVA_OnNotify")"
;
; ---------------------------------------------------------------------------------------
;
; LVA_ListViewAdd(LVvar, Options="", UseFix=true, Opt="")
;
; Makes it possible to color Cells/Rows/Columns/etc... inside the ListView.
; If this is NOT used, every other functions wont work!
; Params:
; LVvar The associated control Variable (the name of the variable,
; NOT the handle to the control!). Must be inside Quotationmarks ""
;
; Options A Space delimited list of one or more of the following:
; "AR"/"+AR" Sets the Alternating Row Coloring to active
; "-AR" Removes the Alternating Row Coloring
; "RB" Followed by a Color Reference to set the Background Color
; for the alternating rows!
; "RF" Same as "RB" except that it controls the Text Color
; "AC"/"+AC" Sets the Alternating Column Coloring to active
; "-AC" Removes the Alternating Column Coloring
; "CB" Followed by a Color Reference to set the Background Color
; for the alternating Columns!
; "CF" Same as "CB" except that it controls the Text Color
; The standard values are:
; "-AR RB0xEFEFEF RF0x000000 -AC CB0xEFEFEF CF0x000000"
;
; UseFix A Boolean that if set true forces the subclassing of the ListView.
; This is done to apply a "Fix" that Microsoft seem to not want to fix,
; since it affects all ListViews. The problem is if this is not used
; and the user scrolls the ListView up by means of the arrow button
; then extra grid lines (if used!) will be drawn at half the heigth
; of the row, same goes for custom drawn cells.
; The option to NOT apply this fix is pressent because of possible
; subclassing problems with AHK (for example if there are already too
; many subclassed controls present).
;
; Opt The Options for the RegisterCallBack() functions, used for the
; subclassing. ONLY USE IF U KNOW WHAT YOU ARE DOING !!!
;
; ---------------------------------------------------------------------------------------
;
; LVA_ListViewModify(LVvar, Options)
;
; A way to modify the Options set with LVA_ListViewAdd().
; Params:
; LVvar The name of the associated control's variable.
;
; Options The same as in LVA_ListViewAdd()
;
; ---------------------------------------------------------------------------------------
;
; LVA_Refresh(LVvar)
;
; A helper function to force a ListView to ReDraw itself
; (Works only with ListViews Specified with LVA_ListViewAdd() !)
;
; ---------------------------------------------------------------------------------------
;
; LVA_SetProgressBar(LVvar, Row, Col, cInfo="")
;
; Allows the use of a ProgressBar inside a specific Cell.
; Call without the cInfo param to remove a ProgressBar from the ListView
; Params:
; LVvar The name of the associated control's variable.
;
; Row The number of the row to be used
;
; Col The number of the column to be used
;
; cInfo A Space delimited list of one or more of the following:
; "R" Followed by a number sets the range of the ProgressBar
; "B" Followed by a Color Reference to set the Background Color
; "S" Followed by a Color Reference to set the Starting Color
; "E" Followed by a Color Reference to set the Ending Color
; (if not used the Ending Color will be the same as the
; Starting Color)
; "Smooth" Use this Option to create a different acting ProgressBar
; The standard values are: "R100 B0xFFFFFF S0x000080"
;
; ---------------------------------------------------------------------------------------
;
; LVA_Progress(Name, Row, Col, pProgress)
;
; If a ProgressBar has been set with LVA_SetProgressBar() then this sets the
; current value of this specific ProgressBar. (This repaints the ProgressBar,
; and ONLY the ProgressBar!)
; Params:
; LVvar The name of the associated control's variable.
;
; Row The number of the row to be used
;
; Col The number of the column to be used
;
; cProgress The new value. If it exceeds the Range set for this ProgressBar,
; the maximum allowed Range is used instead!
;
; ---------------------------------------------------------------------------------------
;
; LVA_SetCell(Name, Row, Col, cBGCol="", cFGCol="")
;
; Sets the Color to a specific Cell. To remove a Color, use the function
; without the "cBGCol" and "cFGCol" params! If one param is empty then
; the other one will be automaticly filled with the standard values for this
; specific ListView (these infos will be determined internally!)
; Params:
; LVvar The name of the associated control's variable.
;
; Row The number of the row to be used
;
; Col The number of the column to be used
;
; cBGCol The Color Reference for the Cells BackGround
;
; cFGCol The Color Reference for the Cells Text
;
; Note: Setting Row or Col to 0 will affect the whole Row/Column.
; The order of priority for the cells color goes:
; if specific the use this
; else if column has color
; else if row has color
; else if is an alternating column and bool is set
; else if is an alternating row and bool is set
; else standard colors
;
; ---------------------------------------------------------------------------------------
; LVA_EraseAllCells(Name)
;
; Resets ALL Color/ProgressBar Informations, for the complete ListView
; (Use with caution!)
;
; LVvar The name of the associated control's variable.
;
; ---------------------------------------------------------------------------------------
;
; The Following Functions CAN BE USED even on ListViews not specified with
; LVA_ListViewAdd()
;
; ---------------------------------------------------------------------------------------
; LVA_GetCellNum(Switch=0, LVvar="")
;
; A function to retrieve Cell-Information (Row/Column) from the cell under
; the Mouse Pointer!
; Params:
;
; Switch If set to 0 and LVvar set to the ListView in question, it
; retrieves the informations and stores the internally!
; Afterwards the LVvar param is no longer needed, and these
; infos can be requested with the following:
; (Note: These values will still hold the values from when it was
; used with Switch set to 0 even if the MousePosition changed!)
; 1 or "Row" Returns the row-number
; 2 or "Col" Returns the Column-number
; -1 or "Row-1" Returns the row-number (0-Based Index)
; -2 or "Row-2" Returns the Column-number (0-Based Index)
; "Rows" Returns the total number of Rows
; "Cols" Returns the total number of Columns
;
; The following values for Switch are special, since with them
; the Cell-Information wont be evaluated (and changed !!).
; But the LVvar param is needed again !!
; "GetRows" Returns the total number of Rows
; "GetCols" Returns the total number of Columns
;
; LVvar The name of the associated control's variable.
; Can also be a Handle !!
;
; ---------------------------------------------------------------------------------------
;
; LVA_SetSubItemImage(LVvar, Row, Col, iNum)
;
; A helper function to set an Image to any Cell. An ImageList MUST be
; associated with that ListView, and the ListView MUST have "+LV0x2" set inside
; its Style Options.
; (Note: Using a number < 1 for Row is the Same as using 1.
; Using 1 for Col , is the same as using: LV_Modify(Row, "Icon" . iNum) !)
; Params:
; LVvar The name of the associated control's variable.
;
; Row The number of the row to be used
;
; Col The number of the column to be used
;
; iNum The number of the ImageList-Icon to be used
;
; ---------------------------------------------------------------------------------------
; ---------------------------------------------------------------------------------------
; Public functions, for use look at the docu above!
; ---------------------------------------------------------------------------------------
LVA_OnNotify(wParam, lParam, msg, hwnd)
{
Critical, 500
if lva_hWndInfo(NumGet(lParam + 0),2)
return lva_OnNotifyProg(wParam, lParam, msg, hwnd)
}
LVA_ListViewAdd(LVvar, Options="", UseFix=false, Opt="")
{
tmp := lva_hWndInfo(LVvar, 1)
tmp2 :=lva_hWndInfo(0, -2, tmp)
lva_Info("SetARowBool", LVvar,0,0,false)
lva_Info("SetARowColB", LVvar,0,0,"0xEFEFEF")
lva_Info("SetARowColF", LVvar,0,0,"0x000000")
lva_Info("SetAColBool", LVvar,0,0,false)
lva_Info("SetAColColB", LVvar,0,0,"0xEFEFEF")
lva_Info("SetAColColF", LVvar,0,0,"0x000000")
SendMessage, 4096,0,0,, ahk_id %tmp2%
lva_Info("SetStdColorBG", LVvar,0,0,ErrorLevel)
SendMessage, 4131,0,0,, ahk_id %tmp2%
lva_Info("SetStdColorFG", LVvar,0,0,ErrorLevel)
LVA_ListViewModify(LVvar, Options)
if UseFix
lva_Subclass(tmp2, "lva_OnLVScroll", Opt)
LVA_Refresh(LVvar)
}
LVA_ListViewModify(LVvar, Options)
{
Loop, Parse, Options, %A_Space%
{
if (A_LoopField = "+AR")||(A_LoopField = "AR")
lva_Info("SetARowBool", LVvar,0,0,true)
if (A_LoopField = "-AR")
lva_Info("SetARowBool", LVvar,0,0,false)
if (A_LoopField = "+AC")||(A_LoopField = "AC")
lva_Info("SetAColBool", LVvar,0,0,true)
if (A_LoopField = "-AC")
lva_Info("SetAColBool", LVvar,0,0,false)
cmd := SubStr(A_LoopField,1,2)
if (cmd = "RB")
lva_Info("SetARowColB", LVvar,0,0, lva_VerifyColor(SubStr(A_LoopField, 3)))
if (cmd = "RF")
lva_Info("SetARowColF", LVvar,0,0, lva_VerifyColor(SubStr(A_LoopField, 3)))
if (cmd = "CB")
lva_Info("SetAColColB", LVvar,0,0, lva_VerifyColor(SubStr(A_LoopField, 3)))
if (cmd = "CF")
lva_Info("SetAColColF", LVvar,0,0, lva_VerifyColor(SubStr(A_LoopField, 3)))
}
}
LVA_Refresh(LVvar)
{
tmp := LVA_hWndInfo(LVvar,0,2)
WinSet, Redraw,, ahk_id %tmp%
}
LVA_SetProgressBar(LVvar, Row, Col, cInfo="")
{
if (cInfo = "")
{
lva_Info("SetPB", LVvar, Row, Col, false)
lva_Refresh(LVvar)
return
}
lva_Info("SetPB", LVvar, Row, Col, true)
lva_Info("SetProgress", LVvar, Row, Col, 0)
lva_Info("SetPBR", LVvar, Row, Col, 100)
lva_Info("SetPCB", LVvar, Row, Col, "0x00FFFFFF")
lva_Info("SetPCS", LVvar, Row, Col, "0x000080")
Loop, Parse, cInfo, %A_Space%
{
cmd := SubStr(A_LoopField,1,1)
if (A_LoopField = "Smooth")
lva_Info("SetPB", LVvar, Row, Col, 2)
else if (cmd = "R")
lva_Info("SetPBR", LVvar, Row, Col, SubStr(A_LoopField, 2))
else if (cmd = "B")
lva_Info("SetPCB", LVvar, Row, Col, lva_VerifyColor(SubStr(A_LoopField, 2),1))
else if (cmd = "S")
lva_Info("SetPCS", LVvar, Row, Col, lva_VerifyColor(SubStr(A_LoopField, 2), 2))
else if (cmd = "E")
lva_Info("SetPCE", LVvar, Row, Col, lva_VerifyColor(SubStr(A_LoopField, 2), 2))
}
if (lva_Info("GetPCE", LVvar, Row, Col) = "")
lva_Info("SetPCE", LVvar, Row, Col, lva_Info("GetPCS", LVvar, Row, Col))
}
LVA_Progress(Name, Row, Col, pProgress)
{
lva_Info("SetProgress", lva_hWndInfo(Name), Row, Col, pProgress)
lva_DrawProgress(Row, Col, lva_hWndInfo(Name,0,2))
}
LVA_SetCell(Name, Row, Col, cBGCol="", cFGCol="")
{
if ((cBGCol = "")&&(cFGCol = ""))
{
lva_Info("SetCol", Name, Row, Col, false)
return
}
if (cBGCol <> "")
lva_Info("SetCellColorBG", Name, Row, Col, lva_VerifyColor(cBGCol))
if (cFGCol <> "")
lva_Info("SetCellColorFG", Name, Row, Col, lva_VerifyColor(cFGCol))
if (cFont <> "")
lva_Info("SetCellFont", Name, Row, Col, cFont)
lva_Info("SetCol", Name, Row, Col, true)
}
LVA_EraseAllCells(Name)
{
lva_Info(0, Name)
}
LVA_GetCellNum(Switch=0, LVvar="")
{
Static LastResR, LastResC, LastColCount, LastRowCount, LastLVvar
if ((Switch = 1)||(Switch = "Row"))
return LastResR
else if ((Switch = 2)||(Switch = "Col"))
return LastResC
else if ((Switch = -1)||(Switch = "Row-1"))
return LastResR-1
else if ((Switch = -2)||(Switch = "Col-1"))
return LastResC-1
else if (Switch = "Rows")
return LastRowCount
else if (Switch = "Cols")
return LastColCount
if (LVvar = "")
LVvar := LastLVvar
else
LastLVvar := LVvar
if LVvar is not Integer
GuiControlGet, hLV, Hwnd, %LVvar%
else
hLV := LVvar
SendMessage, 4100,0,0,, ahk_id %hLV%
RowCount := ErrorLevel
if (Switch = "GetRows")
return RowCount
SendMessage, 4127,0,0,, ahk_id %hLV%
hHeader := ErrorLevel
SendMessage, 4608,0,0,, ahk_id %hHeader%
ColCount := ErrorLevel
if (Switch = "GetCols")
return ColCount
LastRowCount := RowCount
LastColCount := ColCount
VarSetCapacity(spt, 8, 0)
VarSetCapacity(pt, 8, 0)
DllCall("GetCursorPos", "UInt", &spt)
NumPut(NumGet(spt, 0), pt, 0)
NumPut(NumGet(spt, 4), pt, 4)
DllCall("ScreenToClient", "UInt", hLV, "UInt", &pt)
VarSetCapacity(LVHitTest, 24, 0)
NumPut(NumGet(pt, 0), LVHitTest, 0)
NumPut(NumGet(pt, 4), LVHitTest, 4)
SendMessage, 4153, 0, &LVHitTest,, ahk_id %hLV%
LastResR := NumGet(LVHitTest, 12)+1
if (LastResR > RowCount)
LastResR := 0
LastResC := NumGet(LVHitTest, 16)+1
if ((LastResC > ColCount)||(LastResR = 0))
LastResC := 0
return
}
LVA_SetSubItemImage(LVvar, Row, Col, iNum)
{
GuiControlGet, hLV, Hwnd, %LVvar%
VarSetCapacity(LVItem, 60, 0)
if (Row < 1)
Row := 1
NumPut(2, LVItem, 0)
NumPut(Row-1, LVItem, 4)
NumPut(Col, LVItem, 8)
NumPut(iNum-1, LVItem, 28)
SendMessage, 4102, 0, &LVItem,, ahk_id %hLV%
}
; ------------------------------------------------------------------------------------------------------------
; Private Functions! Please use only if u know what your doing
; ------------------------------------------------------------------------------------------------------------
lva_VerifyColor(cColor, Switch=0)
{
if cColor is not Integer
{
if (cColor = "Black")
cColor := (Switch = 1) ? "FFFFFF" : "010101"
else if (cColor = "White")
cColor := (Switch = 1) ? "010101" : "FFFFFF"
else if (cColor = "Silver")
cColor := "C0C0C0"
else if (cColor = "Gray")
cColor := "808080"
else if (cColor = "Maroon")
cColor := "800000"
else if (cColor = "Red")
cColor := "FF0000"
else if (cColor = "Purple")
cColor := "800080"
else if (cColor = "Fuchsia")
cColor := "FF00FF"
else if (cColor = "Green")
cColor := "008000"
else if (cColor = "Lime")
cColor := "00FF00"
else if (cColor = "Olive")
cColor := "808000"
else if (cColor = "Yellow")
cColor := "FFFF00"
else if (cColor = "Navy")
cColor := "000080"
else if (cColor = "Blue")
cColor := "0000FF"
else if (cColor = "Teal")
cColor := "008080"
else if (cColor = "Aqua")
cColor := "00FFFF"
}
if (SubStr(cColor,1,2) = "0x")
cColor := SubStr(cColor, 3)
if ((Switch = 1)&&(SubStr(cColor,1,2) = "00"))
cColor := SubStr(cColor, 3)
if (StrLen(cColor) <> 6)
return "0xFFFFFF"
if (Switch = 1)
return "0x00" . SubStr(cColor,5,2) . SubStr(cColor,3,2) . SubStr(cColor,1,2)
if (Switch = 0)
return "0x" . SubStr(cColor,5,2) . SubStr(cColor,3,2) . SubStr(cColor,1,2)
else
return "0x" . cColor
}
lva_DrawProgressGetStatus(Switch, Row=0, Col=0, Name="")
{
Static BGCol, SColR, SColG, SColB, EColR, EColG, EColB, pProgressMax, pProgress, pProgressType
if !Switch
{
BGCol := lva_Info("GetPCB", Name, Row, Col)
SCol := lva_Info("GetPCS", Name, Row, Col)
ECol := lva_Info("GetPCE", Name, Row, Col)
pProgressMax := lva_Info("GetPBR", Name, Row, Col)
pProgress := lva_Info("GetProgress", Name, Row, Col)
SColR := "0x" . SubStr(SCol, 3, 2) . "00"
SColG := "0x" . SubStr(SCol, 5, 2) . "00"
SColB := "0x" . SubStr(SCol, 7, 2) . "00"
EColR := "0x" . SubStr(ECol, 3, 2) . "00"
EColG := "0x" . SubStr(ECol, 5, 2) . "00"
EColB := "0x" . SubStr(ECol, 7, 2) . "00"
pProgressType := lva_Info("GetPB", Name, Row, Col)
}
if (Switch = 1)
return BGCol
else if (Switch = 2)
return SColR
else if (Switch = 3)
return SColG
else if (Switch = 4)
return SColB
else if (Switch = 5)
return EColR
else if (Switch = 6)
return EColG
else if (Switch = 7)
return EColB
else if (Switch = 8)
{
max := col-row
if (pProgress > pProgressMax)
return max
res := Ceil((max / 100) * (Round(pProgress / (pProgressMax / 100))))
if res > max
return max
else
return res
}
else if (Switch = 9)
return pProgressType
}
lva_GetStatusColor(Switch, Row=0, Col=0, LVvar=0)
{
Static cFGCol, cBGCol
if (Switch = -1)
{
return cFGCol
}
else if (Switch = -2)
{
return cBGCol
}
else if (switch = 0)
{
if lva_Info("GetCol", LVvar, 0, Col)
{
cBGCol := lva_Info("GetCellColorBG", LVvar, 0, Col)
if !cBGCol
cBGCol := lva_Info("GetStdColorBG", LVvar)
cFGCol := lva_Info("GetCellColorFG", LVvar, 0, Col)
if !cFGCol
cFGCol := lva_Info("GetStdColorFG", LVvar)
}
else if lva_Info("GetCol", LVvar, Row)
{
cBGCol := lva_Info("GetCellColorBG", LVvar, Row)
if !cBGCol
cBGCol := lva_Info("GetStdColorBG", LVvar)
cFGCol := lva_Info("GetCellColorFG", LVvar, Row)
if !cFGCol
cFGCol := lva_Info("GetStdColorFG", LVvar)
}
else if (lva_Info("GetAColBool", LVvar))&&(mod(Col, 2) = 0)
{
cBGCol := lva_Info("GetAColColB", LVvar)
cFGCol := lva_Info("GetAColColF", LVvar)
}
else if (lva_Info("GetARowBool", LVvar))&&(mod(Row, 2) = 0)
{
cBGCol := lva_Info("GetARowColB", LVvar)
cFGCol := lva_Info("GetARowColF", LVvar)
}
else
{
cBGCol := lva_Info("GetStdColorBG", LVvar)
cFGCol := lva_Info("GetStdColorFG", LVvar)
}
}
else if (switch = 1)
{
cBGCol := lva_Info("GetCellColorBG", LVvar, Row, Col)
if !cBGCol
if (lva_Info("GetAColBool", LVvar))&&(mod(Col, 2) = 0)
cBGCol := lva_Info("GetAColColB", LVvar)
else if (lva_Info("GetARowBool", LVvar))&&(mod(Row, 2) = 0)
cBGCol := lva_Info("GetARowColB", LVvar)
else
cBGCol := lva_Info("GetStdColorBG", LVvar)
cFGCol := lva_Info("GetCellColorFG", LVvar, Row, Col)
if !cFGCol
if (lva_Info("GetAColBool", LVvar))&&(mod(Col, 2) = 0)
cFGCol := lva_Info("GetAColColF", LVvar)
else if (lva_Info("GetARowBool", LVvar))&&(mod(Row, 2) = 0)
cFGCol := lva_Info("GetARowColF", LVvar)
else
cFGCol := lva_Info("GetStdColorFG", LVvar)
}
}
lva_hWndInfo(hwnd, switch=0, data=1)
{
Static
Local tmp, found
if ((switch = 0)||(switch = 2))
{
if hwnd is Integer
hwnd := hwnd+0
found := false
Loop, %LVCount%
{
tmp := A_Index
Loop, 3
{
if (LVA_hWndInfo_%tmp%_%A_Index% = hwnd)
{
found := true
break
}
}
if found
break
}
if !found
return ""
else
{
if (switch = 0)
return LVA_hWndInfo_%tmp%_%data%
else if (switch = 2)
return true
}
}
else if (switch = -1)
return LVA_hWndInfo_%data%_1
else if (switch = -2)
return LVA_hWndInfo_%data%_2
else if (switch = -3)
return LVA_hWndInfo_%data%_3
else if (switch = 1)
{
if !LVCount
LVCount := 1
else
LVCount++
LVA_hWndInfo_%LVCount%_1 := hwnd
GuiControlGet, tmp, Hwnd, %hwnd%
LVA_hWndInfo_%LVCount%_2 := tmp+0
SendMessage, 4127,0,0,, ahk_id %tmp%
LVA_hWndInfo_%LVCount%_3 := ErrorLevel+0
return LVCount
}
}
lva_OnNotifyProg(wParam, lParam, msg, hwnd)
{
Critical, 500
hHandle := NumGet(lParam + 0)
NotifyMsg := NumGet(lParam + 8, 0, "Int")
if ((NotifyMsg == -307)||(NotifyMsg == -327))
LVA_Refresh(hHandle)
else if (NotifyMsg == -12)
{
Row := NumGet(lParam + 36) +1
Col := NumGet(lParam + 56) +1
st := NumGet(lParam + 12)
if st = 1
Return, 0x20
else if (st == 0x10001)
Return, 0x20
else if (st == 0x30001)
{
LVvar := LVA_hWndInfo(hHandle)
CellType := lva_Info("GetCellType", LVvar, Row, Col)
if (CellType = 0)
{
lva_GetStatusColor(0, Row, Col, LVvar)
NumPut(lva_GetStatusColor(-1), lParam + 48)
NumPut(lva_GetStatusColor(-2), lParam + 52)
}
else if (CellType = 1)
{
lva_GetStatusColor(1, Row, Col, LVvar)
NumPut(lva_GetStatusColor(-1), lParam + 48)
NumPut(lva_GetStatusColor(-2), lParam + 52)
}
else if (CellType = 2)
{
lva_DrawProgress(Row, Col, hHandle)
return 0x4
}
else if (CellType = 3)
{
; lva_DrawMultiImage(Row, Col, hHandle)
return 0x4
}
}
}
}
lva_OnLVScroll(hwnd, uMsg, wParam, lParam)
{
Critical, 500
if (uMsg = 0x115)
{
DLow := wParam & 0xFFFF
if !DLow
DllCall("LockWindowUpdate", "UInt", hwnd)
else
DllCall("LockWindowUpdate", "UInt", 0)
}
return DllCall("CallWindowProcA", "UInt", A_EventInfo, "UInt", hwnd, "UInt", uMsg, "UInt", wParam, "UInt", lParam)
}
lva_DrawProgress(Row, Col, hHandle)
{
if !lva_Info("GetPB", lva_hwndInfo(hHandle,0,1), Row, Col)
return
VarSetCapacity(pRect, 16, 0)
NumPut(0, pRect, 0)
NumPut(Col-1, pRect, 4)
SendMessage, 4152, Row-1, &pRect,, ahk_id %hHandle%
pLeft := NumGet(pRect, 0) > 0x7FFFFFFF ? -(~NumGet(pRect, 0)) - 1 : NumGet(pRect, 0)
pTop := NumGet(pRect, 4) > 0x7FFFFFFF ? -(~NumGet(pRect, 4)) - 1 : NumGet(pRect, 4)
pRight := NumGet(pRect, 8) > 0x7FFFFFFF ? -(~NumGet(pRect, 8)) - 1 : NumGet(pRect, 8)
pBottom := NumGet(pRect, 12) > 0x7FFFFFFF ? -(~NumGet(pRect, 12)) - 1 : NumGet(pRect, 12)
if ((pRight < 0)||(pBottom < 0))
return
VarSetCapacity(pRect2, 16, 0)
SendMessage, 4135,0,0,, ahk_id %hHandle%
SendMessage, 4152, ErrorLevel, &pRect2,, ahk_id %hHandle%
if (pTop < NumGet(pRect2, 4))
return
lva_DrawProgressGetStatus(0, Row, Col, lva_hWndInfo(hHandle))
hDC := DllCall("GetDC", "UInt", hHandle)
if (pLeft < 0)
pWidth := NumGet(pRect, 8) + -pLeft-3
else
pWidth := NumGet(pRect, 8) - NumGet(pRect, 0)-3
pHeight := NumGet(pRect, 12) - NumGet(pRect, 4)-3
mDC := DllCall("CreateCompatibleDC", "UInt", hDC)
mBitmap := DllCall("CreateCompatibleBitmap", "UInt", hDC, "Int", pWidth, "Int", pHeight)
DllCall("SelectObject", "UInt", mDC, "UInt", mBitmap)
VarSetCapacity(pVertex, 32, 0)
NumPut(1, pVertex, 0, "Int")
NumPut(1, pVertex, 4, "Int")
NumPut(lva_DrawProgressGetStatus(2), pVertex, 8, "Ushort")
NumPut(lva_DrawProgressGetStatus(3), pVertex, 10, "Ushort")
NumPut(lva_DrawProgressGetStatus(4), pVertex, 12, "Ushort")
NumPut(0x0000, pVertex, 14, "Ushort")
ProgLen := lva_DrawProgressGetStatus(8, 1, pWidth-1)
if (lva_DrawProgressGetStatus(9) = 1)
NumPut(1+ProgLen, pVertex, 16, "Int")
else
NumPut(pWidth-1, pVertex, 16, "Int")
NumPut(pHeight-1, pVertex, 20, "Int")
NumPut(lva_DrawProgressGetStatus(5), pVertex, 24, "Ushort")
NumPut(lva_DrawProgressGetStatus(6), pVertex, 26, "Ushort")
NumPut(lva_DrawProgressGetStatus(7), pVertex, 28, "Ushort")
NumPut(0x0000, pVertex, 30, "Ushort")
VarSetCapacity(gRect, 8, 0)
NumPut(0, gRect, 0, "UInt")
NumPut(1, gRect, 4, "UInt")
DllCall("msimg32\GradientFill", "UInt", mDC, "UInt", &pVertex, "Int", 2, "UInt", &gRect, "Int", 1, "UInt", 0x0)
NumPut(ProgLen+1, pRect2, 0)
NumPut(1, pRect2, 4)
NumPut(pWidth-1, pRect2, 8)
NumPut(pHeight-1, pRect2, 12)
hBrush := DllCall("Gdi32\CreateSolidBrush", "UInt", lva_DrawProgressGetStatus(1))
DllCall("FillRect", "UInt", mDC, "UInt", &pRect2, "UInt", hBrush)
DllCall("Gdi32\DeleteObject", "UInt", hBrush)
if (pLeft < 0)
DllCall("Gdi32\BitBlt", "UInt", hDC, "UInt", NumGet(pRect, 0)-pLeft-1, "UInt", NumGet(pRect, 4)+1, "UInt", NumGet(pRect, 8), "UInt", NumGet(pRect, 12)-1, "UInt", mDC, "UInt", -pLeft-3, "UInt", 0, "UInt", 0xCC0020)
else
DllCall("Gdi32\BitBlt", "UInt", hDC, "UInt", NumGet(pRect, 0)+2, "UInt", NumGet(pRect, 4)+1, "UInt", NumGet(pRect, 8), "UInt", NumGet(pRect, 12)-1, "UInt", mDC, "UInt", 0, "UInt", 0, "UInt", 0xCC0020)
DllCall("DeleteDC", "UInt", mDC)
DllCall("ReleaseDC", "UInt", hHandle, "UInt", hDC)
}
lva_Info(Switch, Name, Row=0, Col=0, Data=0)
{
Static
if (Switch = 0)
{
Loop, % LVA_GetCellNum("GetRows", Name)
{
lRow := A_Index
if LVA_InfoArray_%Name%_%lRow%_0_HasCellColor
LVA_InfoArray_%Name%_%lRow%_0_HasCellColor := ""
Loop, % LVA_GetCellNum("GetCols", Name)
{
if LVA_InfoArray_%Name%_%lRow%_%A_Index%_HasProgressBar
LVA_InfoArray_%Name%_%lRow%_%A_Index%_HasProgressBar := ""
if LVA_InfoArray_%Name%_%lRow%_%A_Index%_HasMultiImage
LVA_InfoArray_%Name%_%lRow%_%A_Index%_HasMultiImage := ""
if LVA_InfoArray_%Name%_%lRow%_%A_Index%_HasCellColor
LVA_InfoArray_%Name%_%lRow%_%A_Index%_HasCellColor := ""
if LVA_InfoArray_%Name%_0_%A_Index%_HasCellColor
LVA_InfoArray_%Name%_0_%A_Index%_HasCellColor := ""
}
}
return
}
else if (Switch = "GetStdColorBG")
return LVA_InfoArray_%Name%_BGColor
else if (Switch = "GetStdColorFG")
return LVA_InfoArray_%Name%_FGColor
else if (Switch = "GetCellColorBG")
return LVA_InfoArray_%Name%_%Row%_%Col%_BGColor
else if (Switch = "GetCellColorFG")
return LVA_InfoArray_%Name%_%Row%_%Col%_FGColor
else if (Switch = "GetCellType")
{
if LVA_InfoArray_%Name%_%Row%_%Col%_HasCellColor
return 1
else if LVA_InfoArray_%Name%_%Row%_%Col%_HasProgressBar
return 2
else if LVA_InfoArray_%Name%_%Row%_%Col%_HasMultiImage
return 3
else
return 0
}
else if (Switch = "GetPB")
return LVA_InfoArray_%Name%_%Row%_%Col%_HasProgressBar
else if (Switch = "GetProgress")
return LVA_InfoArray_%Name%_%Row%_%Col%_ProgressBarProgress
else if (Switch = "GetPBR")
return LVA_InfoArray_%Name%_%Row%_%Col%_ProgressBarRange
else if (Switch = "GetPCB")
return LVA_InfoArray_%Name%_%Row%_%Col%_ProgressBarBckCol
else if (Switch = "GetPCS")
return LVA_InfoArray_%Name%_%Row%_%Col%_ProgressBarSCol
else if (Switch = "GetPCE")
return LVA_InfoArray_%Name%_%Row%_%Col%_ProgressBarECol
else if (Switch = "GetMI")
return LVA_InfoArray_%Name%_%Row%_%Col%_HasMultiImage
else if (Switch = "GetCol")
return LVA_InfoArray_%Name%_%Row%_%Col%_HasCellColor
else if (Switch = "GetARowBool")
return LVA_InfoArray_%Name%_ARowColor_Alternate
else if (Switch = "GetARowColB")
return LVA_InfoArray_%Name%_ARowColor_BColor
else if (Switch = "GetARowColF")
return LVA_InfoArray_%Name%_ARowColor_FColor
else if (Switch = "GetAColBool")
return LVA_InfoArray_%Name%_AColColor_Alternate
else if (Switch = "GetAColColB")
return LVA_InfoArray_%Name%_AColColor_BColor
else if (Switch = "GetAColColF")
return LVA_InfoArray_%Name%_AColColor_FColor
else if (Switch = "SetStdColorBG")
LVA_InfoArray_%Name%_BGColor := Data
else if (Switch = "SetStdColorFG")
LVA_InfoArray_%Name%_FGColor := Data
else if (Switch = "SetCellColorBG")
LVA_InfoArray_%Name%_%Row%_%Col%_BGColor := Data
else if (Switch = "SetCellColorFG")
LVA_InfoArray_%Name%_%Row%_%Col%_FGColor := Data
else if (Switch = "SetPB")
LVA_InfoArray_%Name%_%Row%_%Col%_HasProgressBar := Data
else if (Switch = "SetProgress")
LVA_InfoArray_%Name%_%Row%_%Col%_ProgressBarProgress := Data
else if (Switch = "SetPBR")
LVA_InfoArray_%Name%_%Row%_%Col%_ProgressBarRange := Data
else if (Switch = "SetPCB")
LVA_InfoArray_%Name%_%Row%_%Col%_ProgressBarBckCol := Data
else if (Switch = "SetPCS")
LVA_InfoArray_%Name%_%Row%_%Col%_ProgressBarSCol := Data
else if (Switch = "SetPCE")
LVA_InfoArray_%Name%_%Row%_%Col%_ProgressBarECol := Data
else if (Switch = "SetMI")
LVA_InfoArray_%Name%_%Row%_%Col%_HasMultiImage := Data
else if (Switch = "SetCol")
LVA_InfoArray_%Name%_%Row%_%Col%_HasCellColor := Data
else if (Switch = "SetARowBool")
LVA_InfoArray_%Name%_ARowColor_Alternate := Data
else if (Switch = "SetARowColB")
LVA_InfoArray_%Name%_ARowColor_BColor := Data
else if (Switch = "SetARowColF")
LVA_InfoArray_%Name%_ARowColor_FColor := Data
else if (Switch = "SetAColBool")
LVA_InfoArray_%Name%_AColColor_Alternate := Data
else if (Switch = "SetAColColB")
LVA_InfoArray_%Name%_AColColor_BColor := Data
else if (Switch = "SetAColColF")
LVA_InfoArray_%Name%_AColColor_FColor := Data
}
lva_Subclass(hCtrl, Fun, Opt="", ByRef $WndProc="") {
if Fun is not integer
{
oldProc := DllCall("GetWindowLong", "uint", hCtrl, "uint", -4)
ifEqual, oldProc, 0, return 0
$WndProc := RegisterCallback(Fun, Opt, 4, oldProc)
ifEqual, $WndProc, , return 0
}
else $WndProc := Fun
return DllCall("SetWindowLong", "UInt", hCtrl, "Int", -4, "Int", $WndProc, "UInt")
}