heavenm 发表于 2015-3-17 17:23:09

ListView复选框响应问题,已解决,但不明白为什么

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

Local $listview1, $button, $item1, $item2, $item3, $msg

GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
GUISetBkColor(0x00E0FFFF) ; will change background color

$listview1 = GUICtrlCreateListView("col1|col2|col3", 10, 10, 200, 150);,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
$item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview1)
$item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview1)
$item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview1)
GUICtrlCreateInput("", 20, 200, 150)
GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
GUISetState()
GUICtrlSetData($item2, "ITEM1")
GUICtrlSetData($item3, "||COL33")
GUICtrlDelete($item1)
Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)
_GUICtrlListView_SetExtendedListViewStyle($listview1, $exStyles)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
        Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $List
        $hWndListView = $ListView1
        If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)

        $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
        $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
        $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
        $iCode = DllStructGetData($tNMHDR, "Code")
        Switch $hWndFrom
                Case $hWndListView
                        ;ConsoleWrite("ICODE:"&$iCode&@CR)
                        Switch $iCode
                                Case -189
                                MsgBox(0, '', '你拉勾勾了')
                                Case $NM_RCLICK
                                        ConsoleWrite("Right click at listview")
                                        ;ListView_RClick()
                                        Return 0

                                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                                        Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                                        $Index = DllStructGetData($tInfo, "Index")
                                        $subitemNR = DllStructGetData($tInfo, "SubItem")
                                        ConsoleWrite("Double click at item index: " & $Index & @CRLF)
                        EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

rdctgvf 发表于 2015-6-10 01:11:44

找了好久,终于解决我的问题了,感谢楼主,非常感谢!!!!

ncxj 发表于 2016-1-6 10:43:19

ListView复选框响应问题,做个记号,如果是事件响应就好了

kk_lee69 发表于 2017-6-21 17:52:26

做個記號   我想找出正確值   MacGyver

kk_lee69 发表于 2017-6-21 23:24:51

回复 1# heavenm

查了半天 果然查不ˇ到這個 -189 的來歷
页: [1]
查看完整版本: ListView复选框响应问题,已解决,但不明白为什么