Jump to content
Sign in to follow this  
qsek

_GUICtrlListview_DeleteAllItems Flicker

Recommended Posts

qsek

Ok, im done with my wisdom and need some serious help.

I cant get the Listview to not change when using _GUICtrlListview_DeleteAllItems.

It seems that the LVM_DELETEALLITEMS Message will fire WM_PAINT, WM_NCPAINT and WM_ERASEBKGND regardless of what i have tried below.

If you look at the code you will see what conditions i have. I cant put the timeintensive anywhere else, they have to be done after deleting the old list.

I read this guide http://www.catch22.net/tuts/flicker and tried $LVS_EX_DOUBLEBUFFER, setting $WM_ERASEBKGND 's return to 1.

Also i searched for several functions to avoid flickering. You see them commented out and can try them to see the different results.

Please notice that using @SW_LOCK is not an option to me casue then after each update my whole GUI will flicker.

This is just an example GUI, the real one has much more Controls which will definitely flicker if @SW_LOCK is used)

Press the "End" key to refresh the List

#include <GuiConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Include <SendMessage.au3>

Opt("GUIOnEventMode",1)
HotKeySet("{End}", "Refresh")

$Gui = GUICreate("TestGUI", 416, 416, 191, 113,BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION))

$Guiplist1 = GUICtrlCreateListView("Name", 8, 8, 200, 400, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT,$LVS_EX_GRIDLINES,$LVS_EX_DOUBLEBUFFER))
_GUICTRLLISTVIEW_SETCOLUMNWIDTH(-1, 0, $LVSCW_AUTOSIZE_USEHEADER)
$Guiplist2 = GUICtrlCreateListView("Name", 208, 8, 200, 400, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT,$LVS_EX_GRIDLINES,$LVS_EX_DOUBLEBUFFER))
_GUICTRLLISTVIEW_SETCOLUMNWIDTH(-1, 0, $LVSCW_AUTOSIZE_USEHEADER)

For $i = 1 To 10
    _GUICtrlListView_InsertItem($Guiplist1, "Result of time intensive Functions "&$i)
next
        
GUISetOnEvent($GUI_EVENT_CLOSE, "Exitf")
GUISetState()

While 1
    Sleep(10)
WEnd

Exit
Func Refresh()
;~  _WinAPI_InvalidateRect(GUICtrlGetHandle($Guiplist1), 0, False)



;~  GUISetState(@SW_LOCK,$GUI)
;~          _SendMessage(GUICtrlGetHandle($Guiplist1),$WM_SETREDRAW,0,0)
;~              GUICtrlSetState($Guiplist1,$GUI_DISABLE)
;~                  _GUICtrlListView_BeginUpdate(GUICtrlGetHandle($Guiplist1))
    
;~                  GUIRegisterMsg($WM_ERASEBKGND,"NoEraseBkgnd")
                    GUIRegisterMsg($WM_NCPAINT,"NoEraseBkgnd")
;~                  GUIRegisterMsg($WM_NOTIFY,"NoEraseBkgnd")
    

    _GUICtrlListView_DeleteAllItems (GUICtrlGetHandle($Guiplist1))

    Sleep(500) ; this represents some time intensive functions
    For $i = 1 To 10
        Sleep(50) ; this represents some time intensive functions
        _GUICtrlListView_InsertItem($Guiplist1, "Result of time intensive Functions "&$i,-1,-1,Random(0,100,1))
    next
    
                    GUIRegisterMsg($WM_ERASEBKGND,"")
;~                  GUIRegisterMsg($WM_NCPAINT, "")
;~                  GUIRegisterMsg($WM_NOTIFY, "")

;~                  _GUICtrlListView_EndUpdate(GUICtrlGetHandle($Guiplist1))
;~              GUICtrlSetState($Guiplist1,$GUI_ENABLE)
;~          _SendMessage(GUICtrlGetHandle($Guiplist1),$WM_SETREDRAW,1,0)
;~  GUISetState(@SW_UNLOCK,$GUI)

EndFunc

Func NoEraseBkgnd()
    Return 1
EndFunc

Func Exitf()
    Exit
EndFunc

Any MSDN Guru has an idea?

PS: I set the lparam to a random value on purpose. Im using the parameter for a custom index.

Edited by qsek

Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites
Achilles

I see your code has begin update and end update... why don't you use them?

#include <GuiConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Include <SendMessage.au3>

Opt("GUIOnEventMode",1)
HotKeySet("{End}", "Refresh")

$Gui = GUICreate("TestGUI", 416, 416, 191, 113,BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION))

$Guiplist1 = GUICtrlCreateListView("Name", 8, 8, 200, 400, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT,$LVS_EX_GRIDLINES,$LVS_EX_DOUBLEBUFFER))
_GUICTRLLISTVIEW_SETCOLUMNWIDTH(-1, 0, $LVSCW_AUTOSIZE_USEHEADER)
$Guiplist2 = GUICtrlCreateListView("Name", 208, 8, 200, 400, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT,$LVS_EX_GRIDLINES,$LVS_EX_DOUBLEBUFFER))
_GUICTRLLISTVIEW_SETCOLUMNWIDTH(-1, 0, $LVSCW_AUTOSIZE_USEHEADER)

For $i = 1 To 10
    _GUICtrlListView_InsertItem($Guiplist1, "Result of time intensive Functions "&$i)
next
       
GUISetOnEvent($GUI_EVENT_CLOSE, "Exitf")
GUISetState()

While 1
    Sleep(10)
WEnd

Exit
Func Refresh()
;~  _WinAPI_InvalidateRect(GUICtrlGetHandle($Guiplist1), 0, False)



;~  GUISetState(@SW_LOCK,$GUI)
;~  _SendMessage(GUICtrlGetHandle($Guiplist1),$WM_SETREDRAW,0,0)
;~   GUICtrlSetState($Guiplist1,$GUI_DISABLE)
     _GUICtrlListView_BeginUpdate(GUICtrlGetHandle($Guiplist1))
   
;~                GUIRegisterMsg($WM_ERASEBKGND,"NoEraseBkgnd")
;~                   GUIRegisterMsg($WM_NCPAINT,"NoEraseBkgnd")
;~    GUIRegisterMsg($WM_NOTIFY,"NoEraseBkgnd")
   
;~  _SendMessage(GUICtrlGetHandle($Guiplist1), $LVM_DELETEALLITEMS)
    _GUICtrlListView_DeleteAllItems (GUICtrlGetHandle($Guiplist1))
    Sleep(500); this represents some time intensive functions
    For $i = 1 To 10
        Sleep(50); this represents some time intensive functions
        _GUICtrlListView_InsertItem($Guiplist1, "aResult of time intensive Functions "&$i,-1,-1,Random(0,100,1))
    next
   
;~                   GUIRegisterMsg($WM_ERASEBKGND,"")
;~    GUIRegisterMsg($WM_NCPAINT, "")
;~    GUIRegisterMsg($WM_NOTIFY, "")

     _GUICtrlListView_EndUpdate(GUICtrlGetHandle($Guiplist1))
;~   GUICtrlSetState($Guiplist1,$GUI_ENABLE)
;~  _SendMessage(GUICtrlGetHandle($Guiplist1),$WM_SETREDRAW,1,0)
;~  GUISetState(@SW_UNLOCK,$GUI)

EndFunc

Func NoEraseBkgnd()
    Return 1
EndFunc

Func Exitf()
    Exit
EndFunc

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
qsek

Simply because begin update and end update has no effect when using _GUICtrlListView_DeleteAllItems.

I wouldnt have put in lines which would fix the problem, i tried them all :P

They only seem to work when adding single items.


Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites
Achilles

Let me get this straight:

You push End, the script blanks the listview, then you want it to pause and do it's thinking thing, then it shows the listview with all the items at once (or do you want it to show one at a time?). If so, why does this not work (I changed it a little bit from what I had above):

#include <GuiConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Include <SendMessage.au3>

Opt("GUIOnEventMode",1)
HotKeySet("{End}", "Refresh")

$Gui = GUICreate("TestGUI", 416, 416, 191, 113,BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION))

$Guiplist1 = GUICtrlCreateListView("Name", 8, 8, 200, 400, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT,$LVS_EX_GRIDLINES,$LVS_EX_DOUBLEBUFFER))
_GUICTRLLISTVIEW_SETCOLUMNWIDTH(-1, 0, $LVSCW_AUTOSIZE_USEHEADER)
$Guiplist2 = GUICtrlCreateListView("Name", 208, 8, 200, 400, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT,$LVS_EX_GRIDLINES,$LVS_EX_DOUBLEBUFFER))
_GUICTRLLISTVIEW_SETCOLUMNWIDTH(-1, 0, $LVSCW_AUTOSIZE_USEHEADER)

For $i = 1 To 10
    _GUICtrlListView_InsertItem($Guiplist1, "Result of time intensive Functions "&$i)
next
      
GUISetOnEvent($GUI_EVENT_CLOSE, "Exitf")
GUISetState()

While 1
    Sleep(10)
WEnd

Exit
Func Refresh()
;~  _WinAPI_InvalidateRect(GUICtrlGetHandle($Guiplist1), 0, False)



;~  GUISetState(@SW_LOCK,$GUI)
;~  _SendMessage(GUICtrlGetHandle($Guiplist1),$WM_SETREDRAW,0,0)
;~   GUICtrlSetState($Guiplist1,$GUI_DISABLE)
    
  
;~                GUIRegisterMsg($WM_ERASEBKGND,"NoEraseBkgnd")
;~                   GUIRegisterMsg($WM_NCPAINT,"NoEraseBkgnd")
;~    GUIRegisterMsg($WM_NOTIFY,"NoEraseBkgnd")
  
;~  _SendMessage(GUICtrlGetHandle($Guiplist1), $LVM_DELETEALLITEMS)
    _GUICtrlListView_DeleteAllItems (GUICtrlGetHandle($Guiplist1))
     _GUICtrlListView_BeginUpdate(GUICtrlGetHandle($Guiplist1))
    Sleep(500); this represents some time intensive functions
    For $i = 1 To 10
        Sleep(50); this represents some time intensive functions
        _GUICtrlListView_InsertItem($Guiplist1, "aResult of time intensive Functions "&$i,-1,-1,Random(0,100,1))
    next
  
;~                   GUIRegisterMsg($WM_ERASEBKGND,"")
;~    GUIRegisterMsg($WM_NCPAINT, "")
;~    GUIRegisterMsg($WM_NOTIFY, "")

     _GUICtrlListView_EndUpdate(GUICtrlGetHandle($Guiplist1))
;~   GUICtrlSetState($Guiplist1,$GUI_ENABLE)
;~  _SendMessage(GUICtrlGetHandle($Guiplist1),$WM_SETREDRAW,1,0)
;~  GUISetState(@SW_UNLOCK,$GUI)

EndFunc

Func NoEraseBkgnd()
    Return 1
EndFunc

Func Exitf()
    Exit
EndFunc

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
qsek

I simply dont want it to "Flicker", meaning that that i want it to visually prevent deleting the old items and display the new without any change or clearing the background.

Just imagine this refreshing of the list is automatically done every second. This wont look very smooth, does it?


Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites
Melba23

qsek,

The only solution I can think of is to use 2 lists and then swap between them. Try running this:

#include <GuiConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Include <SendMessage.au3>

Opt("GUIOnEventMode",1)
HotKeySet("{End}", "Refresh")

Global $fFlag = False

$Gui = GUICreate("TestGUI", 416, 416, 191, 113,BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION))

$Guiplist1 = GUICtrlCreateListView("Name", 8, 8, 200, 400, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT,$LVS_EX_GRIDLINES,$LVS_EX_DOUBLEBUFFER))
_GUICTRLLISTVIEW_SETCOLUMNWIDTH(-1, 0, $LVSCW_AUTOSIZE_USEHEADER)
$Guiplist2 = GUICtrlCreateListView("Name", 8, 8, 200, 400, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT,$LVS_EX_GRIDLINES,$LVS_EX_DOUBLEBUFFER))
_GUICTRLLISTVIEW_SETCOLUMNWIDTH(-1, 0, $LVSCW_AUTOSIZE_USEHEADER)
GUICtrlSetState(-1, $GUI_HIDE)

For $i = 1 To 10
    _GUICtrlListView_InsertItem($Guiplist1, "GUI1 Result of Functions "&$i)
next
        
GUISetOnEvent($GUI_EVENT_CLOSE, "Exitf")
GUISetState()

While 1
    Sleep(10)
WEnd

Exit
Func Refresh()
    GUIRegisterMsg($WM_NCPAINT,"NoEraseBkgnd")
    Sleep(500); this represents some time intensive functions
    $fFlag = Not $fFlag
    If $fFlag Then
        _GUICtrlListView_DeleteAllItems (GUICtrlGetHandle($Guiplist2))
        For $i = 1 To 10
            Sleep(50); this represents some time intensive functions
            _GUICtrlListView_InsertItem($Guiplist2, "GUI2 Result of Functions "&$i,-1,-1,Random(0,100,1))
        Next
        GUICtrlSetState($Guiplist1, $GUI_HIDE)
        GUICtrlSetState($Guiplist2, $GUI_SHOW)
    Else
        _GUICtrlListView_DeleteAllItems (GUICtrlGetHandle($Guiplist1))
        For $i = 1 To 10
            Sleep(50); this represents some time intensive functions
            _GUICtrlListView_InsertItem($Guiplist1, "GUI1 Result of Functions "&$i,-1,-1,Random(0,100,1))
        Next
        GUICtrlSetState($Guiplist2, $GUI_HIDE)
        GUICtrlSetState($Guiplist1, $GUI_SHOW)
    EndIf
    
        GUIRegisterMsg($WM_ERASEBKGND,"")

EndFunc

Func NoEraseBkgnd()
    Return 1
EndFunc

Func Exitf()
    Exit
EndFunc

Does this satisfy your requirements?

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
qsek

yeah thank you, very nice workaround. :P

A bit complicated to invoke that into my script, but i will give that a try.

Though i wonder if there is a more cleaner solution via the WM_PAINT messages.


Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.