civilcalc Posted December 23, 2011 Share Posted December 23, 2011 (edited) Ok, so I have a GUI, and it processes some basic calculations.The history of these calculations is currently stored in a list box like the image below (the large bottom left box)I would like it so the common data, next to STN data is not repeated, so its more clear which data is in the correct 'group'.does anyone have an easy way of formatting this, so it looks correct? Like thisOr should I be doing it another way?Many thanks in advance, and merry Christmas :-)I thought about a listview item, but I always have issues with column widths etc. Edited December 23, 2011 by civilcalc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 23, 2011 Moderators Share Posted December 23, 2011 civilcalc,Can you please post some code - specifically the code which formats the text that will be sent to the ListBox and that which actually sends it. My initial thoughts are that you store the "STN..." text in a variable and then use code to remove it from subsequent lines until it changes. But without sight of the code I can offer nothing more concrete. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
civilcalc Posted December 23, 2011 Author Share Posted December 23, 2011 Melba, bare with my on this one, things are clear in my head, but are often hard to convey. First the graph has its own array; $baby1_grapharray 0-100.000-100.000 1-200.000-200.000 Which stores the output, if line 0 is unchanged, ie the same station, the array is re-dimmed and the new target is added; $baby1_grapharray 0-100.000-100.000 1-200.000-200.000 3-300.000-300.000 If line 0 has changed a new array is created; $baby1_grapharray 0-200.000-200.000 1-300.000-300.000 using this code $stationeast = GUICtrlRead($stn_e) $stationnorth = GUICtrlRead($stn_n) $targeteast = GUICtrlRead($trg_e) $targetnorth = GUICtrlRead($trg_n) If $grapharray[0][0] = $stationeast And $grapharray[0][1] = $stationnorth Then $count = UBound($grapharray) ReDim $grapharray[$count+1][2] $grapharray[$count][0] = $targeteast $grapharray[$count][1] = $targetnorth Else Dim $grapharray[2][2] $grapharray[0][0] = $stationeast $grapharray[0][1] = $stationnorth $grapharray[1][0] = $targeteast $grapharray[1][1] = $targetnorth EndIf The graph is drawn, like in the pictures, I wont put the code here, as its massive. Then the history is updated using this code; $leftupdate = "STN "&Guictrlread($baby1_1)&","&Guictrlread($baby1_2) $midupdate = " --- WCB "&GUICtrlRead($baby1_3) $rightupdate = " --- DIST "&GUICtrlRead($baby1_4) If UBound($baby1_grapharray) < 3 Then GUICtrlSetData($baby1_history,$leftupdate&$midupdate&$rightupdate) Else $leftupdate = " " GUICtrlSetData($baby1_history,$leftupdate&$midupdate&$rightupdate) EndIf The else statement basically says if there are more than 1 target(s) in the array, replace the 'leftupdate' with a blank string. I know I can get this string length to match the original string length, and I know I can format the mid and right updates to align correctly, but the blank string is causing the update to appear out sync with the station it is associated with. The future of this the onevent triggered when the user click the line in the history, using this function; Func _baby1_history() $item = _GUICtrlListBox_GetCurSel($baby1_history) $text = _GUICtrlListBox_GetText($baby1_history,$item) $text = StringReplace($text,"STN ","") $text = StringReplace($text," --- WCB ",",") $text = StringReplace($text," --- DIST ",",") $string = StringSplit($text,",") GUICtrlSetData($baby1_1,$string[1]) GUICtrlSetData($baby1_2,$string[2]) GUICtrlSetData($baby1_3,$string[3]) GUICtrlSetData($baby1_4,$string[4]) baby1calc() EndFunc Basically allowing the user to 'replay' an older calculation. Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 23, 2011 Moderators Share Posted December 23, 2011 civilcalc, Sorry, this will have to wait until tomorrow - it has been a long day. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
civilcalc Posted December 23, 2011 Author Share Posted December 23, 2011 civilcalc,Sorry, this will have to wait until tomorrow - it has been a long day. M23No problem, ive been working on this for a looong time anyway. Thanks :-) Link to comment Share on other sites More sharing options...
Zedna Posted December 25, 2011 Share Posted December 25, 2011 (edited) $leftupdate = "STN "&Guictrlread($baby1_1)&","&Guictrlread($baby1_2) $midupdate = " --- WCB "&GUICtrlRead($baby1_3) $rightupdate = " --- DIST "&GUICtrlRead($baby1_4) If UBound($baby1_grapharray) < 3 Then GUICtrlSetData($baby1_history,$leftupdate&$midupdate&$rightupdate) Else $leftupdate = " " GUICtrlSetData($baby1_history,$leftupdate&$midupdate&$rightupdate) EndIf Global $leftupdate_prev = '' Global $leftupdate_empty = _StringRepeat(' ',19) ... $leftupdate = "STN "&Guictrlread($baby1_1)&","&Guictrlread($baby1_2) If $leftupdate <> $leftupdate_prev Then $leftupdate_prev = $leftupdate Else $leftupdate = $leftupdate_empty EndIf $midupdate = " --- WCB "&GUICtrlRead($baby1_3) $rightupdate = " --- DIST "&GUICtrlRead($baby1_4) If UBound($baby1_grapharray) < 3 Then GUICtrlSetData($baby1_history,$leftupdate&$midupdate&$rightupdate) Else $leftupdate = " " GUICtrlSetData($baby1_history,$leftupdate&$midupdate&$rightupdate) EndIf EDIT: If you want help with listview column widths then don't hesitate to ask istview is much better for this purpose than listbox Edited December 26, 2011 by Zedna civilcalc 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
civilcalc Posted December 26, 2011 Author Share Posted December 26, 2011 If you want help with listview column widths then don't hesitate to askistview is much better for this purpose than listboxZenda, yes please! Ideally what I am looking for is the station in the left column only on the first line, any repeats of this station will add the 'targets' underneath it (like in the photo-shopped second photo), the user can then click on any of the targets to 'replay' the calculation. I am not sure if the widths of the columns in a listview box can be locked in some way? I am hoping you are a listview expert Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 26, 2011 Moderators Share Posted December 26, 2011 civilcalc,Sorry I did not get back to you - Christmas got in the way. I agrer with Zedna that ListViews are much better suited to your purpose. To set the widths of the columns you can use (unsurprisingly) _GUICtrlListView_SetColumnWidth. Locking the column widths and detecting clicks on the subitems is done like this:expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> $hGui = GUICreate("Test", 250, 250) $hListView = GUICtrlCreateListView("Column 1|Column 2|Column 3", 10, 10, 230, 160) For $i = 1 To 6 GUICtrlCreateListViewItem("Item " & $i & "1|Item " & $i & "2|Item " & $i & "3", $hListView) Next $hButton = GUICtrlCreateButton("Lock Columns", 75, 200, 100, 30) GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton Switch GUICtrlRead($hButton) Case "Lock Columns" GUICtrlSetData($hButton, "Unlock Columns") ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView))) ; Lock listview header Case "Unlock Columns" GUICtrlSetData($hButton, "Lock Columns") ControlEnable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView))) ; Unlock listview header EndSwitch EndSwitch WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tStruct = DllStructCreate($tagNMLISTVIEW, $lParam) If @error Then Return Switch DllStructGetData($tStruct, 3) Case $NM_DBLCLK ; Look for the double click ConsoleWrite("Row: " & DllStructGetData($tStruct, "Item") + 1 & " - Col: " &DllStructGetData($tStruct, "SubItem") + 1 & @CRLF) EndSwitch EndFunc ;==>On_WM_NOTIFYI hope that makes up for my tardiness. All clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
civilcalc Posted December 27, 2011 Author Share Posted December 27, 2011 Melba,No worries about Christmas, hope you had a good one.I had seen the _GUICtrlListView_SetColumnWidth function, but with not being able to lock them, I didnt bother to use it.I can see how it works, but I dont think I could ever have figured that out.I am thinking of also writing the data to an .ini file so each section will be under the station data, and each target data will be stored as a 'key'. I think I can then retrieve the data better to re-draw the graph, what do you think?Civilcalc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 27, 2011 Moderators Share Posted December 27, 2011 civilcalc,Sounds like a reasonable plan, but remember that ini files are limited to 64k in size using the normal Ini* functions, with a section limited to 32k. I have no idea of the size of your stored data, but that is worth bearing in mind. There is a UDF out there which can deal with ini files over this size, but I have never used it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
civilcalc Posted December 27, 2011 Author Share Posted December 27, 2011 (edited) civilcalc,Sounds like a reasonable plan, but remember that ini files are limited to 64k in size using the normal Ini* functions, with a section limited to 32k. I have no idea of the size of your stored data, but that is worth bearing in mind. There is a UDF out there which can deal with ini files over this size, but I have never used it. M23Ah, I didnt know that. Any idea how many characters 32k is? I could create an ini file for each station I guess, I am not sure if I want to save the data after the user has closed the main GUI, as I couldnt see any need to re-use the data after I have closed the GUI, but I what I want/do is not what someone else might want to do. Failing that maybe a giant array.ThanksEDIT Melba, is this function you made, is it possible to use it with oneventmode 1 ?The listview is looking pretty funky by the way Ok, I figured it out, I added two replay and delete buttons under the graph for the user to click. Edited December 27, 2011 by civilcalc 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