[已解决]ListView双击无法显示资料
本帖最后由 jackywjl 于 2011-9-27 09:43 编辑请教各位前辈,小弟找了一些前辈们的双击资料,写了一支程式测试,结果却无法显示双击后的资料,不知哪边出了问题,源码如下~~谢谢
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Include <Array.au3>
#Include <File.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 311, 442, 354, 130)
$Tab1 = GUICtrlCreateTab(8, 24, 289, 409)
$tab0 = GUICtrlCreateTabItem("tab1")
$ListView1 = GUICtrlCreateListView("", 8, 43, 289, 390)
_GUICtrlListView_AddColumn($ListView1, "ID", 90, 2)
_GUICtrlListView_AddColumn($ListView1, "NAME", 60, 2)
GUICtrlCreateListViewItem("1" & "|" & "2" , $ListView1)
$tab2 = GUICtrlCreateTabItem("tab2")
$ListView2 = GUICtrlCreateListView("", 8, 43, 289, 390)
_GUICtrlListView_AddColumn($ListView2, "test1", 90, 2)
_GUICtrlListView_AddColumn($ListView2, "test2", 90, 2)
GUICtrlCreateListViewItem("3" & "|" & "4" , $ListView2)
GUICtrlCreateTabItem("")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
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 ,$Menu
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = DllStructGetData($tNMHDR, 2)
$iCode = DllStructGetData($tNMHDR, 3)
Switch $hWndFrom
Case $ListView1
Switch $iCode
Case $NM_DBLCLK ; 响应 List1 范围内的双击
$Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If $Index <> "" Then
$L_Name = _GUICtrlListView_GetItemText($ListView1,$Index)
MsgBox(0,"响应双击","你选择的是"&$L_Name)
EndIf
EndSwitch
Case $ListView2
Switch $iCode
Case $NM_DBLCLK ; 响应 List1 范围内的双击
$Index = _GUICtrlListView_GetSelectedIndices($ListView2)
If $Index <> "" Then
$L_Name = _GUICtrlListView_GetItemText($ListView2,$Index)
MsgBox(0,"响应双击","你选择的是"&$L_Name)
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc 回复 1# jackywjl
$L_Name = _GUICtrlListView_GetItemText($ListView1,Number($Index))
$Index 换成 数字型 感谢haodd大大,解决困扰我好久的问题~~感恩 WIN7下双击没反应,不知道怎么修改。 回复 4# damoo
#PRE_UseX64=n
64位吧?注明即可 无法获取到数据吧。 正好需要顶起
页:
[1]