Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Func _guictrllistview_simplesort($hwnd, ByRef $vdescending, $icol)
- If $debug_lv Then __udf_validateclassname($hwnd, $__listviewconstant_classname)
- If _guictrllistview_getitemcount($hwnd) Then
- Local $b_desc
- If (IsArray($vdescending)) Then
- $b_desc = $vdescending[$icol]
- Else
- $b_desc = $vdescending
- EndIf
- Local $columns = _guictrllistview_getcolumncount($hwnd)
- Local $items = _guictrllistview_getitemcount($hwnd)
- Local $temp_item = ""
- Local $separatorchar = Opt("GUIDataSeparatorChar")
- For $x = 1 To $columns
- $temp_item = $temp_item & " " & $separatorchar
- Next
- $temp_item = StringTrimRight($temp_item, 1)
- Local $a_lv[$items][$columns + 1]
- Local $i_selected = StringSplit(_guictrllistview_getselectedindices($hwnd), $separatorchar)
- Local $i_checked = StringSplit(__guictrllistview_getcheckedindices($hwnd), $separatorchar)
- Local $v_item, $ifocused = -1
- For $x = 0 To UBound($a_lv) - 1 Step 1
- If $ifocused = -1 Then
- If _guictrllistview_getitemfocused($hwnd, $x) Then $ifocused = $x
- EndIf
- _guictrllistview_setitemselected($hwnd, $x, False)
- _guictrllistview_setitemchecked($hwnd, $x, False)
- For $y = 0 To UBound($a_lv, 2) - 2 Step 1
- $v_item = StringStripWS(_guictrllistview_getitemtext($hwnd, $x, $y), 2)
- If (StringIsFloat($v_item) OR StringIsInt($v_item)) Then
- $a_lv[$x][$y] = Number($v_item)
- Else
- $a_lv[$x][$y] = $v_item
- EndIf
- Next
- $a_lv[$x][$y] = $x
- Next
- _arraysort($a_lv, $b_desc, 0, 0, $icol)
- For $x = 0 To UBound($a_lv) - 1 Step 1
- For $y = 0 To UBound($a_lv, 2) - 2 Step 1
- _guictrllistview_setitemtext($hwnd, $x, $a_lv[$x][$y], $y)
- Next
- For $z = 1 To $i_selected[0]
- If $a_lv[$x][UBound($a_lv, 2) - 1] = $i_selected[$z] Then
- If $a_lv[$x][UBound($a_lv, 2) - 1] = $ifocused Then
- _guictrllistview_setitemselected($hwnd, $x, True, True)
- Else
- _guictrllistview_setitemselected($hwnd, $x, True)
- EndIf
- ExitLoop
- EndIf
- Next
- For $z = 1 To $i_checked[0]
- If $a_lv[$x][UBound($a_lv, 2) - 1] = $i_checked[$z] Then
- _guictrllistview_setitemchecked($hwnd, $x, True)
- ExitLoop
- EndIf
- Next
- Next
- If (IsArray($vdescending)) Then
- $vdescending[$icol] = NOT $b_desc
- Else
- $vdescending = NOT $b_desc
- EndIf
- EndIf
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement