Jump to content

Listview problems


lyledg
 Share

Recommended Posts

  • 2 weeks later...

I solved this scrolling glitch by invalidating listview's client rectangle upon $LVN_ENDSCROLL notification. Also added $LVS_EX_DOUBLEBUFFER style to eliminate redraw flicker (eventhough it was no big deal, just one flick).

Example using beta...

#include <GuiListView.au3>

Opt("GUICloseOnESC", 0)
Opt("GUIOnEventMode", 1)
Opt("WinWaitDelay", 0)

$sTitle = "Listview gridlines scroll"
$hGui = GUICreate($sTitle, 400, 300, -1, -1, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "SysEvents")

$listview = GUICtrlCreateListView("asdf|", 0, 0, 400, 250, -1, $LVS_EX_FULLROWSELECT+$LVS_EX_GRIDLINES+$LVS_EX_DOUBLEBUFFER)
GUICtrlSendMsg(-1, 0x101E, 0, 350)
GUICtrlSendMsg(-1, 0x101E, 1, 50)
For $i = 1 To 40
    $s = ""
    For $j = 1 to 40
        $s &= Chr(Random(97, 122, 1))
    Next
    GUICtrlCreateListViewItem($s, $listview)
Next

GUIRegisterMsg($WM_NOTIFY, "On_WM_NOTIFY")
GUISetState()

While 1
    Sleep(1000)
WEnd

Func SysEvents()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
EndFunc
Func On_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    ;wparam = cid, lparam = pnmh
    If $wParam = $listview Then
        Local $tNMHDR = DllStructCreate("hwnd hWnd;uint cID;int code", $lParam)
        Local $code = DllStructGetData($tNMHDR, "code")
        Local $hLV = HWnd(DllStructGetData($tNMHDR, "hWnd"))
        Switch $code
            Case $NM_CUSTOMDRAW
            Case $LVN_ENDSCROLL
                _WinAPI_InvalidateRect($hLV)
        EndSwitch
        ;
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

"be smart, drink your wine"

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...