本帖最后由 kk_lee69 于 2012-8-22 21:49 编辑
一个FROM 两个 LISTVIEW 如何判断双击事件..有查过..不过我写不出来所以求助
寫出來 都會變成判斷成第一個 LISTVIEW
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
$Form1 = GUICreate("Form1", 800, 600)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$ListView1 = GUICtrlCreateListView("||", 8, 8, 300, 200)
GUISetState(@SW_SHOW)
For $I = 1 To 10
GUICtrlCreateListViewItem($I, $ListView1)
Next
$ListView2 = GUICtrlCreateListView("||", 350, 250, 200, 200)
GUISetState(@SW_SHOW)
For $I = 1 To 5
GUICtrlCreateListViewItem($I, $ListView2)
Next
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
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
Select ;$IDFrom;選擇產生事件的控制項
Case $ListView1
Switch $Event; 選擇產生的事件
Case $NM_CLICK ; 左擊
;~ ...
Case $NM_DBLCLK ; 雙擊
MsgBox(0,"A","A")
$Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If Not StringLen($Index) Then; 這裏用以判斷是否選定了ListViewItem
MsgBox(0, "", "未選定")
Return
EndIf
MsgBox(0,0, _GUICtrlListView_GetItemText($ListView1, Number($Index), 0))
Case $NM_RCLICK ; 右擊
;~ ...
EndSwitch
Case $ListView2
Switch $Event; 選擇產生的事件
Case $NM_CLICK ; 左擊
;~ ...
Case $NM_DBLCLK ; 雙擊
MsgBox(0,"B","B")
$Index2 = _GUICtrlListView_GetSelectedIndices($ListView2)
If Not StringLen($Index2) Then; 這裏用以判斷是否選定了ListViewItem
MsgBox(0, "", "未選定")
Return
EndIf
MsgBox(0,0, _GUICtrlListView_GetItemText($ListView2, Number($Index2), 0))
Case $NM_RCLICK ; 右擊
;~ ...
EndSwitch
EndSelect
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
|