Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoTrayIcon
- #include <GUIConstantsEx.au3>
- #include <GUIListView.au3>
- #include <WindowsConstants.au3>
- #include <ButtonConstants.au3>
- #include <GUIButton.au3>
- Example()
- Func Example()
- Local Const $hGUI = GUICreate("", 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
- Local Const $iListView = GUICtrlCreateListView("", 0, 0, 400, 270)
- Local Const $hListView = GUICtrlGetHandle($iListView)
- $hlistviewHeader = _GUICtrlListView_GetHeader($hlistview)
- $chk = _GUICtrlButton_Create($hlistviewHeader, "", 0, 0, 20, 20, $BS_AUTOCHECKBOX)
- _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
- GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
- Local $iSelectionState = GUICtrlCreateButton("Change State", 400 - 90, 275, 85, 22.5)
- GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM)
- GUISetState(@SW_SHOWNORMAL, $hGUI)
- __ListViewFill($hListView, Random(1, 5, 1), Random(2, 15, 1), 1) ; Randomly fill data in a ListView.
- While 1
- Switch GUIGetMsg()
- Case $GUI_EVENT_CLOSE
- ExitLoop
- Case $iSelectionState
- _GUICtrlListView_SetCheckedStates($hListView, 2)
- MsgBox(4096, "", "All items were inverted, so if an item was checked before it was unchecked afterwards.")
- _GUICtrlListView_SetCheckedStates($hListView, 0)
- MsgBox(4096, "", "All items were unchecked.")
- _GUICtrlListView_SetCheckedStates($hListView, 1)
- MsgBox(4096, "", "All items were checked.")
- EndSwitch
- WEnd
- Return GUIDelete($hGUI)
- EndFunc ;==>Example
- ;~ $iType: 0 - UnCheck all, 1 - Check all & 2 - Invert selection.
- Func _GUICtrlListView_SetCheckedStates(Const $hListView, Const $iType) ; By Zedna, Modified by guinness.
- Local $fState = False
- Local Const $iCount = _GUICtrlListView_GetItemCount($hListView)
- If $iType < 0 Or $iType > 2 Then
- Return SetError(1, 0, 0)
- EndIf
- If $iType Then
- $fState = True
- EndIf
- For $i = 0 To $iCount - 1
- If $iType = 2 Then
- $fState = Not _GUICtrlListView_GetItemChecked($hListView, $i) ; Invert checked state with $iType 2.
- EndIf
- _GUICtrlListView_SetItemChecked($hListView, $i, $fState)
- Next
- EndFunc ;==>_GUICtrlListView_SetCheckedStates
- Func __ListViewFill(Const $hListView, Const $iColumns, Const $iRows, Const $iCheckboxes = 0) ; Randomly fill data in a ListView.
- For $A = 0 To $iColumns - 1
- _GUICtrlListView_InsertColumn($hListView, $A, "Column " & $A + 1, 50)
- _GUICtrlListView_SetColumnWidth($hListView, $A - 1, -2)
- Next
- For $A = 0 To $iRows - 1
- _GUICtrlListView_AddItem($hListView, Chr(Random(65, 90, 1)) & " - Row " & $A + 1 & ": Col 1", $A)
- If Random(0, 1, 1) And $iCheckboxes Then
- _GUICtrlListView_SetItemChecked($hListView, $A)
- EndIf
- For $B = 1 To $iColumns
- _GUICtrlListView_AddSubItem($hListView, $A, "Row " & $A + 1 & ": Col " & $B + 1, $B)
- Next
- Next
- EndFunc ;==>__ListViewFill
Add Comment
Please, Sign In to add comment