Results 1 to 10 of 10

Thread: [RESOLVED] Listview flashing while updated

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Resolved [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

    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!
    Thanks for helping me out.

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    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
    Thanks for helping me out.

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    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 ?
    Thanks for helping me out.

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    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.
    Thanks for helping me out.

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: Listview flashing while updated

    Thanks man, it did really help alot!!

    Thanks again for your kind help.


    Rated ))
    Thanks for helping me out.

  10. #10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width