本帖最后由 pusofalse 于 2010-3-29 21:19 编辑
ListView 消息扩展UDF - ListViewEditEvent.au3 - http://autoitx.com/forum.php?mod=viewthread&tid=13175#include <ListViewEditEvent.au3>
$hGUI = GUICreate("LVN_ITEMCHECKING", 400, 300)
$iListView = GUICtrlCreateListView("Test", 10, 10, 380, 280, Default, BitOR($LVS_EX_CHECKBOXES, 0x200))
$hListView = GUICtrlGetHandle(-1)
GUICtrlCreateListViewItem("Item 1", $iListView)
GUICtrlCreateListViewItem("Item 2", $iListView)
GUISetState()
_GUICtrlListView_RegisterEditEvent($hListView)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While GUIGetMsg() <> -3
WEnd
GUIDelete($hGUI)
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
If ($iwParam = $iListView) Then
Local $tBuffer, $iCode, $iItem, $iState, $sText
$tBuffer = DllStructCreate($tagLISTVIEW_ITEMCHECKING, $ilParam)
$iCode = DllStructGetData($tBuffer, "Code")
If ($iCode = $LVN_ITEMCHECKING) Then
$iItem = DllStructGetData($tBuffer, "Item")
$iState = DllStructGetData($tBuffer, "CurrentChecked")
$iFlags = DllStructGetData($tBuffer, "Flags")
$sText &= "Item: " & $iItem & @CRLF
$sText &= "Current state: " & $iState & " (0 - unchecked, 1 - checked)" & @CRLF
$sText &= "Checking flag: " & $iFlags & @CRLF & @CRLF
$sText &= "Are you sure change state of this item?"
If Msgbox(52, '', $sText, 0, $hGUI) = 7 Then
DllStructSetData($tBuffer, "AllowCheck", 0)
EndIf
EndIf
EndIf
EndFunc ;==>WM_NOTIFY
|