samonlinesuper Posted September 1, 2011 Share Posted September 1, 2011 Dear ALL, As title, could someone help or give some suggestion that how to make select items from left to right in the GUI menu. Below is my code. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> $DualListDlg = GUICreate("Choices Dialog", 345, 359, 355, 224) GUISetIcon("", -1) $ListBox1 = GUICtrlCreateList("", 8, 8, 137, 201, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL)) GUICtrlSetData(-1, "Item1|Item2|Item3|Item4|Item5") $Button1 = GUICtrlCreateButton(">", 156, 15, 30, 25) $Button2 = GUICtrlCreateButton(">>", 156, 48, 31, 25) $Button3 = GUICtrlCreateButton("<", 157, 81, 31, 25) GUICtrlSetState(-1, $GUI_DISABLE) $Button4 = GUICtrlCreateButton("<<", 157, 114, 32, 25) $ListBox2 = GUICtrlCreateList("", 200, 8, 137, 201) $Button5 = GUICtrlCreateButton("&OK", 104, 225, 75, 25) $Button6 = GUICtrlCreateButton("&CLOSE", 184, 225, 75, 25) ; $Button7 = GUICtrlCreateButton("&Help", 264, 225, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE ExitLoop Case $nMsg = $Button6 WinClose("Choices Dialog", "") EndSelect WEnd Link to comment Share on other sites More sharing options...
JoHanatCent Posted September 1, 2011 Share Posted September 1, 2011 See if this helps: Link to comment Share on other sites More sharing options...
Spiff59 Posted September 1, 2011 Share Posted September 1, 2011 (edited) Getting comfortable with using arrays will make life much easier. This example has hard-coded values in the array: "Item1", "Item2", etc. You may later convert to loading the array from a file, if you wish the data to be stored and retrieved between executions of your script. See if this makes any sense: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $aItem[6][2] = [[5,""],["Item1",0],["Item2",1],["Item3",0],["Item4",0],["Item5",0]] $DualListDlg = GUICreate("Choices Dialog", 345, 359, 355, 224) GUISetIcon("", -1) $ListBox1 = GUICtrlCreateList("", 8, 8, 137, 201, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL)) $Button1 = GUICtrlCreateButton(">", 156, 15, 30, 25) $Button2 = GUICtrlCreateButton(">>", 156, 48, 31, 25) $Button3 = GUICtrlCreateButton("<", 157, 81, 31, 25) ;GUICtrlSetState(-1, $GUI_DISABLE) $Button4 = GUICtrlCreateButton("<<", 157, 114, 32, 25) $ListBox2 = GUICtrlCreateList("", 200, 8, 137, 201, $LBS_MULTIPLESEL) $Button5 = GUICtrlCreateButton("&OK", 104, 225, 75, 25) $Button6 = GUICtrlCreateButton("&CLOSE", 184, 225, 75, 25) ; $Button7 = GUICtrlCreateButton("&Help", 264, 225, 75, 25) GUISetState(@SW_SHOW) Update_Listviews() While 1 $msg = GUIGetMsg() Switch $msg Case $Button1 Shift($ListBox1, 1) Update_Listviews() Case $Button3 Shift($ListBox2, 0) Update_Listviews() Case $Button6, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func Update_Listviews() ; scan array and reload listboxes accordingly Local $str1, $str2 For $x = 1 to $aItem[0][0] ; loop through array If $aItem[$x][1] Then ; if 1, add to right listbox string $str2 &= $aItem[$x][0] & "|" Else ; if 0, add to left listbox string $str1 &= $aItem[$x][0] & "|" EndIf Next GUICtrlSetData($ListBox1, "") GUICtrlSetData($ListBox1, StringTrimRight($str1, 1)) ; strip trailing "|" and load to left listbox GUICtrlSetData($ListBox2, "") GUICtrlSetData($ListBox2, StringTrimRight($str2, 1)) ; strip trailing "|" and load to right listbox EndFunc Func Shift($control, $dest) Local $row = 0 For $x = 1 to $aItem[0][0] ; loop through array If $aItem[$x][1] <> $dest Then ; is array element not already in dest listbox? If _GUICtrlListBox_GetSel($control, $row) Then $aItem[$x][1] = $dest ; if row selected , move array element $row += 1 EndIf Next EndFunc Edit: Boo hiss! My first "code tag" post with the new forum software. It removed all the blank lines Edited September 1, 2011 by Spiff59 Link to comment Share on other sites More sharing options...
samonlinesuper Posted September 1, 2011 Author Share Posted September 1, 2011 Dears, Thanks a lot. However, I thought I could handle it after this but I founf that it is hard for me to execut select items. Could anyone help.............(sorry, I am new guy in programming). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now