以下代码功能,用GUICtrlCreateList控件如何实现?[已解决]
本帖最后由 dhh45 于 2010-10-19 09:06 编辑以下代码功能,用GUICtrlCreateList控件如何实现?#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GUIListview.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$List1 = GUICtrlCreateListView("", 72, 56, 105, 188)
_GUICtrlListView_AddItem($List1,"test1",0)
_GUICtrlListView_AddItem($List1,"test2",1)
_GUICtrlListView_AddItem($List1,"test3",2)
_GUICtrlListView_AddItem($List1,"test4",3)
_GUICtrlListView_AddItem($List1,"test5",4)
_GUICtrlListView_AddItem($List1,"test6",5)
_GUICtrlListView_AddItem($List1,"test7",6)
_GUICtrlListView_AddItem($List1,"test8",7)
GUICtrlSetStyle($List1,BitOR($lvs_list,$lvs_showselalways))
$Button1 = GUICtrlCreateButton(">", 216, 64, 89, 33)
$Button2 = GUICtrlCreateButton("<", 216, 112, 89, 33)
$Button3 = GUICtrlCreateButton(">>", 216, 160, 89, 41)
$List2 = GUICtrlCreateListView("", 344, 64, 113, 175)
GUICtrlSetStyle($List2,BitOR($lvs_list,$lvs_showselalways))
$Button4 = GUICtrlCreateButton("<<", 216, 208, 89, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_GUICtrlListView_CopyItems(GUICtrlGetHandle($List1),GUICtrlGetHandle($List2),True)
Case $Button2
_GUICtrlListView_CopyItems(GUICtrlGetHandle($List2),GUICtrlGetHandle($List1),True)
Case $Button3
$dd=""
$dd=_GUICtrlListView_GetItemCount(GUICtrlGetHandle($List1))
For $i=0 To $dd-1
_GUICtrlListView_SetItemSelected(GUICtrlGetHandle($List1),$i,True)
Next
_GUICtrlListView_CopyItems(GUICtrlGetHandle($List1),GUICtrlGetHandle($List2),True)
Case $Button4
$dd=""
$dd=_GUICtrlListView_GetItemCount(GUICtrlGetHandle($List2))
For $i=0 To $dd-1
_GUICtrlListView_SetItemSelected(GUICtrlGetHandle($List2),$i,True)
Next
_GUICtrlListView_CopyItems(GUICtrlGetHandle($List2),GUICtrlGetHandle($List1),True)
EndSwitch
WEnd 大家没有看见,还是…… 没人回答是因为你完全没有经过自己思考,只想着要求源码。
给你一段代码,没写完整。自己补全吧。
;#include <ButtonConstants.au3>
;#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
;#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Listbox=_GUICtrlListBox_Create($Form1, "", 72, 56, 105, 188)
_GUICtrlListBox_BeginUpdate($Listbox)
For $i = 1 To 9
_GUICtrlListBox_AddString($ListBox, 'Test'&$i)
Next
_GUICtrlListBox_EndUpdate($Listbox)
$Button1 = GUICtrlCreateButton(">", 216, 64, 89, 33)
$Button2 = GUICtrlCreateButton("<", 216, 112, 89, 33)
$Button3 = GUICtrlCreateButton(">>", 216, 160, 89, 41)
$Button4 = GUICtrlCreateButton("<<", 216, 208, 89, 41)
$Listbox2=_GUICtrlListBox_Create($Form1, "", 344, 64, 113, 175)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$index=_GUICtrlListBox_GetCurSel($ListBox)
If $index=-1 Then $index=0
$text=_GUICtrlListBox_GetText($ListBox, $index)
MsgBox(0,0,$text)
_GUICtrlListBox_BeginUpdate($Listbox2)
_GUICtrlListBox_AddString($ListBox2, $text)
_GUICtrlListBox_EndUpdate($Listbox2)
_GUICtrlListBox_DeleteString($ListBox,$index)
Case $Button2
;与$BUTTON1雷同
Case $Button3
;与$BUTTON1雷同
Case $Button4
;与$BUTTON1雷同
EndSwitch
WEnd 回复 3# 3mile
不是等着大家的代码,而是真的有困难。
您的代码只实现了选择单个记录转移,没有实现多选转移,这个是难点
我还在研究…… 回复 4# dhh45
_GUICtrlListBox_GetCount #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$List1 = GUICtrlCreateList("", 32, 16, 569, 136,BitOR($ws_border,$ws_vscroll,$lbs_notify,$lbs_disablenoscroll,$ws_hscroll,$lbs_extendedsel))
$List2 = GUICtrlCreateList("", 40, 264, 569, 149,BitOR($ws_border,$ws_vscroll,$lbs_notify,$lbs_disablenoscroll,$ws_hscroll,$lbs_extendedsel))
$Button1 = GUICtrlCreateButton("向下", 48, 184, 65, 33)
$Button2 = GUICtrlCreateButton("全向下", 136, 184, 65, 33)
$Button3 = GUICtrlCreateButton("向上", 224, 184, 73, 33)
$Button4 = GUICtrlCreateButton("全向上", 328, 184, 73, 33)
$Button5 = GUICtrlCreateButton("清空", 432, 184, 81, 41)
For$i=1To 12
_GUICtrlListBox_InsertString(GUICtrlGetHandle($List1), "test"&$i,$i-1)
Next
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
SingalSelect($List1,$List2)
Case $Button2
AllSelect($List1,$List2)
Case $Button3
SingalSelect($List2,$List1)
Case $Button4
AllSelect($List2,$List1)
Case $Button5
_GUICtrlListBox_ResetContent (GUICtrlGetHandle($List1))
_GUICtrlListBox_ResetContent (GUICtrlGetHandle($List2))
EndSwitch
WEnd
Func SingalSelect($S,$D)
$aa=""
$bb=""
$aa=_GUICtrlListBox_GetSelItemsText(GUICtrlGetHandle($S))
$bb=_GUICtrlListBox_GetSelItems(GUICtrlGetHandle($S))
For $i=1 To $aa
_GUICtrlListBox_AddString(GUICtrlGetHandle($D),$aa[$i])
Next
For $i=1 To $aa
_GUICtrlListBox_ReplaceString(GUICtrlGetHandle($S),$bb[$i],"temp")
Next
$count=_GUICtrlListBox_GetCount(GUICtrlGetHandle($S))
For $i=1 To $count
_GUICtrlListBox_DeleteString(GUICtrlGetHandle($S),_GUICtrlListBox_FindString(GUICtrlGetHandle($S),"temp",True))
Next
EndFunc
Func AllSelect($s,$d)
$count=_GUICtrlListBox_GetCount(GUICtrlGetHandle($S))
For $i=0 To $count-1
_GUICtrlListBox_AddString(GUICtrlGetHandle($d),_GUICtrlListBox_GetText(GUICtrlGetHandle($S),$i))
Next
_GUICtrlListBox_ResetContent (GUICtrlGetHandle($S))
EndFunc 留着以后用 雷锋精神传天下!谢谢分享!
页:
[1]