#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
Global $iListView, $iListViewCheck, $hListViewCheck, $iCountCheck = 0, $iLbl
_Main()
Func _Main()
Local $iTimer, $iBtn, $iBtnRand, $aItems[Random(50, 100, 1)][2]
GUICreate('ListView', 400, 400)
$iListView = GUICtrlCreateListView('', 2, 2, 197, 268)
$iListViewCheck = GUICtrlCreateListView('', 201, 2, 197, 268)
$hListViewCheck = GUICtrlGetHandle($iListViewCheck)
_GUICtrlListView_SetExtendedListViewStyle($iListViewCheck, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
_GUICtrlListView_SetExtendedListViewStyle($iListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
$iBtn = GUICtrlCreateButton('UnChecked All', 20, 350, 110, 30)
$iLbl = GUICtrlCreateLabel('Checked: 0', 150, 310, 100, 20)
$iBtnRand = GUICtrlCreateButton('Checked Random', 20, 310, 110, 30)
_GUICtrlListView_AddColumn($iListView, 'Пункты', 90)
_GUICtrlListView_AddColumn($iListView, '1', 90)
_GUICtrlListView_AddColumn($iListViewCheck, 'Checked', 90)
_GUICtrlListView_AddColumn($iListViewCheck, '1', 90)
For $i = 0 To UBound($aItems) - 1
$aItems[$i][0] = Random(1, 1000, 1) & ' Пункт'
$aItems[$i][1] = Random(1, 1000, 1) & ' Пункт'
Next
_GUICtrlListView_AddArray($iListView, $aItems)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $iBtn
GUIRegisterMsg($WM_NOTIFY, '')
_GUICtrlListView_SetItemChecked($iListView, -1, 0)
_GUICtrlListView_DeleteAllItems($hListViewCheck)
$iCountCheck = 0
GUICtrlSetData($iLbl, 'Checked: ' & $iCountCheck)
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
Case $iBtnRand
For $i = 0 To _GUICtrlListView_GetItemCount($iListView) - 1
If Random(0, 1, 1) Then _GUICtrlListView_SetItemChecked($iListView, $i)
Next
EndSwitch
WEnd
GUIDelete()
EndFunc ;==>_Main
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tInfo, $iIndex, $iIndexCh
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Switch DllStructGetData($tInfo, 'IDFrom')
Case $iListView
Switch DllStructGetData($tInfo, 'Code')
Case $LVN_ITEMCHANGED
Switch DllStructGetData($tInfo, 'NewState')
Case $LVM_FIRST
$iCountCheck -= 1
$iIndex = DllStructGetData($tInfo, 'Index')
$iIndex = _GUICtrlListView_FindInText($hListViewCheck, _GUICtrlListView_GetItemText($iListView, $iIndex))
If $iIndex >= 0 Then _GUICtrlListView_DeleteItem($hListViewCheck, $iIndex)
GUICtrlSetData($iLbl, 'Checked: ' & $iCountCheck)
Case $LVM_FIRST * 2
$iCountCheck += 1
$iIndex = DllStructGetData($tInfo, 'Index')
_GUICtrlListView_AddItem($iListViewCheck, _GUICtrlListView_GetItemText($iListView, $iIndex))
$iIndexCh = _GUICtrlListView_GetItemCount($iListViewCheck) - 1
For $i = 1 To _GUICtrlListView_GetColumnCount($iListView) - 1
_GUICtrlListView_AddSubItem($iListViewCheck, $iIndexCh, _GUICtrlListView_GetItemText($iListView, $iIndex, $i), $i)
Next
GUICtrlSetData($iLbl, 'Checked: ' & $iCountCheck)
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY