#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 267, 223)
$ListView1 = GUICtrlCreateListView("1|2|3", 8, 8, 250, 150)
$Button1 = GUICtrlCreateButton("查看", 68, 176, 75, 25)
$Button2 = GUICtrlCreateButton("更改状态", 150, 176, 75, 25)
$radio1 = GUICtrlCreateRadio("radio1", 88, 202, 75, 25)
$radio2 = GUICtrlCreateRadio("radio2", 170, 202, 75, 25)
Local $Showhide, $Enabledisable
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0, '', IsWindowEnable(GUICtrlGetHandle($ListView1)) ? "启用" : "禁用")
MsgBox(0, '', IsWindowVisible(GUICtrlGetHandle($ListView1)) ? "显示" : "隐藏")
Case $Button2
If Random(0, 1, 1) Then
$Showhide = $GUI_SHOW
Else
$Showhide = $GUI_HIDE
EndIf
If Random(0, 1, 1) Then
$Enabledisable = $GUI_ENABLE
Else
$Enabledisable = $GUI_DISABLE
EndIf
GUICtrlSetState($ListView1, BitOR($Showhide,$Enabledisable))
EndSwitch
WEnd
Func IsWindowEnable($hWnd)
Local $aRet = DllCall('user32.dll', 'bool', 'IsWindowEnabled', 'hwnd', $hWnd)
If @error Then Return SetError(@error, @extended, False)
Return $aRet[0]
EndFunc
Func IsWindowVisible($hWnd)
Local $aResult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hWnd)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[0]
EndFunc