本帖最后由 jycel 于 2009-9-29 21:31 编辑
论坛上有类似例子!
可以参照下我写的网吧GHOST后全自动设置程序3.0源代码
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
;上句加入开头
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 ; 左击
$Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If Not StringLen($Index) Then; 这里用以判断是否选定了ListViewItem
$List_n=_GUICtrlListView_GetItemCount($ListView1)
If Not $List_n Then
GUICtrlSetData($Label1,"提示:当前无任何数据请先扫描")
EndIf
;GUICtrlSetData($Label1,"提示:请先选中数据再进行相关操作,没有数据请先扫描")
Return
EndIf
GUICtrlSetData($Label1,"提示:请点击右键操作[编缉数据]|[删除按钮]|[清空数据]|[批量编缉]")
GUICtrlSetData($Input1,_GUICtrlListView_GetItemText($ListView1, Number($Index),1))
GUICtrlSetData($Input2,_GUICtrlListView_GetItemText($ListView1, Number($Index),2))
GUICtrlSetData($Input3,_GUICtrlListView_GetItemText($ListView1, Number($Index),0))
GUICtrlSetData($Combo1,_GUICtrlListView_GetItemText($ListView1, Number($Index),3))
GUICtrlSetData($Input5,_GUICtrlListView_GetItemText($ListView1, Number($Index),4))
GUICtrlSetData($Input6,_GUICtrlListView_GetItemText($ListView1, Number($Index),5))
GUICtrlSetData($Input7,_GUICtrlListView_GetItemText($ListView1, Number($Index),6))
GUICtrlSetData($Input8,_GUICtrlListView_GetItemText($ListView1, Number($Index),7))
GUICtrlSetData($Input9,_GUICtrlListView_GetItemText($ListView1, Number($Index),9))
GUICtrlSetData($Combo2,_GUICtrlListView_GetItemText($ListView1, Number($Index),8))
GUICtrlSetData($Combo3,_GUICtrlListView_GetItemText($ListView1, Number($Index),10))
Case $NM_DBLCLK ; 双击
$Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If Not StringLen($Index) Then; 这里用以判断是否选定了ListViewItem
GUICtrlSetData($Label1,"提示:请先选中数据再进行相关操作,没有数据请先扫描")
Return
EndIf
GUICtrlSetData($Label1,"提示:请点击右键操作[编缉数据]|[删除按钮]|[清空数据]|[批量编缉]")
GUICtrlSetData($Input1,_GUICtrlListView_GetItemText($ListView1, Number($Index),1))
GUICtrlSetData($Input2,_GUICtrlListView_GetItemText($ListView1, Number($Index),2))
GUICtrlSetData($Input3,_GUICtrlListView_GetItemText($ListView1, Number($Index),0))
GUICtrlSetData($Combo1,_GUICtrlListView_GetItemText($ListView1, Number($Index),3))
GUICtrlSetData($Input5,_GUICtrlListView_GetItemText($ListView1, Number($Index),4))
GUICtrlSetData($Input6,_GUICtrlListView_GetItemText($ListView1, Number($Index),5))
GUICtrlSetData($Input7,_GUICtrlListView_GetItemText($ListView1, Number($Index),6))
GUICtrlSetData($Input8,_GUICtrlListView_GetItemText($ListView1, Number($Index),7))
GUICtrlSetData($Input9,_GUICtrlListView_GetItemText($ListView1, Number($Index),9))
GUICtrlSetData($Combo2,_GUICtrlListView_GetItemText($ListView1, Number($Index),8))
GUICtrlSetData($Combo3,_GUICtrlListView_GetItemText($ListView1, Number($Index),10))
Case $NM_RCLICK ; 右击
;~ ...
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
|