Advertisement
Guest User

Untitled

a guest
May 28th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Func _guictrllistview_simplesort($hwnd, ByRef $vdescending, $icol)
  2.     If $debug_lv Then __udf_validateclassname($hwnd, $__listviewconstant_classname)
  3.     If _guictrllistview_getitemcount($hwnd) Then
  4.         Local $b_desc
  5.         If (IsArray($vdescending)) Then
  6.             $b_desc = $vdescending[$icol]
  7.         Else
  8.             $b_desc = $vdescending
  9.         EndIf
  10.         Local $columns = _guictrllistview_getcolumncount($hwnd)
  11.         Local $items = _guictrllistview_getitemcount($hwnd)
  12.         Local $temp_item = ""
  13.         Local $separatorchar = Opt("GUIDataSeparatorChar")
  14.         For $x = 1 To $columns
  15.             $temp_item = $temp_item & " " & $separatorchar
  16.         Next
  17.         $temp_item = StringTrimRight($temp_item, 1)
  18.         Local $a_lv[$items][$columns + 1]
  19.         Local $i_selected = StringSplit(_guictrllistview_getselectedindices($hwnd), $separatorchar)
  20.         Local $i_checked = StringSplit(__guictrllistview_getcheckedindices($hwnd), $separatorchar)
  21.         Local $v_item, $ifocused = -1
  22.         For $x = 0 To UBound($a_lv) - 1 Step 1
  23.             If $ifocused = -1 Then
  24.                 If _guictrllistview_getitemfocused($hwnd, $x) Then $ifocused = $x
  25.             EndIf
  26.             _guictrllistview_setitemselected($hwnd, $x, False)
  27.             _guictrllistview_setitemchecked($hwnd, $x, False)
  28.             For $y = 0 To UBound($a_lv, 2) - 2 Step 1
  29.                 $v_item = StringStripWS(_guictrllistview_getitemtext($hwnd, $x, $y), 2)
  30.                 If (StringIsFloat($v_item) OR StringIsInt($v_item)) Then
  31.                     $a_lv[$x][$y] = Number($v_item)
  32.                 Else
  33.                     $a_lv[$x][$y] = $v_item
  34.                 EndIf
  35.             Next
  36.             $a_lv[$x][$y] = $x
  37.         Next
  38.         _arraysort($a_lv, $b_desc, 0, 0, $icol)
  39.         For $x = 0 To UBound($a_lv) - 1 Step 1
  40.             For $y = 0 To UBound($a_lv, 2) - 2 Step 1
  41.                 _guictrllistview_setitemtext($hwnd, $x, $a_lv[$x][$y], $y)
  42.             Next
  43.             For $z = 1 To $i_selected[0]
  44.                 If $a_lv[$x][UBound($a_lv, 2) - 1] = $i_selected[$z] Then
  45.                     If $a_lv[$x][UBound($a_lv, 2) - 1] = $ifocused Then
  46.                         _guictrllistview_setitemselected($hwnd, $x, True, True)
  47.                     Else
  48.                         _guictrllistview_setitemselected($hwnd, $x, True)
  49.                     EndIf
  50.                     ExitLoop
  51.                 EndIf
  52.             Next
  53.             For $z = 1 To $i_checked[0]
  54.                 If $a_lv[$x][UBound($a_lv, 2) - 1] = $i_checked[$z] Then
  55.                     _guictrllistview_setitemchecked($hwnd, $x, True)
  56.                     ExitLoop
  57.                 EndIf
  58.             Next
  59.         Next
  60.         If (IsArray($vdescending)) Then
  61.             $vdescending[$icol] = NOT $b_desc
  62.         Else
  63.             $vdescending = NOT $b_desc
  64.         EndIf
  65.     EndIf
  66. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement