1.左键双击移动到另一个LISTVIEW.
2.可CTRL多选.多选后右键移动到另一个LISTVIEW
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GuiImageList.au3>
$hGUI = GUICreate("LVN_ITEMCHECKING", 400, 400)
$ListView1 = GUICtrlCreateListView("Test|Val", 10, 10, 380, 180, $LVS_SHOWSELALWAYS, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT));, Default, BitOR($LVS_EX_CHECKBOXES, 0x200))
$hListView = GUICtrlGetHandle(-1)
$hImage = _GUIImageList_Create(1, 30);30为间距
_GUICtrlListView_SetImageList($ListView1, $hImage, 1)
For $I = 1 To 10
GUICtrlCreateListViewItem("ITEM-" & $I & "|Val-" & $I, $ListView1)
Next
$ListView2 = GUICtrlCreateListView("Test1|Val1", 10, 190, 380, 180, $LVS_SHOWSELALWAYS);, Default, BitOR($LVS_EX_CHECKBOXES, 0x200))
;GUICtrlCreateListViewItem("Item 1", $iListView)
;GUICtrlCreateListViewItem("Item 2", $iListView)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While GUIGetMsg() <> -3
WEnd
GUIDelete($hGUI)
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 ; 双击
$Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If $Index = "" Then; 这里用以判断是否选定了ListViewItem
Return
EndIf
_GUICtrlListView_AddItem($ListView2, _GUICtrlListView_GetItemText($ListView1, Number($Index), 0))
_GUICtrlListView_AddSubItem($ListView2, _GUICtrlListView_GetItemCount($ListView2) - 1, _GUICtrlListView_GetItemText($ListView1, Number($Index), 1), 1)
_GUICtrlListView_DeleteItem($ListView1, Number($Index))
Case $NM_RCLICK ; 右击
$Index = _GUICtrlListView_GetSelectedIndices($ListView1, True)
If $Index[0] = 0 Then Return
For $I = 1 To $Index[0]
_GUICtrlListView_AddItem(GUICtrlGetHandle($ListView2), _GUICtrlListView_GetItemText($ListView1, Number($Index[$I]), 0))
_GUICtrlListView_AddSubItem($ListView2, _GUICtrlListView_GetItemCount($ListView2) - 1, _GUICtrlListView_GetItemText($ListView1, Number($Index[$I]), 1), 1)
Next
For $I = $Index[0] To 1 Step -1
_GUICtrlListView_DeleteItem($ListView1, Number($Index[$I]))
Next
EndSwitch
Case $ListView2
Switch $Event; 选择产生的事件
Case $NM_CLICK ; 左击
;~ ...
Case $NM_DBLCLK ; 双击
$Index = _GUICtrlListView_GetSelectedIndices($ListView2)
If $Index = "" Then; 这里用以判断是否选定了ListViewItem
Return
EndIf
_GUICtrlListView_AddItem($ListView1, _GUICtrlListView_GetItemText($ListView2, Number($Index), 0))
_GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1, _GUICtrlListView_GetItemText($ListView2, Number($Index), 1), 1)
_GUICtrlListView_DeleteItem(GUICtrlGetHandle($ListView2), Number($Index))
Case $NM_RCLICK ; 右击
$Index = _GUICtrlListView_GetSelectedIndices($ListView2, True)
If $Index[0] = 0 Then Return
For $I = 1 To $Index[0]
_GUICtrlListView_AddItem(GUICtrlGetHandle($ListView1), _GUICtrlListView_GetItemText($ListView2, Number($Index[$I]), 0))
_GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1, _GUICtrlListView_GetItemText($ListView2, Number($Index[$I]), 1), 1)
Next
For $I = $Index[0] To 1 Step -1
_GUICtrlListView_DeleteItem(GUICtrlGetHandle($ListView2), Number($Index[$I]))
Next
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
|