两种方法都完美实现不了左边框复制到左边框的代码(已解决)
本帖最后由 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("","","","left",1,12, 10)
EndIf
Case $Button2
If GUICtrlRead($List2) <> '' Then
GUICtrlSetData($List1, GUICtrlRead($List2))
_GUICtrlListBox_DeleteString($List2, _GUICtrlListBox_GetCurSel($List2))
ControlClick("","","","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好容易啊 多看多学多思。 这个谁有现成的思路么....
这个代码应该很常用才对,不过help里面的太复杂,应该有简单的才对 update一下,有人帮忙么 自己解决了一下,看起来还凑合
就是代码需要那么复杂么#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))
; $iIndex = _GUICtrlListBox_FindString($hListBox, "exa")
;_GUICtrlListBox_SetCurSel($hListBox, $iIndex)
$Index=_GUICtrlListBox_GetCurSel($List1)
_GUICtrlListBox_DeleteString($List1, $index)
If $index > 0 Then
_GUICtrlListBox_ClickItem($list1, $Index-1)
Else
_GUICtrlListBox_ClickItem($list1, 0)
EndIf
;ControlClick("","","","left",1,12, 10)
EndIf
Case $Button2
If GUICtrlRead($List2) <> '' Then
GUICtrlSetData($List1, GUICtrlRead($List2))
$Index=_GUICtrlListBox_GetCurSel($List2)
_GUICtrlListBox_DeleteString($List2, $index)
If $index > 0 Then
_GUICtrlListBox_ClickItem($list2, $Index-1)
Else
_GUICtrlListBox_ClickItem($list2, 0)
EndIf
EndIf
EndSwitch
WEnd 本帖最后由 sour 于 2011-11-15 23:48 编辑
多选出错的原因是for 的排列要从大到小,否则就会删除错误....#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
Local $sItems, $aItems, $hListBox
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 432, 341, 192, 114)
$List1 = GUICtrlCreateList("11", 96, 32, 73, 201, BitOR($GUI_SS_DEFAULT_LIST, $LBS_MULTIPLESEL))
$List2 = GUICtrlCreateList("6", 224, 32, 73, 201, BitOR($GUI_SS_DEFAULT_LIST, $LBS_MULTIPLESEL))
$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
$aItems = _GUICtrlListBox_GetSelItemsText($List1)
For $iI = 1 To $aItems
GUICtrlSetData($List2, $aItems[$iI])
Next
$aItems = _GUICtrlListBox_GetSelItems($List1)
For $iI = $aItems To 1 Step -1
_GUICtrlListBox_DeleteString($List1, $aItems[$iI])
Next
If $aItems > 0 Then
_GUICtrlListBox_ClickItem($List1, $aItems - 1)
Else
_GUICtrlListBox_ClickItem($List1, 0)
EndIf
Case $Button2
$aItems = _GUICtrlListBox_GetSelItemsText($List2)
For $iI = 1 To $aItems
GUICtrlSetData($List1, $aItems[$iI])
Next
$aItems = _GUICtrlListBox_GetSelItems($List2)
For $iI = $aItems To 1 Step -1
_GUICtrlListBox_DeleteString($List2, $aItems[$iI])
Next
If $aItems > 0 Then
_GUICtrlListBox_ClickItem($List2, $aItems - 1)
Else
_GUICtrlListBox_ClickItem($List2, 0)
EndIf
EndSwitch
WEnd
页:
[1]