[RESOLVED] Listview flashing while updated
Hi,
I have a timer that changes the value of a listview subitem,costantly
While the update happends the listview flashed which is annoying..
What is interesting for me is that, while the update of the listview is happening i can resize the Form and while resizing the form the listview does not flash :confused: :sick:
My question would be, is there a way to fix that so i dont have the listview flashing while the form si not being resized?
I tried the lock api but that didnt work.
Cheers!
Re: Listview flashing while updated
It shouldn't flash unless you use ListView1.Refresh method.
Re: Listview flashing while updated
the list itself does not flash...it's the column headers mostly...
i dont have the refresh method in the code ...
still, while i resize the form the listview does not flash a bit :/ straange
thanks for replying :)
Re: Listview flashing while updated
I noticed that listview would flash if form's AutoRedraw = True. Check that and turn it off if it's on.
Re: Listview flashing while updated
My AutoRedraw is set to False
I still dont know what do to, maybe a sub to make constant minor form resizing ?
Re: Listview flashing while updated
You did mention that you tried using Lock (as you said) api but it didn't help.
I tried running this quick sample and there was not a single flash so create new project and run this:
Code:
Option Explicit
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Sub Form_Load()
Me.AutoRedraw = False
'add column headers here
ListView1.ListItems.Add , , "Item1"
ListView1.ListItems.Add , , "Item2"
ListView1.ListItems.Add , , "Item3"
End Sub
Private Sub Command1_Click()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
Static i As Long
LockWindowUpdate ListView1.hWnd
i = i + 1
ListView1.ListItems(2).SubItems(1) = "Value " & i
LockWindowUpdate False
End Sub
Re: Listview flashing while updated
the flashing seems to be gone, but if you put the timer interval as 10 or 5 the flashing comes out again....
i work with very very small intervals....
my hopes start to fade away :(
RhinoBull ,i really appreciate your work here.
Re: Listview flashing while updated
Utilizing Before/AfterLabelUpdate and Sleep api makes it less flickering. Give it the try:
Code:
Option Explicit
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
Me.AutoRedraw = False
'add column headers here
ListView1.ListItems.Add , , "Item1"
ListView1.ListItems.Add , , "Item2"
ListView1.ListItems.Add , , "Item3"
End Sub
Private Sub Command1_Click()
Timer1.Interval = 10
End Sub
Private Sub ListView1_AfterLabelEdit(Cancel As Integer, NewString As String)
LockWindowUpdate False
End Sub
Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)
LockWindowUpdate ListView1.hWnd
End Sub
Private Sub Timer1_Timer()
Static i As Long
LockWindowUpdate ListView1.hWnd
i = i + 1
ListView1.ListItems(2).SubItems(1) = "Value " & i
Sleep 10
LockWindowUpdate False
End Sub
Re: Listview flashing while updated
Thanks man, it did really help alot!!
Thanks again for your kind help.
Rated :)))
Re: [RESOLVED] Listview flashing while updated
Alright, sounds better this time... :afrog: