-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathLV_G.ahk
711 lines (649 loc) · 23.2 KB
/
LV_G.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
/*
;===================================================================================
Listview Supplementary Library v1.0
;===================================================================================
Functions:
- LVG_Search()
- LVG_Get()
- LVG_Count_Un()
- LVG_GetNext_Un()
- LVG_Check()
- LVG_Select()
- LVG_Delete()
;===================================================================================
LVG_Search()
Returns the...
- Total number of the rows, that contain "Search string" and that are...
- Row numbers of all rows (comma separated list), that contain "Search string" and that are...
- Row number of the next row, that contains "Search string" and that's...
* Selected
* Deselected
* Checked
* Unchecked
* Selected AND checked
* Deselected AND unchecked
* Selected AND unchecked
* Deselected AND checked
...from the user specified row/column range.
Quick example:
Say you've got a Gui with the number 23 assigned to it (Gui, 23:...), and it has a Listview
with 150 rows. You want to get the row numbers of the selected rows from the first twenty,
that contain the word "Scripting" in their second column. Here's how to do it:
LVG_Search(23,"Selected","List","1-20","2","Scripting")
;-----------------------------------------------------------------------------------
LVG_Get()
Returns the...
- Total number of rows, that are...
- Row numbers of all rows (comma separated list), that are...
- Row number of the next row, that's...
* Selected
* Deselected
* Checked
* Unchecked
* Selected AND checked
* Deselected AND unchecked
* Selected AND unchecked
* Deselected AND checked
...from the user specified row range
Quick example:
LVG_Get(1,"Unchecked","Count","1-12;23-55;89;82")
...will return a comma separated list, that contains the total number of those unchecked rows,
whose row numbers are: 1-12 or 23-55 or 89 or 82.
;-----------------------------------------------------------------------------------
LVG_Count_Un()
Returns the row number of the next:
* Unchecked
* Deselected
...row.
Quick example:
LVG_GetNext_Un(1,"Deselected")
...will return the total number of all the deselected rows from the default Listview of GUI1.
;-----------------------------------------------------------------------------------
LVG_GetNext_Un()
Returns the row number of the next:
* Unchecked
* Deselected
...row.
Quick example:
LVG_GetNext_Un(65,"Unchecked")
...will return the next unchecked row from the default Listview of GUI65.
;-----------------------------------------------------------------------------------
LVG_Check()
Checks/Unchecks all the rows that are...
* Checked
* Unchecked
* Selected
* Deselected
* Reverts checks
Quick example:
LVG_Select(1,"CheckAll")
...will check all the unchecked rows.
;-----------------------------------------------------------------------------------
LVG_Select()
Selects/Deselects all the rows that are...
* Selected
* Deselected
* Checked
* Unchecked
* Reverts selection
Quick example:
LVG_Select(1,"Reverse")
...will select all the deselected rows, and deselect all the selected ones.
;-----------------------------------------------------------------------------------
LVG_Delete()
Deletes all the rows that are...
* Selected
* Deselected
* Checked
* Unchecked
* Selected AND checked
* Deselected AND unchecked
* Selected AND unchecked
* Deselected AND checked
Quick example:
LVG_Delete(1,"Unchecked")
...will delete all unchecked rows.
;=========================================
Remarks:
- For further info on the functions' parameters see the descriptions by each function below.
- It's not heavily commented (or should I say not commented at all)... So, if you have questions, don't hesitate to ask 'em in the forum topic.
- The uncheck/check-related features work only if the Listview has "Checked" specified among its options
;=========================================
About:
- Version: 1.0 by GAHKS http://www.autohotkey.net/~gahks
- License: Attribution-Share Alike 3.0 Unported: http://creativecommons.org/licenses/by-sa/3.0/
- Forum topic: http://www.autohotkey.com/forum/topic49091.html
;===================================================================================
*/
/*
;===================================================================================
Function:
LVG_Search(GuiNumber,"Mode","Mode2","RowstoSearchIn","ColstoSearchIn","SearchString")
Description:
Searches for the string specified in "SearchString" in the specified range, if any fields of the specified row contains the string, it returns the row's number according to "Mode2".
Parameters:
GuiNumber: - the number of the gui, that has the target listview as its default listview control
Mode:
Selected - will search only in selected rows
Deselected - will search only in deselected rows
Checked - etc., etc.
Unchecked
SelectedChecked
DeselectedUnchecked
SelectedUnchecked
DeselectedChecked
Mode2:
Count - returns the total number of rows
Next - returns the row number of the next row
List - returns the row numbers of all the rows
RowToSearchIn:
All - will search in all the rows that meet the conditions of Mode
Semicolon-separated list of numbers or ranges in quotation marks. Eg.: "1;2;12-35;67-87;54"
- will search only in these rows
StartingRowNumber - only if Mode2 is Next
ColstoSearchIn:
All - will search in all the columns
Semicolon-separated list of numbers or ranges in quotation marks. Eg.: "1-3;5;7"
- will search only in the fields that are in this column, and in "RowToSearchIn" row
SearchString
String - will search for this string in the above specified fields
Examples:
You'd like to obtain the row numbers for any checked AND selected rows that contain the letter "a" in their first and second column starting from row thirty-four, to row fifty, including row seventy and seventy-one, from the default listview of GUI nr. 14.
LVG_Search(14,"SelectedChecked","List","34-50;70;71","1-2","a")
...will return a comma-separated list, containing all the rows that met the above conditions.
Say you'd like to do the same, with the only exceptions, that you'd like to know only the total number of rows that meet these conditions:
LVG_Search(14,"SelectedChecked","Total","34-50;70;71","1-2","a")
*/
;===================================================================================
LVG_Search(Gui_nr=1,mode="Selected",mode2="Count",rows="all",cols="all",srch_str="") {
modelist=Selected,Deselected,Checked,Unchecked,SelectedChecked
,DeselectedUnchecked,SelectedUnchecked,DeselectedChecked
StringSplit, modelist, modelist, `,
Loop, %modelist0%
if (mode=modelist%a_index%)
mode = %a_index%
mode2list=Count,Next,List
StringSplit, mode2list, mode2list, `,
Loop, %mode2list0%
if (mode2=mode2list%a_index%)
mode2 = %a_index%
modelist:="",mode2list:="",c:=0,count:="",s_mode:="Checked",s_mode2:=""
if (mode=1 || mode=2 || mode=5 || mode=6 || mode=7 || mode=8)
s_mode:="", s_mode2:="Checked"
Gui, %Gui_nr%:Default
if (rows <> "all")
{
StringSplit, row_a, rows, `; ;Splitting row parameter into subparameters
Loop, %row_a0%
{
c_row_a := a_index
StringSplit, row_b, row_a%a_index%, -
if row_b0 = 2
{
start := row_b1
Loop, % row_b2-row_b1+1 ;+1 so that it includes the last number too (eg. by rows=4-12 it includes 12 too)
{
row_c%start% := 1
start++
}
}
else if row_b0 = 1
row_c%row_b1% := 1
}
}
if (cols <> "all")
{
StringSplit, col_a, cols, `; ;Splitting row parameter into subparameters
Loop, %col_a0%
{
c_col_a := a_index
StringSplit, col_b, col_a%a_index%, -
if col_b0 = 2
{
start := col_b1
Loop, % col_b2-col_b1+1 ;+1 so that it includes the last number too (eg. by rows=4-12 it includes 12 too)
{
col_c%start% := 1
start++
}
}
else if col_b0 = 1
col_c%col_b1% := 1
}
}
pr=0
if mode2=2
if (rows = "all" || row_a0 <> 1 || row_b0 <> 1)
return "ERROR"
else
pr:=rows
Loop, % LV_GetCount()
{
c_i := a_index
if (!row_c%c_i% && rows <> "all" && mode2 <> 2)
{
pr := c_i
Continue
}
if (mode2=2)
c_i:=rows+a_index-1
if (((LV_GetNext(pr, s_mode) = c_i) && (mode=2 || mode=4))
|| ((LV_GetNext(pr, s_mode) <> c_i) && (mode=1 || mode=3))
|| (((LV_GetNext(pr, s_mode) = c_i) || (LV_GetNext(pr, s_mode2) = c_i)) && mode=6)
|| (((LV_GetNext(pr, s_mode) <> c_i) || (LV_GetNext(pr, s_mode2) <> c_i)) && mode=5)
|| (((LV_GetNext(pr, s_mode) = c_i) || (LV_GetNext(pr, s_mode2) <> c_i)) && mode=8)
|| (((LV_GetNext(pr, s_mode) <> c_i) || (LV_GetNext(pr, s_mode2) = c_i)) && mode=7))
{
pr := c_i
Continue
}
else if (((LV_GetNext(pr, s_mode) = c_i) && (mode=1 || mode=3))
|| ((LV_GetNext(pr, s_mode) <> c_i) && (mode=2 || mode=4))
|| ((LV_GetNext(pr, s_mode) <> c_i) && (LV_GetNext(pr, s_mode2) <> c_i) && mode=6)
|| ((LV_GetNext(pr, s_mode) = c_i) && (LV_GetNext(pr, s_mode2) = c_i) && mode=5)
|| ((LV_GetNext(pr, s_mode) <> c_i) && (LV_GetNext(pr, s_mode2) = c_i) && mode=8)
|| ((LV_GetNext(pr, s_mode) = c_i) && (LV_GetNext(pr, s_mode2) <> c_i) && mode=7))
{
Loop, % LV_GetCount("Column")
{
if (!col_c%a_index% && cols <> "all")
continue
col_i := col_c%a_index%
if (cols = "all")
col_i := a_index
LV_GetText(c_t, c_i, col_i)
IfInString, c_t, %srch_str%
{
if (mode2=2)
return c_i
else if (mode2=1)
count++
else if (mode2=3)
count .= c_i . ","
break
}
}
pr := c_i
}
}
if mode2=3
StringTrimRight, count, count, 1
return count
}
/*
;===================================================================================
Function:
LVG_Get(GuiNumber,"Mode","Mode2","RowstoSearchIn")
Description:
Returns the row numbers of the rows/total number of rows/row number of the next row according to "Mode2", that meet(s) the conditions of "Mode"
Parameters:
GuiNumber: - the number of the gui, that has the target listview as its default listview control
Mode:
Selected - will return selected rows only
Deselected - will return deselected rows only
Checked - etc., etc.
Unchecked
SelectedChecked
DeselectedUnchecked
SelectedUnchecked
DeselectedChecked
Mode2:
Count - returns the total number of rows
Next - returns the row number of the next row that meets the conditions specified in "Mode"
List - returns the row numbers of all the rows
RowsToSearchIn:
All - will return all the rows that meet the conditions of "Mode"
Semicolon-separated list of numbers or ranges in quotation marks. Eg.: "1;2;12-35;67-87;54"
- will return rows from this row range if they meet Mode conditions
StartingRowNumber - only if Mode2 is Next
Examples:
You'd like to obtain the row numbers for any "Unchecked" rows starting from second row to the nineth row, but including row twelve and thirteen, from the default listview of GUI nr. 1.
LVG_Get(1,"Unchecked","List","2-9;12-13")
...this will return a comma-separated list, containing all the rows that met the above conditions.
Say you'd like to do the same, only you'd like to know the total number of rows that meet these conditions:
LVG_Get(1,"Unchecked","Count","2-9;12-13")
And now you'd like to know only the first row from the List that meets these conditions:
LVG_Get(1,"Unchecked","Next",2)
*/
;===================================================================================
LVG_Get(Gui_nr=1,mode="Selected",mode2="Count",rows="all") {
modelist=Selected,Deselected,Checked,Unchecked,SelectedChecked
,DeselectedUnchecked,SelectedUnchecked,DeselectedChecked
StringSplit, modelist, modelist, `,
Loop, %modelist0%
if (mode=modelist%a_index%)
mode = %a_index%
mode2list=Count,Next,List
StringSplit, mode2list, mode2list, `,
Loop, %mode2list0%
if (mode2=mode2list%a_index%)
mode2 = %a_index%
modelist:="",mode2list:="",c:=0,count:="",s_mode:="Checked",s_mode2:=""
if (mode=1 || mode=2 || mode=5 || mode=6 || mode=7 || mode=8)
s_mode:="", s_mode2:="Checked"
Gui, %Gui_nr%:Default
if (rows <> "all")
{
StringSplit, row_a, rows, `; ;Splitting row parameter into subparameters
Loop, %row_a0%
{
c_row_a := a_index
StringSplit, row_b, row_a%a_index%, -
if row_b0 = 2
{
start := row_b1
Loop, % row_b2-row_b1+1 ;+1 so that it includes the last number too (eg. by rows=4-12 it includes 12 too)
{
row_c%start% := 1
start++
}
}
else if row_b0 = 1
row_c%row_b1% := 1
}
}
pr=0
if mode2=2
if (rows = "all" || row_a0 <> 1 || row_b0 <> 1)
return "ERROR"
else
pr:=rows
Loop, % LV_GetCount()
{
c_i := a_index
if (!row_c%c_i% && rows <> "all" && mode2 <> 2)
{
pr := c_i
Continue
}
if (mode2=2)
c_i:=rows+a_index-1
if (((LV_GetNext(pr, s_mode) = c_i) && (mode=2 || mode=4))
|| ((LV_GetNext(pr, s_mode) <> c_i) && (mode=1 || mode=3))
|| (((LV_GetNext(pr, s_mode) = c_i) || (LV_GetNext(pr, s_mode2) = c_i)) && mode=6)
|| (((LV_GetNext(pr, s_mode) <> c_i) || (LV_GetNext(pr, s_mode2) <> c_i)) && mode=5)
|| (((LV_GetNext(pr, s_mode) = c_i) || (LV_GetNext(pr, s_mode2) <> c_i)) && mode=8)
|| (((LV_GetNext(pr, s_mode) <> c_i) || (LV_GetNext(pr, s_mode2) = c_i)) && mode=7))
{
pr := c_i
Continue
}
else if (((LV_GetNext(pr, s_mode) = c_i) && (mode=1 || mode=3))
|| ((LV_GetNext(pr, s_mode) <> c_i) && (mode=2 || mode=4))
|| ((LV_GetNext(pr, s_mode) <> c_i) && (LV_GetNext(pr, s_mode2) <> c_i) && mode=6)
|| ((LV_GetNext(pr, s_mode) = c_i) && (LV_GetNext(pr, s_mode2) = c_i) && mode=5)
|| ((LV_GetNext(pr, s_mode) <> c_i) && (LV_GetNext(pr, s_mode2) = c_i) && mode=8)
|| ((LV_GetNext(pr, s_mode) = c_i) && (LV_GetNext(pr, s_mode2) <> c_i) && mode=7))
{
if (mode2=2)
return c_i
else if (mode2=1)
count++
else if (mode2=3)
count .= c_i . ","
pr := c_i
}
}
if mode2=3
StringTrimRight, count, count, 1
return count
}
/*
;===================================================================================
Function:
LVG_Count_Un(GuiNumber,Mode)
Description:
Returns the total number of Deselected/Unchecked rows
Parameters:
GuiNumber: - the number of the gui, that has the target listview as its default listview control
Mode:
Deselected - will return the total number of the Deselected rows
Unchecked - will return the total number of the Unchecked rows
Examples:
This will return the total number of the Unchecked rows:
LVG_Count_Un(1,"Unchecked")
Remarks
With LVG_Get() you can use much more sophisticated filters to pick the right row, and basically it renders this functions obsolete.
I left it in this library, because this is a basic function that I assume many people will want to use, who don't need the full functionality of LVG_Get.
*/
;===================================================================================
LVG_Count_Un(Gui_nr=1,mode="Unchecked") {
if mode=Unchecked
mode=1
else if mode=Deselected
mode=2
count:=0,s_mode:="Checked"
If mode=2
s_mode=
Gui, %Gui_nr%:Default
pr := 0
Loop, % LV_GetCount()
{
If (LV_GetNext(pr, s_mode) = a_index)
pr := a_index
Else
count++
}
return count
}
/*
;===================================================================================
Function:
LVG_GetNext_Un(GuiNumber,"Mode",StartingRowNumber)
Description:
Returns the row number of the next Deselected/Unchecked row (starting from StartingRowNumber).
Parameters:
GuiNumber: - the number of the gui, that has the target listview as its default listview control
Mode:
Deselected - will return the row number of the next Deselected row
Unchecked - will return the row number of the next Unchecked row
StartingRowNumber: - the row number from which to start
Examples:
This will return the row number of the next Deselected row after row nr. 23.
LVG_GetNext_Un(1,"Deselected", 23)
Remarks
With LVG_Get() you can use much more sophisticated filters to pick the right row, and basically it renders this functions obsolete
I left it in this library, because this is a basic function that I assume many people eill want to use, who don't need the full functionality of LVG_Get.
*/
;===================================================================================
LVG_GetNext_Un(Gui_nr=1,mode="Unchecked",pr=0) {
if mode=Unchecked
mode=1
else if mode=Deselected
mode=2
count:=0,s_mode:="Checked"
If mode=2
s_mode=
Gui, %Gui_nr%:Default
Loop, % LV_GetCount()
{
If (LV_GetNext(pr, s_mode) = a_index)
pr := a_index
Else
{
count := a_index
break
}
}
return count
}
/*
;===================================================================================
Function:
LVG_Check(GuiNumber,"Mode")
Description:
Gui action function:
Checks/unchecks all the rows that meet the conditions of "Mode".
Parameters:
GuiNumber: - the number of the gui, that has the target listview as its default listview control
Mode:
Reverse - will check all unchecked rows and uncheck all checked rows
CheckAll - will check all unchecked rows
UncheckAll - will uncheck all checked rows
CheckSelected - will check all selected rows
UncheckSelected - will uncheck all selected rows
CheckDeselected - will check all deselected rows
UncheckDeselected - will uncheck all deselected rows
Examples:
This will reverse-check the listview's checkboxes in GUI2:
LVG_Check(2,"Reverse")
This will check all the selected rows:
LVG_Check(2,"CheckSelected")
*/
;===================================================================================
LVG_Check(Gui_nr=1,mode="Reverse") {
modelist=Reverse,CheckAll,UncheckAll,CheckSelected
,UncheckSelected,CheckDeselected,UncheckDeselected
StringSplit, modelist, modelist, `,
Loop, %modelist0%
if (mode=modelist%a_index%)
mode = %a_index%
modelist:="",count:=0,count2:=0,pr:= 0,s_mode:=
Gui, %Gui_nr%:Default
If (mode=1||mode=2||mode=3)
s_mode=Checked
Loop, % LV_GetCount()
{
If (LV_GetNext(pr, s_mode) = a_index)
pr:=a_index,r%a_index%:=1,count2++
Else
r%a_index%:= 0,count++
}
Loop, % LV_GetCount()
{
If ((r%a_index% && (mode=1 || mode=3 || mode=5)) || (!r%a_index% && mode=7))
LV_Modify(a_index, "-Check")
Else if ((!r%a_index% && (mode=1 || mode=2 || mode=6)) || (r%a_index% && mode=4))
LV_Modify(a_index, "+Check")
}
return count . "," . count2
}
/*
;===================================================================================
Function:
LVG_Select(GuiNumber,"Mode")
Description:
Gui action function:
Same as LVG_Check() with the exception that this works with Selections.
Reverts selection/selects all/deselects all rows that meet the conditions of "Mode".
Parameters:
GuiNumber: - the number of the gui, that has the target listview as its default listview control
Mode:
Reverse - will select all deselected rows and deselect all selected rows (revert selection)
SelectAll - will select all deselected rows
DeselectAll - will deselect all selected rows
SelectChecked - will select all checked rows
DeselectChecked - will deselect all checked rows
SelectUnchecked - will select all unchecked rows
DeselectUnchecked - will deselect all unchecked rows
Examples:
This will revert selection:
LVG_Select(1,"Reverse")
This will select all the Unchecked rows:
LVG_Select(1,"SelectUnchecked")
*/
;===================================================================================
LVG_Select(Gui_nr=1,mode="Reverse") {
modelist=Reverse,SelectAll,DeselectAll,SelectChecked
,DeselectChecked,SelectUnchecked,DeselectUnchecked
StringSplit, modelist, modelist, `,
Loop, %modelist0%
if (mode=modelist%a_index%)
mode = %a_index%
modelist:="",count:=0,count2:=0,pr:= 0,s_mode:="Checked"
Gui, %Gui_nr%:Default
If (mode=1||mode=2||mode=3)
s_mode=
Loop, % LV_GetCount()
{
If (LV_GetNext(pr, s_mode) = a_index)
pr:=a_index,r%a_index%:=1,count2++
Else
r%a_index%:= 0,count++
}
Loop, % LV_GetCount()
{
If ((r%a_index% && (mode=1 || mode=3 || mode=5)) || (!r%a_index% && mode=7))
LV_Modify(a_index, "-Select")
Else if ((!r%a_index% && (mode=1 || mode=2 || mode=6)) || (r%a_index% && mode=4))
LV_Modify(a_index, "+Select")
}
return count . "," . count2
}
/*
;===================================================================================
Function:
LVG_Delete(GuiNumber,"Mode")
Description:
Gui action function:
Same as LVG_Check() with the exception that this works with Selections.
Reverts selection/selects all/deselects all rows that meet the conditions of "Mode".
Parameters:
GuiNumber: - the number of the gui, that has the target listview as its default listview control
Mode:
Selected - will delete all the selected rows
Deselected - will delete all deselected rows
Checked - etc.
Unchecked
SelectedChecked - will delete all selected AND checked rows (not to be mixed with selected OR checked!)
DeselectedUnchecked - etc.
SelectedUnchecked
DeselectedChecked
Examples:
This will delete all Selected rows:
LVG_Delete(1,"Selected")
This will delete all the Selected AND Checked rows:
LVG_Select(1,"SelectedChecked")
Remarks
Note: With the help of LVG_Get()'s or LV_Search()' Next option and LV_Delete() you can use a more sophisticated filter to delete rows!
*/
;===================================================================================
LVG_Delete(Gui_nr=1,mode="Selected") {
modelist=Selected,Deselected,Checked,Unchecked,SelectedChecked
,DeselectedUnchecked,SelectedUnchecked,DeselectedChecked
StringSplit, modelist, modelist, `,
Loop, %modelist0%
if (mode=modelist%a_index%)
mode = %a_index%
modelist:="",c:=0,count:=0,s_mode:="Checked",s_mode2:=""
If (mode=1 || mode=2 || mode=5 || mode=6 || mode=7 || mode=8)
{
s_mode:=""
s_mode2:="Checked"
}
Gui, %Gui_nr%:Default
Loop, % LV_GetCount()
{
If (pr = LV_GetCount())
Break
pr=0
Loop, % LV_GetCount()
{
If (((LV_GetNext(pr, s_mode) = a_index) && (mode=2 || mode=4)) || ((LV_GetNext(pr, s_mode) <> a_index) && (mode=1 || mode=3)) || ((LV_GetNext(pr, s_mode) = a_index) && (LV_GetNext(pr, s_mode2) = a_index) && mode=6) || ((LV_GetNext(pr, s_mode) <> a_index) && (mode=5)) || ((LV_GetNext(pr, s_mode) = a_index) && (LV_GetNext(pr, s_mode2) <> a_index) && mode=8) || ((LV_GetNext(pr, s_mode) <> a_index) && (LV_GetNext(pr, s_mode2) = a_index) && mode=7))
{
If (mode=5 || mode=6 || mode=7 || mode=8)
{
Loop, % LV_GetCount()
{
If (((LV_GetNext(pr, s_mode2) <> a_index) && (mode=5 || mode=8)) || ((LV_GetNext(pr, s_mode2) = a_index) && (mode=6 || mode=7)))
{
pr := a_index
Continue
}
Else
break
}
}
pr := a_index
Continue
}
Else if (((LV_GetNext(pr, s_mode) = a_index) && (mode=1 || mode=3)) || ((LV_GetNext(pr, s_mode) <> a_index) && (mode=2 || mode=4)) || ((LV_GetNext(pr, s_mode) <> a_index) && (LV_GetNext(pr, s_mode2) <> a_index) && mode=6) || ((LV_GetNext(pr, s_mode) = a_index) && (LV_GetNext(pr, s_mode2) = a_index) && (mode=5)) || ((LV_GetNext(pr, s_mode) <> a_index) && (LV_GetNext(pr, s_mode2) = a_index) && mode=8) || ((LV_GetNext(pr, s_mode) = a_index) && (LV_GetNext(pr, s_mode2) <> a_index) && mode=7))
{
count++
LV_Delete(a_index)
break
}
}
}
return count
}