czardas Posted October 15, 2011 Share Posted October 15, 2011 (edited) Is this a bug? Caution don't run this if you don't know what you are doing. Run the script, preferably in SciTE, and select an item in the ListView control. Now we can cause the to GUI freeze by pressing the TAB key. Since the GUI stops responding I figured it must be a bug. expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> _Run() Func _Run() Local $sFont = "MS Sans Serif", $iFontSize = 10, $iFontWeight = 500, $iWidthRatio = .9, $iHeightRatio = .8, _ $bLV_BKColor = 0xFFFFCC Local $iWidth = @DesktopWidth*$iWidthRatio, $iHeight = @DesktopHeight*$iHeightRatio, _ $bStyle = BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX) Local $hGUI = GUICreate(" Test", $iWidth, $iHeight, Default, Default, $bStyle) Local $sHeadings = "Col 1|Col 2|Col 3|Col 4|Col 5|Col 6|Col 7" $hListView = GUICtrlCreateListView($sHeadings, 0, 0, $iWidth, $iHeight -20, _ BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) GUICtrlSetBkColor($hListView, $bLV_BKColor) GUICtrlSetFont($hListView, $iFontSize, $iFontWeight, Default, $sFont) _SetColWidth($hListView, $iWidth/7) _SetData($hListView) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $GUI_EVENT_MAXIMIZE Then _SetColWidth($hListView, @DesktopWidth/7) If $msg = $GUI_EVENT_RESTORE Then _SetColWidth($hListView, $iWidth/7) WEnd EndFunc Func _SetData($hListView) For $i = 0 To 1000 GUICtrlCreateListViewItem( _ Random(0 ,1000000, 1) &"|"& _ Random(0 ,1000000, 1) &"|"& _ Random(0 ,1000000, 1) &"|"& _ Random(0 ,1000000, 1) &"|"& _ Random(0 ,1000000, 1) &"|"& _ Random(0 ,1000000, 1) &"|"& _ Random(0 ,1000000, 1) , $hListView) Next EndFunc Func _SetColWidth($hListView, $iWidth) For $i = 0 To 6 _GUICtrlListView_SetColumnWidth($hListView, $i, $iWidth -3) Next EndFunc Removing $LVS_EX_DOUBLEBUFFER resolves the issue. I thought I'd take a look to see what it does, but the help file doesn't give any information. $LVS_EX_DOUBLEBUFFER was left over from an earlier edit using an example from the help file => _GUICtrlListView_SortItems. I don't need it afaict. I'm curious why it has no description. Edited October 16, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted October 16, 2011 Author Share Posted October 16, 2011 >>> Please could someone confirm this. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted October 16, 2011 Share Posted October 16, 2011 It certainly does freeze with that const in, but I have no idea why, is it not something to do with stopping gui flicker? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted October 16, 2011 Author Share Posted October 16, 2011 (edited) I don't know. I guess it's one of those MS options that they never bothered to give a description for. Maybe I'm wrong. I also suspect that another control added to the GUI may stop it from freezing. However, I think I ought to report it as a bug. Thanks JoneOne. Edited October 16, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted October 16, 2011 Share Posted October 16, 2011 Have you seen by M23? In it he uses some setextendedlistviwestyle func, and I think he explains why in his wiki entry. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted October 16, 2011 Author Share Posted October 16, 2011 (edited) Thanks for the link. When I use _GUICtrlListView_SetExtendedListViewStyle it seems to fix the issue. I don't know why that would be. But if I set $LVS_EX_DOUBLEBUFFER as a parameter for the function GUICtrlCreateListView, it breaks. #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> _Run() Func _Run() ;$bStyle = BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX) Local $hGUI = GUICreate(" Test", 400, 300) Local $sHeadings = "Col 1|Col 2|Col 3" $hListView = GUICtrlCreateListView($sHeadings, 0, 0, 400, 300) _GUICtrlListView_SetExtendedListViewStyle($hListView, _ BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) _SetData($hListView) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc Func _SetData($hListView) For $i = 0 To 3 GUICtrlCreateListViewItem( _ Random(0 ,1000000, 1) &"|"& _ Random(0 ,1000000, 1) &"|"& _ Random(0 ,1000000, 1) , $hListView) Next EndFunc I think I'll wait a while to see if someone else can shed some light on this. Edited October 16, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 16, 2011 Moderators Share Posted October 16, 2011 czardas, It seems that some of the $LVS_EX_* styles have the same numerical values as certain $WS_EX_* styles. When you use the $LVS_EX_* styles in the ListView creation line as extended styles, they are interpreted as the $WS_EX_* styles - you need to use _GUICtrlListView_SetExtendedListViewStyle function to get them accepted as the $LVS_EX_* styles. So I imagine you were trying to set some unsupported extended style value which froze the GUI. Top tip: Only ever set $LVS_EX_* styles using the UDF function - leave the ListView creation line to the $WS_EX_* ones! 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...
czardas Posted October 17, 2011 Author Share Posted October 17, 2011 (edited) Thanks for the tip Melba23. I'm currently just trying out different ideas. There are so many ListView functions that seem to work differently than expected and I find that somewhat confusing, and also a little overwhelming. I'm currently writing some custom functions to hopefully make life a little easier, but it's slow progress. I understand arrays, so this is what I have so far. #include <GuiListView.au3> Func _ListViewToArray($hListView) Local $iCols = _GUICtrlListView_GetColumnCount($hListView), _ $iRows = _GUICtrlListView_GetItemCount($hListView) Local $aLVData[$iRows][$iCols] For $i = 0 To $iRows -1 For $j = 0 To $iCols -1 $aLVData[$i][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) Next Next ;_ArrayDisplay($aLVData) Return $aLVData EndFunc Edited October 17, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 17, 2011 Moderators Share Posted October 17, 2011 czardas, You might want to take a look here. 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...
guinness Posted October 17, 2011 Share Posted October 17, 2011 You beat me to it Melba23! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
czardas Posted October 17, 2011 Author Share Posted October 17, 2011 (edited) Nice example Guiness. Okay I'm digressing a little, but I think I'm making progress. After trying out a few examples in the help file I got totally confused: I felt a little dumbstruck when _GUICtrlListView_SetColumnOrder just changed the column headers. Then after looking a little deeper I realized that it is only the display that changes, so saving the changes will also involve saving additional information about the display order, and that's something I wish to avoid for a reason. I personally think the end user will feel more at ease with just swapping the positions of two columns.at a time, rather than messing around with delimited strings. Now I have three custom functions I can understand. ; Swap two columns in a ListView control Func _LVCols_Swap($hListView, $iCol1, $iCol2) Local $sTemp, $aLVData = _GUICtrlListView_GetColumn($hListView, $iCol1) $sTemp = $aLVData[5] $aLVData = _GUICtrlListView_GetColumn($hListView, $iCol2) _GUICtrlListView_SetColumn($hListView, $iCol2, $sTemp) _GUICtrlListView_SetColumn($hListView, $iCol1, $aLVData[5]) Local $iRows = _GUICtrlListView_GetItemCount($hListView) For $i = 0 To $iRows $sTemp = _GUICtrlListView_GetItemText($hListView, $i, $iCol1) _GUICtrlListView_SetItemText($hListView, $i, _ _GUICtrlListView_GetItemText($hListView, $i, $iCol2), $iCol1) _GUICtrlListView_SetItemText($hListView, $i, $sTemp, $iCol2) Next EndFunc ;==> _LVCols_Swap ; Justifies column width according to the width of the ListView control... 2nd Param ... $iWidth ; Avoids horizontal scroll bar appearing - Needs further testing Func _LVCols_Justify($hListView, $iWidth) Local $iCols = _GUICtrlListView_GetColumnCount($hListView) $iWidth = Floor($iWidth/$iCols) Local $iReserve = 0 ; Reserved area for vertical scroll bar Do $iReserve += 1 Until $iReserve*$iCols > 20 For $i = 0 To $iCols -1 _GUICtrlListView_SetColumnWidth($hListView, $i, $iWidth - $iReserve) Next EndFunc ;==> _LVCols_Justify Edited October 17, 2011 by czardas operator64 ArrayWorkshop 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