Jump to content

ListView without ScrollBar ?


piterek
 Share

Recommended Posts

I did not explain right, the script is working well.

I remove the scrollbars of all listview that has the GUI.

For more than one listview in your Gui, some of the code would have to be duplicated.

Make a set of global vars for each listview, run _InitializeLV for each listview with those vars

It may be possible to global subclass the listview class to use the same window procedure handler.

One handler would be used for all listview controls.

$iCB1, $wProcOldLV1, $tSCROLLINFO1
$cListView1, $hListView1

$iCB2, $wProcOldLV2, $tSCROLLINFO2
$cListView2, $hListView2

$wProcOldLV1 = _InitializeLV($cListView1, $iCB1, $tSCROLLINFO1)
$wProcOldLV2 = _InitializeLV($cListView2, $iCB2, $tSCROLLINFO2)

add the extra code to close the callback, setwindowlong, etc in your exit function

make a copy of _LVWndProc() for each listview

_LVWndProc1($hWnd, $Msg, $wParam, $lParam)
_LVWndProc2($hWnd, $Msg, $wParam, $lParam)

and change listview ID for GUICtrlSendMsg($cListView1 in each handler

If using WM_NOTIFY, then just add the additional listview handles

Switch $hWndFrom
    Case $hListView1, $hListView2

Edit: rewording, again...

Note: If you mean a listview in an external process, then no, this code won't work, as the script is coded for subclassing a listview of the current process only.

Edited by rover

I see fascists...

Link to comment
Share on other sites

  • 4 weeks later...

The last code solved the problem of vertical movement but you can not use if you have more than one in gui listview.

Link to comment
Share on other sites

Here's an example of three subclassed listviews on the same gui

Edit: revised comment on WM_SETREDRAW painting disable

;coded by rover 2k12
;http://www.autoitscript.com/forum/topic/124308-listview-without-scrollbar/page__view__findpost__p__978222
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <WinAPIEx.au3>

Opt("MustDeclareVars", 1)

Global $aSClass[4] = [0, 0, 0, DllOpen("user32.dll")]
Global $aLVSC[3][2]

_Main()

Func _Main()
    Local $hGui, $Msg, $iExStyles
    $hGui = GUICreate("Scrollable ListView w/o scrollbars", 310, 352, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
    GUISetBkColor(0x494949)

    ;Listview 1 - subclassed
    $aLVSC[0][0] = GUICtrlCreateListView("", 2, 2, 306, 100, BitOR($LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER))
    $aLVSC[0][1] = GUICtrlGetHandle(-1) ;use with _GUICtrlListView_DeleteItem, _GUICtrlListView_DeleteAllItems, _GUICtrlListView_DeleteItemsSelected
    $iExStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER) ;$LVS_EX_DOUBLEBUFFER required for flicker control
    _GUICtrlListView_SetExtendedListViewStyle(-1, $iExStyles)
    GUICtrlSetFont(-1, 8.5) ;fixed font size (themes can change font size)
    _InitializeLV($aLVSC[0][0], $aSClass) ;set font before adjusting listview size to number of items displayable - Note: initialize before adding items or scrollbar will show
    GUICtrlSetBkColor(-1, 0x494949)
    GUICtrlSetColor(-1, 0xDADADA)

    _GUICtrlListView_InsertColumn($aLVSC[0][0], 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($aLVSC[0][0], 1, "Column 2", 100)
    For $i = 0 To 100
        _GUICtrlListView_AddItem($aLVSC[0][0], "Row " & $i & " : Col 1")
    Next

    ;Listview 2 - subclassed
    $aLVSC[1][0] = GUICtrlCreateListView("", 2, 120, 306, 100, BitOR($LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER))
    $aLVSC[1][1] = GUICtrlGetHandle(-1)
    $iExStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
    _GUICtrlListView_SetExtendedListViewStyle(-1, $iExStyles)
    GUICtrlSetFont(-1, 8.5)
    _InitializeLV($aLVSC[1][0], $aSClass)
    GUICtrlSetBkColor(-1, 0x494949)
    GUICtrlSetColor(-1, 0xDADADA)

    _GUICtrlListView_InsertColumn($aLVSC[1][0], 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($aLVSC[1][0], 1, "Column 2", 100)
    For $i = 0 To 100
        _GUICtrlListView_AddItem($aLVSC[1][0], "Row " & $i & " : Col 1")
    Next


    ;Listview 3 - subclassed
    $aLVSC[2][0] = GUICtrlCreateListView("", 2, 238, 306, 100)
    $aLVSC[2][1] = GUICtrlGetHandle(-1)
    $iExStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
    _GUICtrlListView_SetExtendedListViewStyle(-1, $iExStyles)
    GUICtrlSetFont(-1, 8.5)
    _InitializeLV($aLVSC[2][0], $aSClass)
    GUICtrlSetBkColor(-1, 0x494949)
    GUICtrlSetColor(-1, 0xDADADA)

    _GUICtrlListView_InsertColumn($aLVSC[2][0], 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($aLVSC[2][0], 1, "Column 2", 100)
    For $i = 0 To 100
        _GUICtrlListView_AddItem($aLVSC[2][0], "Row " & $i & " : Col 1")
    Next

    ;refreshes gridlines and prevents flicker when arrow/pg-up/dn key scrolling and mouse wheel scrolling (combined with $LVS_EX_DOUBLEBUFFER)
    ;should be for XP only (untested in Vista, but seems to work fine without this in Win 7 x64)
    If $__WINVER < 0x0600 Then GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") ;modify your own _WM_NOTIFY handler accordingly to handle XP/Vista/7
    GUISetState()

    While 1
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                _Exit($aLVSC, $hGui, $aSClass)
        EndSwitch
    WEnd
EndFunc   ;==>_Main

Func _InitializeLV(ByRef $cLV, ByRef $aSC)
    ;coded by rover 2k12
    ;http://www.autoitscript.com/forum/topic/124308-listview-without-scrollbar/page__view__findpost__p__978222
    ;create struct for setting mouse scrolling limit - one time only with first listview to be subclassed
    If Not IsDllStruct($aSC[1]) Then
        $aSC[1] = DllStructCreate($tagSCROLLINFO)
        DllStructSetData($aSC[1], "cbSize", DllStructGetSize($aSC[1]))
        DllStructSetData($aSC[1], "fMask", BitOR($SIF_RANGE, $SIF_TRACKPOS))
    EndIf
    Local $hLVWnd = GUICtrlGetHandle($cLV)
    Local $aPos = ControlGetPos($hLVWnd, "", $hLVWnd)
    ;adjust listview size for number of items that can be shown
    Local $iY = _GUICtrlListView_ApproximateViewHeight($cLV, _GUICtrlListView_GetCounterPage($cLV))
    GUICtrlSetPos($cLV, $aPos[0], $aPos[1], $aPos[2], $iY + 4)
    ;register callback for all subclassed listviews - one time only with first listview to be subclassed
    If Not $aSC[2] Then $aSC[2] = DllCallbackRegister("_LVWndProc", "ptr", "hwnd;uint;wparam;lparam")
    ;subclass multiple listviews - returns same window procedure handle each time called
    $aSC[0] = _WinAPI_SetWindowLong($hLVWnd, $GWL_WNDPROC, DllCallbackGetPtr($aSC[2]))
EndFunc   ;==>_InitializeLV

Func _Exit(ByRef $aLV, ByRef $hWnd, ByRef $aSC)
    If $aSC[0] Then
        For $i = 0 To UBound($aLV) - 1
            If IsHWnd($aLV[$i][1]) Then _WinAPI_SetWindowLong($aLV[$i][1], $GWL_WNDPROC, $aSC[0])
        Next
    EndIf
    If IsHWnd($hWnd) Then GUIDelete($hWnd);prevents crash on exit caused by DllCallbackFree()
    If $aSC[2] Then DllCallbackFree($aSC[2])
    If $aSC[3] Then DllClose($aSC[3])
    Exit
EndFunc   ;==>_Exit

Func _LVWndProc($hWnd, $Msg, $wParam, $lParam)
    ;coded by rover 2k11
    ;http://www.autoitscript.com/forum/topic/124308-listview-without-scrollbar/page__view__findpost__p__978222
    #forceref $hWnd, $Msg, $wParam, $lParam
    Switch $Msg
        Case $WM_KEYDOWN ;horiz scrolling disabled
            If $wParam = 0x27 Then Return 0 ;VK_RIGHT
        Case $WM_MOUSEWHEEL ;if using mouse wheel scrolling
            ;Modified code from _Scrollbars_WM_MOUSEWHEEL() in GUIScrollbars_Ex UDF by Melba23
            If Not BitAND($wParam, 0x0000FFFF) Then ; Move Vert scrollbar
                Local $iDirn = $SB_LINEDOWN, $iDelta = BitShift($wParam, 16) ; Mouse wheel movement direction
                If $iDelta > 0 Then $iDirn = $SB_LINEUP
                Local $iCnt = DllCall($aSClass[3], "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $LVM_GETCOUNTPERPAGE, "wparam", 0, "lparam", 0)
                $iCnt = $iCnt[0]
                DllCall($aSClass[3], "bool", "GetScrollInfo", "hwnd", $hWnd, "int", $SB_VERT, "struct*", $aSClass[1])
                Local $iMax = DllStructGetData($aSClass[1], "nMax")
                Local $iTrkPos = DllStructGetData($aSClass[1], "nTrackPos")
                If (($iTrkPos + $iCnt) <= $iMax) Or ($iDelta > 0) Then
                    DllCall($aSClass[3], "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $WM_VSCROLL, "wparam", $iDirn, "lparam", 0)
                EndIf
            EndIf
        Case $WM_WINDOWPOSCHANGING
            DllCall($aSClass[3], "bool", "ShowScrollBar", "hwnd", $hWnd, "int", $SB_BOTH, "bool", 0);Hide scrollbars
            Local $tWINDOWPOS = DllStructCreate($tagWINDOWPOS, $lParam) ;prevents major flicker on scrolling
            DllStructSetData($tWINDOWPOS, "Flags", BitXOR(DllStructGetData($tWINDOWPOS, "Flags"), $SWP_FRAMECHANGED))
    EndSwitch
    ;pass the unhandled messages to default WindowProc
    Local $aResult = DllCall($aSClass[3], "lresult", "CallWindowProcW", "ptr", _
            $aSClass[0], "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    If @error Then Return -1
    Return $aResult[0]
EndFunc   ;==>_LVWndProc


Func _WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    ;coded by rover 2k12
    ;http://www.autoitscript.com/forum/topic/124308-listview-without-scrollbar/page__view__findpost__p__978222
    #forceref $hWnd, $Msg, $wParam
    Local $tNMHDR, $hWndFrom, $iCode
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $aLVSC[0][1], $aLVSC[1][1], $aLVSC[2][1]
            Switch $iCode ;fix painting issues with scrolling, gridlines, item add/delete
                Case $LVN_DELETEITEM
                    ;;XP only
                    ;prevent flicker on item deletion (fixes gridline bug in XP)
                    DllCall($aSClass[3], 'int', 'InvalidateRect', 'hwnd', $hWndFrom, 'ptr', 0, 'int', 1)
                Case $LVN_BEGINSCROLL
                    ;XP only
                    ;fixes slight flicker when initially mouse scrolling from top or bottom, or mouse scrolling after any keypress
                    ;(there is an an error in the previous example of this code using $hWnd (parent gui) instead of $hWndFrom (listview))
                    ;(accidentally disabling painting on the parent gui $hWnd was more effective at reducing the slight mouse scrolling flicker,
                    ;Note: on testing with an updating label on the gui, using $hWnd (parent gui) did not disable control painting when scrolling
                    ;The refresh works very well when gui painting is disabled ($hWnd = parent gui),
                    ;as any control painting seems to overide this, so the listview doesn't flicker and the gui is still updated when mouse scrolling.
                    DllCall($aSClass[3], "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $WM_SETREDRAW, "wparam", 0, "lparam", 0) ;disable screen painting at onset of scrolling
                Case $LVN_ENDSCROLL ;mouse scrolling
                    ;XP only
                    ;prevent scrolling flicker (fixes gridline bug in XP)
                    DllCall($aSClass[3], "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $WM_SETREDRAW, "wparam", 1, "lparam", 0) ;enable screen painting at end of scrolling
                    DllCall($aSClass[3], 'int', 'InvalidateRect', 'hwnd', $hWndFrom, 'ptr', 0, 'int', 1)
                Case $LVN_ITEMCHANGED ;arrow key scrolling
                    ;XP only
                    ;prevent scrolling flicker (fixes gridline bug in XP)
                    DllCall($aSClass[3], 'int', 'InvalidateRect', 'hwnd', $hWndFrom, 'ptr', 0, 'int', 1)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY
Edited by rover

I see fascists...

Link to comment
Share on other sites

Thanks Rover worked perfectly for what I want.

#include <GuiImageList.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <WinAPIEx.au3>

Global $aLVSC[3][2], $aSClass[4] = [0, 0, 0, DllOpen("user32.dll")]
$hGui = GUICreate("Scrollable ListView/ListBox without scrollbars", 600, 330, -1, -1)

_Main()

Func _Main()
$aLVSC[0][0] = GUICtrlCreateListView("", 2, 2, 596, 150, $LVS_NOCOLUMNHEADER, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
$aLVSC[0][1] = GUICtrlGetHandle($aLVSC[0][0])
GUICtrlSetBkColor($aLVSC[0][0], 0x233BF7)
GUICtrlSetColor($aLVSC[0][0], 0xFFFFFF)
_InitializeLV($aLVSC[0][0], $aSClass)

    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($aLVSC[0][0], 0xC9AF1A, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($aLVSC[0][0], 0xF72811, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($aLVSC[0][0], 0x18E0F2, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($aLVSC[0][0], 0xDE6CF0, 16, 16))
    _GUICtrlListView_SetImageList($aLVSC[0][0], $hImage, 1)

    _GUICtrlListView_InsertColumn($aLVSC[0][0], 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($aLVSC[0][0], 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($aLVSC[0][0], 2, "Column 2", 100)
     _GUICtrlListView_InsertColumn($aLVSC[0][0], 3, "Column 4", 292)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 1",0)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 2",1)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 3",2)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 4",3)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 5",0)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 6",1)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 8",2)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 9",3)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 10",0)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 11",1)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 12",2)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 13",3)
         _GUICtrlListView_AddItem($aLVSC[0][0], ": item 14",0)
        _GUICtrlListView_AddSubItem($aLVSC[0][0], 0, ": Col 2", 1)
        _GUICtrlListView_AddSubItem($aLVSC[0][0], 1, ": Col 3", 2)
        _GUICtrlListView_AddSubItem($aLVSC[0][0], 2, ": Col 4", 3)

    ;Listview 2 - subclassed
    $aLVSC[1][0] = GUICtrlCreateListView("", 2, 165, 596, 150, $LVS_NOCOLUMNHEADER, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
    $aLVSC[1][1] = GUICtrlGetHandle(-1)
    GUICtrlSetBkColor($aLVSC[1][0], 0x494949)
    GUICtrlSetColor($aLVSC[1][0], 0xFFFFFF)
    _InitializeLV($aLVSC[1][0], $aSClass)
    _GUICtrlListView_InsertColumn($aLVSC[1][0], 0, "Column 1", 590)

    For $i = 0 To 100
        _GUICtrlListView_AddItem($aLVSC[1][0], "Row " & $i & " : Col 1")
    Next
    GUISetState()
EndFunc

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    _Exit($aLVSC, $hGui, $aSClass)

Func _InitializeLV(ByRef $cLV, ByRef $aSC)
    ;coded by rover 2k12
    ;http://www.autoitscript.com/forum/topic/124308-listview-without-scrollbar/page__view__findpost__p__978222
    ;create struct for setting mouse scrolling limit - one time only with first listview to be subclassed
    If Not IsDllStruct($aSC[1]) Then
        $aSC[1] = DllStructCreate($tagSCROLLINFO)
        DllStructSetData($aSC[1], "cbSize", DllStructGetSize($aSC[1]))
        DllStructSetData($aSC[1], "fMask", BitOR($SIF_RANGE, $SIF_TRACKPOS))
    EndIf
    Local $hLVWnd = GUICtrlGetHandle($cLV)
    Local $aPos = ControlGetPos($hLVWnd, "", $hLVWnd)
    ;adjust listview size for number of items that can be shown
    Local $iY = _GUICtrlListView_ApproximateViewHeight($cLV, _GUICtrlListView_GetCounterPage($cLV))
    GUICtrlSetPos($cLV, $aPos[0], $aPos[1], $aPos[2], $iY + 4)
    ;register callback for all subclassed listviews - one time only with first listview to be subclassed
    If Not $aSC[2] Then $aSC[2] = DllCallbackRegister("_LVWndProc", "ptr", "hwnd;uint;wparam;lparam")
    ;subclass multiple listviews - returns same window procedure handle each time called
    $aSC[0] = _WinAPI_SetWindowLong($hLVWnd, $GWL_WNDPROC, DllCallbackGetPtr($aSC[2]))
EndFunc   ;==>_InitializeLV

;#cs
Func _Exit(ByRef $aLV, ByRef $hWnd, ByRef $aSC)
    If $aSC[0] Then
        For $i = 0 To UBound($aLV) - 1
            If IsHWnd($aLV[$i][1]) Then _WinAPI_SetWindowLong($aLV[$i][1], $GWL_WNDPROC, $aSC[0])
        Next
    EndIf
    If IsHWnd($hWnd) Then GUIDelete($hWnd);prevents crash on exit caused by DllCallbackFree()
    If $aSC[2] Then DllCallbackFree($aSC[2])
    If $aSC[3] Then DllClose($aSC[3])
    Exit
EndFunc   ;==>_Exit
;#ce


Func _LVWndProc($hWnd, $Msg, $wParam, $lParam)
    ;coded by rover 2k11
    ;http://www.autoitscript.com/forum/topic/124308-listview-without-scrollbar/page__view__findpost__p__978222
    #forceref $hWnd, $Msg, $wParam, $lParam
    Switch $Msg
        Case $WM_KEYDOWN ;horiz scrolling disabled
            If $wParam = 0x27 Then Return 0 ;VK_RIGHT
        Case $WM_MOUSEWHEEL ;if using mouse wheel scrolling
            ;Modified code from _Scrollbars_WM_MOUSEWHEEL() in GUIScrollbars_Ex UDF by Melba23
            If Not BitAND($wParam, 0x0000FFFF) Then ; Move Vert scrollbar
                Local $iDirn = $SB_LINEDOWN, $iDelta = BitShift($wParam, 16) ; Mouse wheel movement direction
                If $iDelta > 0 Then $iDirn = $SB_LINEUP
                Local $iCnt = DllCall($aSClass[3], "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $LVM_GETCOUNTPERPAGE, "wparam", 0, "lparam", 0)
                $iCnt = $iCnt[0]
                DllCall($aSClass[3], "bool", "GetScrollInfo", "hwnd", $hWnd, "int", $SB_VERT, "struct*", $aSClass[1])
                Local $iMax = DllStructGetData($aSClass[1], "nMax")
                Local $iTrkPos = DllStructGetData($aSClass[1], "nTrackPos")
                If (($iTrkPos + $iCnt) <= $iMax) Or ($iDelta > 0) Then
                    DllCall($aSClass[3], "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $WM_VSCROLL, "wparam", $iDirn, "lparam", 0)
                EndIf
            EndIf
        Case $WM_WINDOWPOSCHANGING
            DllCall($aSClass[3], "bool", "ShowScrollBar", "hwnd", $hWnd, "int", $SB_BOTH, "bool", 0);Hide scrollbars
            Local $tWINDOWPOS = DllStructCreate($tagWINDOWPOS, $lParam) ;prevents major flicker on scrolling
            DllStructSetData($tWINDOWPOS, "Flags", BitXOR(DllStructGetData($tWINDOWPOS, "Flags"), $SWP_FRAMECHANGED))
    EndSwitch
    ;pass the unhandled messages to default WindowProc
    Local $aResult = DllCall($aSClass[3], "lresult", "CallWindowProcW", "ptr", _
            $aSClass[0], "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    If @error Then Return -1
    Return $aResult[0]
EndFunc   ;==>_LVWndProc


Func _WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    ;coded by rover 2k12
    ;http://www.autoitscript.com/forum/topic/124308-listview-without-scrollbar/page__view__findpost__p__978222
    #forceref $hWnd, $Msg, $wParam
    Local $tNMHDR, $hWndFrom, $iCode
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $aLVSC[0][1], $aLVSC[1][1], $aLVSC[2][1]
            Switch $iCode ;fix painting issues with scrolling, gridlines, item add/delete
                Case $LVN_DELETEITEM
                    ;;XP only
                    ;prevent flicker on item deletion (fixes gridline bug in XP)
                    DllCall($aSClass[3], 'int', 'InvalidateRect', 'hwnd', $hWndFrom, 'ptr', 0, 'int', 1)
                Case $LVN_BEGINSCROLL
                    ;XP only
                    ;fixes slight flicker when initially mouse scrolling from top or bottom, or mouse scrolling after any keypress
                    ;(corrected an error in the previous example of this code using $hWnd (parent gui) instead of $hWndFrom (listview))
                    ;(accidentally disabling painting on the parent gui $hWnd was more effective at reducing the slight mouse scrolling flicker,
                    ;but not feasible for any gui with controls other than listviews, but listviews on an embedded child gui could do this)
                    DllCall($aSClass[3], "lresult", "SendMessageW", "hwnd", $hWndFrom, "uint", $WM_SETREDRAW, "wparam", 0, "lparam", 0) ;disable screen painting at onset of scrolling
                Case $LVN_ENDSCROLL ;mouse scrolling
                    ;XP only
                    ;prevent scrolling flicker (fixes gridline bug in XP)
                    DllCall($aSClass[3], "lresult", "SendMessageW", "hwnd", $hWndFrom, "uint", $WM_SETREDRAW, "wparam", 1, "lparam", 0) ;enable screen painting at end of scrolling
                    DllCall($aSClass[3], 'int', 'InvalidateRect', 'hwnd', $hWndFrom, 'ptr', 0, 'int', 1)
                Case $LVN_ITEMCHANGED ;arrow key scrolling
                    ;XP only
                    ;prevent scrolling flicker (fixes gridline bug in XP)
                    DllCall($aSClass[3], 'int', 'InvalidateRect', 'hwnd', $hWndFrom, 'ptr', 0, 'int', 1)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY
Link to comment
Share on other sites

Your welcome

It is a mistake to not use _GUICtrlListView_SetExtendedListViewStyle for extended styles

You get these WINDOW EX styles ($WS_EX_DLGMODALFRAME, $WS_EX_WINDOWEDGE, $WS_EX_TRANSPARENT)

when you use the LISTVIEW EX style param to set these LVS EX styles ($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)

That is the reason for using _GUICtrlListView_SetExtendedListViewStyle, so you don't get unintended styles.

It's the same reason you use BitOr() and not + to add styles

Use $LVS_EX_DOUBLEBUFFER, it reduces flicker, whether customdrawn/ownerdrawn or not, if running on XP (I saw a few intermittant glitches using it when scrolling in Win 7 x64

but it no longer glitched if WM_NOTIFY painting code was also used with doublebuffer in Win7. At any rate you have two methods to use if you see any glitching)

The notes in my last post about $hWndFrom with $WM_SETREDRAW need revising.

The refresh works very well when gui painting is disabled ($hWnd = parent gui),

as any control painting seems to overide this, so the listview doesn't flicker and the gui is still updated when mouse scrolling.

As you can see, there are issues with _GUICtrlListView_ApproximateViewHeight, it is not very precise...

Edited by rover

I see fascists...

Link to comment
Share on other sites

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