[已解决]第2个ListViewt控件响应不了 双击事件?
本帖最后由 elexy 于 2021-2-28 18:52 编辑#AutoIt3Wrapper_UseX64=n
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
;~ #include <ListViewConstants.au3>
Opt("GUIOnEventMode", 1) ;开启 Event 模式
Opt("TrayMenuMode", 1) ;右下角无菜单
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$GUI = GUICreate("", 555, 680, -1, -1, -1)
GUISetOnEvent(-3, "guiclose")
$Listview1 = GUICtrlCreateListView("编号|时间|代码|名称|标志|状态|数据1|数据2|数据3|数据4", 0, 0, 555, 400)
$Listview2 = GUICtrlCreateListView("代码|名称|数量|档案1|档案2|档案3|档案4|档案5|档案6", 0, 400, 555, 280)
GUICtrlCreateListViewItem("1001|1002|1003|1004|1005|1006|1007|1008|1009", $Listview1)
GUICtrlCreateListViewItem("2001|2002|2003|2004|2005|2006|2007|2008|2009", $Listview1)
GUICtrlCreateListViewItem("3001|3002|3003|3004|3005|3006|3007|3008|3009", $Listview2)
GUICtrlCreateListViewItem("4001|4002|4003|4004|4005|4006|4007|4008|4009", $Listview2)
GUICtrlCreateListViewItem("5001|5002|5003|5004|5005|5006|5007|5008|5009", $Listview2)
GUICtrlCreateListViewItem("6001|6002|6003|6004|6005|6006|6007|6008|6009", $Listview2)
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)
Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
If @error Then Return $GUI_RUNDEFMSG
$IDFrom = DllStructGetData($tagNMHDR, 2)
$Event = DllStructGetData($tagNMHDR, 3)
$tagNMHDR = 0
Switch $IDFrom ;选择产生事件的控件
Case $Listview1
Switch $Event; 选择产生的事件
Case $NM_CLICK; 左击
Case $NM_DBLCLK ; 双击
Global $Index = _GUICtrlListView_GetSelectedIndices($Listview1)
Global $Index2 = _GUICtrlListView_GetSelectedIndices($Listview2)
;MsgBox(64, $Index, $Index2)
If StringLen($Index) = 0 and StringLen($Index2) = 0 Then Return ;这里用以判断是否选定了ListViewItem
_DBC()
Case $NM_RCLICK ; 右击
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _DBC()
If StringLen($Index) Then
$a = _GUICtrlListView_GetSelectedIndices($Listview1)
$b = _GUICtrlListView_GetItemTextString($Listview1, Number($a))
$chaifen = StringSplit($b, "|")
MsgBox(64, 'L1', $chaifen)
Else
$a = _GUICtrlListView_GetSelectedIndices($Listview2)
$b = _GUICtrlListView_GetItemTextString($Listview2, Number($a))
$chaifen = StringSplit($b, "|")
MsgBox(64, 'L2', $chaifen)
EndIf
EndFunc ;==>_DBC
Func guiclose()
Exit
EndFunc ;==>guiclose
GUI上面的LV控件没问题,但下面的部分双击是没有反应的,请老师们指点一下如何实现两个LV控件单独双击弹出数据互不干扰
第 39 行 改为 Case $Listview1, $Listview2 确实,太尴尬了。。哈哈,谢谢谢谢
页:
[1]