|
本帖最后由 sour 于 2011-11-15 23:18 编辑
代码一只能一个一个复制,如果东西多了就很坑爹,但是又不知道怎么让他停留在上次选的下面#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 432, 341, 192, 114)
$List1 = GUICtrlCreateList("11", 96, 32, 73, 201)
$List2 = GUICtrlCreateList("6", 224, 32, 73, 201)
$Button1 = GUICtrlCreateButton("添加>>", 176, 48, 41, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("<<添加", 176, 88, 41, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUICtrlSetData($List1, "123")
GUICtrlSetData($List1, "1kj")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If GUICtrlRead($List1) <> '' Then
GUICtrlSetData($List2, GUICtrlRead($List1))
_GUICtrlListBox_DeleteString($List1, _GUICtrlListBox_GetCurSel($List1))
ControlClick("","","[CLASS:ListBox; INSTANCE:1]","left",1,12, 10)
EndIf
Case $Button2
If GUICtrlRead($List2) <> '' Then
GUICtrlSetData($List1, GUICtrlRead($List2))
_GUICtrlListBox_DeleteString($List2, _GUICtrlListBox_GetCurSel($List2))
ControlClick("","","[CLASS:ListBox; INSTANCE:1]","left",1,12, 10)
EndIf
EndSwitch
WEnd
方法2可以多选,左边拉到右边,右边再拉回来就不会删除了,看起来是
$totalnum = _GUICtrlListView_GetItemCount($list1)
的问题#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 432, 341, 192, 114)
$aStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
$list1 = GUICtrlCreateListView("名称", 96, 32, 73, 201, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
$list2 = GUICtrlCreateListView("名称", 224, 32, 73, 201, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
;_GUICtrlListView_SetExtendedListViewStyle($list1, $aStyles)
;_GUICtrlListView_SetView($list1, "0")
GUICtrlSetBkColor($list1, 0xffffff)
$Button1 = GUICtrlCreateButton("添加>>", 176, 48, 41, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("<<添加", 176, 88, 41, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$listteam = GUICtrlCreateListViewItem ("222",$list1)
;GUICtrlSetImage($listteam, "shell32.dll", 5)
$listteam = GUICtrlCreateListViewItem ("333",$list1)
;GUICtrlSetImage($listteam, "shell32.dll", 5)
$listteam = GUICtrlCreateListViewItem ("444",$list1)
$listteam = GUICtrlCreateListViewItem ("44432",$list1)
$listteam = GUICtrlCreateListViewItem ("4443",$list1)
$listteam = GUICtrlCreateListViewItem ("444333",$list1)
$listteam = GUICtrlCreateListViewItem ("44432",$list2)
$listteam = GUICtrlCreateListViewItem ("4443",$list2)
$listteam = GUICtrlCreateListViewItem ("444333",$list2)
;GUICtrlSetImage($listteam, "shell32.dll", 5)
While 1
$nMsg = GUIGetMsg ()
Switch $nMsg
Case -3
Exit
Case $button1
$totalnum = _GUICtrlListView_GetItemCount($list1)
$selectcount = _GUICtrlListView_GetSelectedCount($list1)
$out = ""
For $i = 0 To $totalnum-1
If $selectcount Then
If _GUICtrlListView_GetItemSelected($list1, $i) == True Then
_GUICtrlListView_CopyItems($list1, $list2, 1)
EndIf
Else
EndIf
Next
Case $button2
$totalnum = _GUICtrlListView_GetItemCount($list2)
$selectcount = _GUICtrlListView_GetSelectedCount($list2)
$out = ""
For $i = 0 To $totalnum-1
If $selectcount Then
If _GUICtrlListView_GetItemSelected($list2, $i) == True Then
_GUICtrlListView_CopyItems($list2, $list1, 1)
EndIf
Else
EndIf
Next
EndSwitch
WEnd
弄得那么复杂,用js好容易啊 |
|