Jump to content

Refreshing Data in ListView - Flickering !


ptrex
 Share

Recommended Posts

When loading data in a ListView, the screen flickers like hell, when loading and refreshing.

Especialy when loading a few thousand lines.

Is there a solution for it, like should I buld in a sleep() somewhere to prevent this.

Or is the a kind of refreshrate which can be set, to get rid of the annoynig flickering if the ListView on the GUI.

Link to comment
Share on other sites

put the lock at the top of the function and unlock at the bottom

Func _ReduceMemory()
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    Return $ai_Return[0]
EndFunc  ;==>_ReduceMemory

Func _LockAndWait()
    GUISetState(@SW_LOCK)
    GUISetCursor(15, 1)
EndFunc  ;==>_LockAndWait

Func _ResetLockWait()
    GUISetState(@SW_UNLOCK)
    GUISetCursor(2, 1)
    _ReduceMemory()
EndFunc  ;==>_ResetLockWait
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

@gafrost

Againg a hit !!

I installed the function and it runs like a charm.

The more I start using AutoIT the more I realize what is possible, and how litle I know.

Is this also not a good suggestion to have this as a kind of parameter, build into the ListView control,

to set the LOCK on or off.

Just a thought.

Edited by ptrex
Link to comment
Share on other sites

put the lock at the top of the function and unlock at the bottom

Func _ReduceMemory()
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    Return $ai_Return[0]
EndFunc  ;==>_ReduceMemory

Func _LockAndWait()
    GUISetState(@SW_LOCK)
    GUISetCursor(15, 1)
EndFunc  ;==>_LockAndWait

Func _ResetLockWait()
    GUISetState(@SW_UNLOCK)
    GUISetCursor(2, 1)
    _ReduceMemory()
EndFunc  ;==>_ResetLockWait
Curiosity,

Why _ReduceMemory is needed? B)

Link to comment
Share on other sites

put the lock at the top of the function and unlock at the bottom

Func _ReduceMemory()
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    Return $ai_Return[0]
EndFunc  ;==>_ReduceMemory

Func _LockAndWait()
    GUISetState(@SW_LOCK)
    GUISetCursor(15, 1)
EndFunc  ;==>_LockAndWait

Func _ResetLockWait()
    GUISetState(@SW_UNLOCK)
    GUISetCursor(2, 1)
    _ReduceMemory()
EndFunc  ;==>_ResetLockWait
I have a ListView that flickers too, so the functions above looked good to me. When I put them in, the ListView quit working I comment them and it works.

Would you look at my code below and point out the cause if it is there, it's not the whole script, just the UDF where i build the listView.

Func _LockAndWait()
 GUISetState(@SW_LOCK)
 GUISetCursor(15, 1)
EndFunc ;==>_LockAndWait


Func _ResetLockWait()
 GUISetState(@SW_UNLOCK)
 GUISetCursor(2, 1)
EndFunc ;==>_ResetLockWait


Func _BuildListView()
 _LockAndWait()
 $listview = GUICtrlCreateListView("Name|Activity|Trial|Time", 8, 75, 250, 270, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTASCENDING))
 $sListData = ""
 $sListName = ""
 $sListName = $sCurrName
 $aVar1 = IniReadSectionNames($sDataPath & $sListName & ".ini")
 For $i1 = 1 To $aVar1[0]
  If $aVar1[$i1] <> "Name" And $aVar1[$i1] <> "Style_Location" And $aVar1[$i1] <> "DefaultActivity" And $aVar1[0] > 3 Then
   $sActivity = $aVar1[$i1] & "|"
   
   $aVar2 = IniReadSection($sDataPath & $sListName & ".ini", $aVar1[$i1])
  ;MsgBox(0,"Information 537","$aVar1[$i] " & $aVar1[$i1] & "  -  " & $i1)
   If @error Then
    MsgBox(4096, "Error 1417", "Error occured, unable to read the section (The INI file may not exist or the section may not exist) or if the section was empty, or no standard format data could be found.")
   Else
    If $aVar2[0][0] > 1 Then
     For $i2 = 1 To $aVar2[0][0]
     ;MsgBox(0,"Information 543","$aVar2[$i2] " & $aVar2[$i2][0] & "  -  " & $i2)
      If StringLeft($aVar2[$i2][0], 7) <> "Trial00" Then
       $sListData = $sListName & "|" & $sActivity & StringRight($aVar2[$i2][0], 2) & "|" & StringLeft($aVar2[$i2][1], 6)
       GUICtrlCreateListViewItem($sListData, $listview)
      ;MsgBox(4096, "Information 547", "$sListData: " & $sListData)
       $sListData = ""
      EndIf
     Next
    EndIf
   EndIf
  ElseIf $aVar1[0] = 3 Then
   GUICtrlCreateListViewItem(" | | | ", $listview)
  EndIf
 ;MsgBox(4096, "", $aVar1[$i])
 Next
 _ResetLockWait()
EndFunc;==>_BuildListView

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Link to comment
Share on other sites

Quick Question...

Is there any way this could work to freeze the desktop? I have a couple scripts that would be great to run without the user seeing some obnoxious windows opening/closing.

Mike

I am not sure. the function is intended for only one window of any running application

It is reset by any other call to this lock mechanism. So if any application do the same it will unlock your's

Link to comment
Share on other sites

Hi,

@Gene,

Can you post a small script as example which calls your funcs (the I can run your funcs and watch for errors?)

Best, Randall

I'm using ListView in only one script, it is 1500+ lines, and would still require some appropriate INI files.

Of the functions in my post, only _BuildListView() is mine, I copied the other two {lock & unlock} from a previous post by gafrost.

_BuildListView() is self contained except for the $sCurrName var which is Global. _BuildListView() works except when I include the lock and unlock functions. Since the ListView is built by getting the appropriate section names from $sCurrName & ".INI" file, then gets the keys, then writes the List Items, I'm not surprised at a little flicker. If it could be gotten rid of easily that would be good.

I could cobble up a small script like you mention, but since _BuildListView() works on its own, I don't think that would be very useful.

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...