P0ZiTR0N Posted April 17, 2009 Share Posted April 17, 2009 Need to organize hot-switch of variables from 1 to 5 and from 5 to 1 with full exchange of data in array. (but not reverse - numbers set just as simple example) Any suggestions about it? Same as in screenshots. In full project the data for gui reads from ini-file I thought about: 1) kill and recreate window (as a variant but not the best choice) 2) create ALL checkbox in the listview but set visible/invisible if is it possible (I think this is the hardest way) 3) kill gui control "listview" and create new with the same name - this does not help.. Why? Don't know... the part of code of trouble: expandcollapse popup#NoTrayIcon ;#include <Debug.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <GuiListView.au3> #include <GuiTreeView.au3> #include <GUIScrollBars.au3> #include <INet.au3> #include <ListBoxConstants.au3> #include <ListviewConstants.au3> #include <ScrollBarConstants.au3> #include <StaticConstants.au3> #include <String.au3> #include <TabConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> global $conf, $conf1, $conf2, $treeOne, $c1, $c $ini_list1 = _ArrayCreate("") $tree_list_one = _ArrayCreate("") $Form1 = GUICreate("Form1", 200, 200) $conf1 = GUICtrlCreateButton("conf1",120, 8, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $conf2 = GUICtrlCreateButton("conf2",120, 24, 80, 17) $Bbutton1 = GUICtrlCreateButton("4test", 40, 180, 60, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) $treeOne = GUICtrlCreateListView("Items",0, 8, 120, 120, -1, $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($treeOne, 0, $LVSCW_AUTOSIZE_USEHEADER) For $c = 1 To 5 ; setting the data (this example has just simple cycle) _ArrayAdd($ini_list1, $c) Next _ArrayReverse ($ini_list1) _ArrayPop($ini_list1) If $c <> 0 Then dim $tree_list_one[$c] EndIf $c = 0 GUISetState(@SW_SHOW) if $conf = 0 Then _check(0) endif func _check ($lab) ; _check(1) if $lab = 1 then For $c = 5 To 1 ; 5,4,3,2,1 _ArrayAdd($ini_list1, $c) Next For $c1 = 0 To $c ;~ _ArrayDisplay($ini_list1,"$ini_list1") ;~ _ArrayDisplay($tree_list_one,"$tree_list_one") GUICtrlSetData($tree_list_one[$c1], _ArrayPop($ini_list1), $treeOne) Next return ; _check(2) elseIf $lab = 2 then For $c = 1 To 5 ; 1,2,3,4,5 _ArrayAdd($ini_list1, $c) Next For $c1 = 0 To $c-2 GUICtrlSetData($tree_list_one[$c1], _ArrayPop($ini_list1), $treeOne) Next return else For $c = 1 To 5 _ArrayAdd($ini_list1, $c) Next For $c1 = 0 To $c-2 GUICtrlSetData ($tree_list_one[$c1],GUICtrlCreateListViewItem(_ArrayPop($ini_list1), $treeOne)) ;~ _ArrayDisplay($ini_list1,"$ini_list1") ;~ _ArrayDisplay($tree_list_one,"$tree_list_one") Next return endif endFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $conf1 _check(1) Case $conf2 _check(2) EndSwitch WEnd Link to comment Share on other sites More sharing options...
Bert Posted April 18, 2009 Share Posted April 18, 2009 do you mean to randomize the list? The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
P0ZiTR0N Posted April 18, 2009 Author Share Posted April 18, 2009 No. I mean to: 1) create the treeviewlist with the array[$i] 2) put the $c into array value 3) create GUI with default data of function _check(0) 4) wait for switch and then check a) if pressed (1) then set the value of array 5...1 and show it in the GUI if pressed (2) then set 1...5 and show it. Later the shown data need to be checked by user and worked by script for searching and sending checked data to the server. this is not the exactly input values, but for this example. Link to comment Share on other sites More sharing options...
AlmarM Posted April 18, 2009 Share Posted April 18, 2009 do you mean to randomize the list?He wants to sort it.AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
andybiochem Posted April 18, 2009 Share Posted April 18, 2009 I don't think he wants to simply sort the items...1 to 5 was just an example, items could be any strings (I think?!?!?!?). Do you want to keep the array as it is, or do you want it to be reversed along with the list view? Does this help any?: #include <ListviewConstants.au3> #Include <GuiListView.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) Global $aArray[5] = [1,2,3,4,5] Global $aArrayCopy[1] GUICreate("",200,150) $LV = GUICtrlCreateListView("Items",10,10,120,120,-1,$LVS_EX_CHECKBOXES) GUICtrlCreateButton("Forward",140,10,50,20) GUICtrlSetOnEvent(-1,"PopulateLV") GUICtrlCreateButton("Reverse",140,40,50,20) GUICtrlSetOnEvent(-1,"PopulateLV") GUISetState() While 1 Sleep(100) WEnd Func PopulateLV() $aArrayCopy = $aArray If @GUI_CtrlId = 5 Then _ArrayReverse($aArrayCopy) _GUICtrlListView_DeleteAllItems($LV) For $i In $aArrayCopy GUICtrlCreateListViewItem($i,$LV) Next EndFunc - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar! Link to comment Share on other sites More sharing options...
P0ZiTR0N Posted April 18, 2009 Author Share Posted April 18, 2009 Yes.. it must be different strings, what should be read from ini. Your code with reversing first array with second is usefull but not for this project... ini consists from 2 parts: 1) [conf1] data1=x data2=y 2) [conf2] data3=a data4=b Thanx for code, if anyone has another idea, please write it Link to comment Share on other sites More sharing options...
andybiochem Posted April 18, 2009 Share Posted April 18, 2009 ok, wild-stab-in-the-dark number 2: expandcollapse popup#include <ListviewConstants.au3> #Include <GuiListView.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) Global $aArray GUICreate("",200,150) $LV = GUICtrlCreateListView("Items",10,10,120,120,-1,$LVS_EX_CHECKBOXES) GUICtrlCreateButton("Conf1",140,10,50,20) GUICtrlSetOnEvent(-1,"PopulateLV") GUICtrlCreateButton("Conf2",140,40,50,20) GUICtrlSetOnEvent(-1,"PopulateLV") GUISetState() While 1 Sleep(100) WEnd Func PopulateLV() ;----- Read different ini sections into array, depending on button pressed ----- Switch @GUI_CtrlId Case 4;Conf1 $aArray = IniReadSection("data.ini","conf1") Case 5;Conf2 $aArray = IniReadSection("data.ini","conf2") EndSwitch ;----- populate LV with ini values ----- For $i = 1 to UBound($aArray) - 1 GUICtrlCreateListViewItem($aArray[$i][1],$LV) Next EndFunc .... this one loads ini keys & values into the global array from "data.ini" from different sections depending on which button was pressed. Listview items are then created from the array. Any closer? - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar! Link to comment Share on other sites More sharing options...
P0ZiTR0N Posted April 18, 2009 Author Share Posted April 18, 2009 (edited) this is closer... works as my first try. But the same(old) problem - the list now adds itselfs... for example: input from conf1: [conf1] ID=000001 ID=000002 ID=000003 ID=000004 [conf2] ID=000005 ID=000006 ID=000007 ID=000008 After click - conf 2 button - it just adds after conf 1 and the same - if click 1 it adds after last clicked. Result of cross-clicking: 000001 000002 000003 000004 000005 000006 000007 000008 000001 000002 000003 000004 000001 000002 000003 000004 Same method (more harder then your) was done before in my project.. But I hope it may be the way to clear first list without deleting (for re-call it later if press button conf1) and creating new Edited April 18, 2009 by P0ZiTR0N Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 18, 2009 Moderators Share Posted April 18, 2009 (edited) this is closer... works as my first try. But the same(old) problem - the list now adds itselfs... for example: input from conf1: [conf1] ID=000001 ID=000002 ID=000003 ID=000004 [conf2] ID=000005 ID=000006 ID=000007 ID=000008 After click - conf 2 button - it just adds after conf 1 and the same - if click 1 it adds after last clicked. Result of cross-clicking: 000001 000002 000003 000004 000005 000006 000007 000008 000001 000002 000003 000004 000001 000002 000003 000004 Same method (more harder then your) was done before in my project.. But I hope it may be the way to clear first list without deleting (for re-call it later if press button conf1) and creating new Your description of what you need/want really suck. You should take more time trying to figure out how to explain yourself. And, I commend you on providing example code (that doesn't work at all , but it didn't explain your situation either). A stab in the dark as andybiochem did (there shouldn't have to be "stabs"):expandcollapse popup;~ #NoTrayIcon; When your submitting testing code, unless you know what you're doing, don't remove the tray icon! #include <GUIConstantsEx.au3> #include <GuiListView.au3> ; Don't add unnecessary includes to your test code #Region Global Data Global $s_data_ini = "data.ini" #Region Global Data #Region GUI Creation Global $h_main_gui = GUICreate("My GUI", 200, 200) Global $i_button_conf1 = GUICtrlCreateButton("Conf1", 120, 8, 80, 17) Global $i_button_conf2 = GUICtrlCreateButton("Conf2", 120, 24, 80, 17) ;~ Global $i_button_test = GUICtrlCreateButton("4Test", 40, 180, 60, 120); No idea what you're doing with this button Global $h_lv_main = _GUICtrlListView_Create($h_main_gui, "Items", 0, 8, 120, 120) _GUICtrlListView_SetExtendedListViewStyle($h_lv_main, $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($h_lv_main, 0, $LVSCW_AUTOSIZE_USEHEADER) #EndRegion GUI Creation GUISetState() While 1 Switch GUIGetMsg() Case -3 Exit Case $i_button_conf1 _conf_data($h_lv_main, $s_data_ini, "conf1") Case $i_button_conf2 _conf_data($h_lv_main, $s_data_ini, "conf2") EndSwitch WEnd Func _conf_data($h_lv, $s_ini, $s_section) Local $a_ini = IniReadSection($s_ini, $s_section) If @error Then Return SetError(1, 0, 0) _GUICtrlListView_BeginUpdate($h_lv) _GUICtrlListView_DeleteAllItems($h_lv) For $i = 1 To $a_ini[0][0] _GUICtrlListView_AddItem($h_lv, $a_ini[$i][1]) Next _GUICtrlListView_EndUpdate($h_lv) Return 1 EndFuncdata.ini contains the exact info you posted above[conf1] ID=000001 ID=000002 ID=000003 ID=000004 [conf2] ID=000005 ID=000006 ID=000007 ID=000008 Edited April 18, 2009 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
P0ZiTR0N Posted April 18, 2009 Author Share Posted April 18, 2009 Yes.. This is what I need, thanx. Sorry for my mistakes... I'll remember them for feature. Topic may be closed/killed Link to comment Share on other sites More sharing options...
andybiochem Posted April 18, 2009 Share Posted April 18, 2009 this is closer... works as my first try. But the same(old) problem - the list now adds itselfs... [.......] was done before in my project.. But I hope it may be the way to clear first list without deleting (for re-call it later if press button conf1) and creating new Oops, my bad.... forgot to clear the LV before re-populating. This is how it should look: expandcollapse popup#include <ListviewConstants.au3> #Include <GuiListView.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) Global $aArray GUICreate("",200,150) $LV = GUICtrlCreateListView("Items",10,10,120,120,-1,$LVS_EX_CHECKBOXES) GUICtrlCreateButton("Conf1",140,10,50,20) GUICtrlSetOnEvent(-1,"PopulateLV") GUICtrlCreateButton("Conf2",140,40,50,20) GUICtrlSetOnEvent(-1,"PopulateLV") GUISetState() While 1 Sleep(100) WEnd Func PopulateLV() ;----- Read different ini sections into array, depending on button pressed ----- Switch @GUI_CtrlId Case 4;Conf1 $aArray = IniReadSection("data.ini","conf1") Case 5;Conf2 $aArray = IniReadSection("data.ini","conf2") EndSwitch ;----- populate LV with ini values ----- _GUICtrlListView_DeleteAllItems($LV) For $i = 1 to UBound($aArray) - 1 GUICtrlCreateListViewItem($aArray[$i][1],$LV) Next EndFunc ...but if Smoke_N's code does the job, stick with that. - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar! 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