MyEarth Posted October 24, 2016 Share Posted October 24, 2016 (edited) Hi, Short story. A listview with column, 01234. The user have the possibility to hide 234. The problem is when a column is hidden the resizing of other column, with mouse i mean, is a problem. Anyway, my idea was move the hidden column at the start, so: Assuming the initial situation is 01234 User hide column 2, the expected result is 20134 If user hide column 234, the expected result is 23401 If user hide column 3, the expected result is 30124 And so on. I have make a 2D for store the column index and the state ( 1 visible, 0 hidden ) and i need to convert it in 1D array with the expected result for passing to the Listview UDF. Please avoid all the _Array* function for a task like this is a so small array, thanks. My wrong attempt: #include <Array.au3> Local $iCol2 = 1 Local $iCol3 = 0 Local $iCol4 = 1 Local $aResult[5][2] = [[0, 1],[1, 1],[2, $iCol2],[3, $iCol3],[4, $iCol4]] Local $aFinal[5], $iIndexInc = 0, $iIndexDec = 4 _ArrayDisplay($aResult) For $i = 0 To UBound($aResult) - 1 If $aResult[$i][1] = 1 Then $aFinal[$iIndexInc] = $aResult[$i][0] $iIndexInc += 1 ElseIf $aResult[$i][1] = 0 Then $aFinal[$iIndexDec] = $aResult[$i][0] $iIndexDec -= 1 EndIf Next _ArrayDisplay($aFinal) Edited October 24, 2016 by MyEarth Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 24, 2016 Moderators Share Posted October 24, 2016 MyEarth, Sounds complex. Why not just prevent the hidden columns from being resized? expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $hGUI = GUICreate("Test", 500, 500) $cListView = GUICtrlCreateListView("Column 0|Column 1|Column 2|Column 3|Column 4", 10, 10, 420, 250) For $i = 1 To 10 $sData = "" For $j = 0 To 4 $sData &= Random(0, 10, 1) & "|" Next GUICtrlCreateListViewItem(StringTrimRight($sData, 1), $cListView) Next $cStart = GUICtrlCreateDummy() + 1 For $i = 0 To 4 GUICtrlCreateCheckbox(" Col " & $i, 10, 300 + (20 * $i), 200, 20) GUICtrlSetState(-1, $GUI_CHECKED) Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case Else ; Check if a checkbox was actioned For $i = 0 To 4 If $iMsg = $cStart + $i Then ; if it was then adjust the column width accordingly If GUICtrlRead($iMsg) = $GUI_CHECKED Then _GUICtrlListView_SetColumnWidth($cListView, $i, 80) Else _GUICtrlListView_SetColumnWidth($cListView, $i, 0) EndIf ExitLoop EndIf Next EndSwitch WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Get details of message Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) Local $iCode = BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) ; Look for header resize code Switch $iCode Case $HDN_BEGINTRACKW ; Get column Local $iCol = DllStructGetData($tStruct, 4) ; Prevent resizing if column invisible If GUICtrlRead($cStart + $iCol) = $GUI_UNCHECKED Then Return True EndIf EndSwitch EndFunc 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...
MyEarth Posted October 24, 2016 Author Share Posted October 24, 2016 (edited) I have already prevent the hidden column to be resized but the mouse "cursor" remids the column is there, with 0 width, also if you can't resize it. If i move it to the start, this problem doesn't exist anymore. Another attempt: EDIT: Done #include <Array.au3> Local $iCol2 = 0 Local $iCol3 = 1 Local $iCol4 = 0 Local $aResult[5][2] = [[0, 1],[1, 1],[2, $iCol2],[3, $iCol3],[4, $iCol4]] Local $aFinal[5], $iIndex = 0 _ArrayDisplay($aResult) For $i = 0 To UBound($aResult) - 1 If $aResult[$i][1] = 0 Then $aFinal[$iIndex] = $aResult[$i][0] $aResult[$i][0] = -1 $iIndex += 1 EndIf Next For $j = 0 To UBound($aResult) - 1 If $aResult[$j][0] <> -1 Then $aFinal[$iIndex] = $aResult[$j][0] $iIndex += 1 EndIf Next _ArrayDisplay($aFinal) Edited October 24, 2016 by MyEarth Link to comment Share on other sites More sharing options...
Gianni Posted October 24, 2016 Share Posted October 24, 2016 #include <Array.au3> Local $iCol2 = 0 Local $iCol3 = 1 Local $iCol4 = 0 Local $aResult[5][2] = [[0, 1],[1, 1],[2, $iCol2],[3, $iCol3],[4, $iCol4]] Local $iNrRow = UBound($aResult) Local $aFinal[$iNrRow] Local $aStacks[$iNrRow + 1][2] ; temporary array _ArrayDisplay($aResult) For $i = 0 To $iNrRow - 1 ; separates visible and hidden columns $aStacks[$aStacks[$iNrRow][$aResult[$i][1]]][$aResult[$i][1]] = $i $aStacks[$iNrRow][$aResult[$i][1]] += 1 Next ; _ArrayDisplay($aStacks) Local $iNDX = 0 ; merge again colums appending first hidden then visible For $x = 0 To 1 For $i = 1 To $aStacks[$iNrRow][$x] $aFinal[$iNDX] = $aStacks[$i - 1][$x] $iNDX += 1 Next Next _ArrayDisplay($aFinal) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... 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