Sign in to follow this  
Followers 0
czardas

$LVS_EX_DOUBLEBUFFER causes freeze

11 posts in this topic

#1 ·  Posted (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.

#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 by czardas

Share this post


Link to post
Share on other sites



#4 ·  Posted (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 by czardas

Share this post


Link to post
Share on other sites

#6 ·  Posted (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. :graduated:

#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 by czardas

Share this post


Link to post
Share on other sites

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! :graduated:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (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. :graduated:

#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 by czardas

Share this post


Link to post
Share on other sites

czardas,

You might want to take a look here. :graduated:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

You beat me to it Melba23!


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Nice example Guiness. :graduated:

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 by czardas

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0