Jump to content

ListView without ScrollBar ?


piterek
 Share

Recommended Posts

Hi all

Is it possible to create ListView control (using _GUICtrlListView_Create) with >> "hidden" << scrollbar ??

In ListView table styles there is only "$LBS_DISABLENOSCROLL".

Is there some way to only hide a scrollbar ?

you could try playing around with display positions, like setting the dimensions off the edge of the gui.

thats the only way i can think of, possibly a dll call but i dont have time to search msdn right now.

good luck

http://twentylinesofcode.blogspot.comLittle apps n crap. can be fun
Link to comment
Share on other sites

OK... so maybe another question

I want to add string to ListBox in two text parts.

example:

|1. Song title a          2:15|
   |2. Song title abc        3:14|
   |3. Song title abcde      4:09|
   |99. Song title ab        3:33|
etc...

Song title is a first part and song lenght is a second but it must be at the end of string.

This has the same look as in Winamp playlist...

It's look like columns but i need to do this in LISTBOX (no ListView)

Edited by piterek
Link to comment
Share on other sites

....look into

StringFormat ( "format control", var1 [, ... var32] )

one of the examples is a right-justification

...as for the scroll bars i had a look around and found an answer for you, have a look at this example

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>

Opt("MustDeclareVars", 1)

Global $iMemo

_Main()

Func _Main()
    Local $GUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $iMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($iMemo, $GUI_DOCKALL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)
    
    GUISetState()

    _GUIScrollBars_Init($hGUI)

    _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 30)
    
    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_HORZ))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_HORZ))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_HORZ))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_HORZ))
    
    Sleep ( 3000 )

    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_VERT))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_VERT))

    _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0)

    While 1
        $GUIMsg = GUIGetMsg()

        Switch $GUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>_Main

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite
http://twentylinesofcode.blogspot.comLittle apps n crap. can be fun
Link to comment
Share on other sites

Hi all

Is it possible to create ListView control (using _GUICtrlListView_Create) with >> "hidden" << scrollbar ??

In ListView table styles there is only "$LBS_DISABLENOSCROLL".

Is there some way to only hide a scrollbar ?

piterek

Re: formatting listbox text

use LBS_USETABSTOPS style and _GUICtrlListBox_SetTabStops() in listbox UDF

hiding listbox scrollbars

you can do this, but as usual there are issues...

this is a rough unoptimized hack/workaround that introduces new issues...

needs improvement or preferably a better way of doing this

there are border drawing issues for both listbox/listview.

listbox won't mouse scroll until scrolled by keyboard past last visible item.

one method I came across removes the listview/listbox WS_VSCROLL style in the WM_NCCALCSIZE message handler

with setwindowlong. - mouse scrolling no longer works, unless SWP_FRAMECHANGED flag removed in WM_WINDOWPOSCHANGING message.

a method I came across accidentally a few months ago, while trying some things with a subclassed listview.

removes SWP_FRAMECHANGED flag in WM_WINDOWPOSCHANGING message.

flag is removed before listview is shown, and when restored from minimize.

this does not work on an existing visible listview.

allows scrolling to last item, keyboard and mouse scrolling work, no visible scrollbars

Issues: listview

you must limit column resizing to prevent columns from being dragged past the listview right border

you cannot restore the scrollbars then rehide them.

A sliver of the scrollbar is visible and erases the listview border

when vertically scrolling or horizontally scrolling (column resizing).

when the gui is minimized then restored, this is repainted.

as this effectively blocks listview frame drawing, either a new frame needs to be drawn

or the existing frame removed.

not tested with resizeable gui/listview

the alternative is to repaint the frame by finding the right command and location to paint the listview when

the columns are adjusted or the listview is vertically scrolled.

If that can be done without causing flicker.

or enlarge the listview past the gui border and use transparentlabels to cover the listview border

issues: listbox

outlined item other than selected item sometimes appears in listbox

mouse won't scroll list until top index item is one greater than visible items

on restore from minimize, scrolling stops again until selected item one greater than visible items

#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 <GUIListBox.au3>
#Include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>

Opt('MustDeclareVars', 1)


Global $hGui, $hListView, $hList, $iDLLUser32 = DllOpen("user32.dll")
Global $wProcNewLV, $wProcOldLV, $wProcNewLB, $wProcOldLB

Example_UDF_Created()

Func Example_UDF_Created()
    $hGui = GUICreate("Scrollable ListView/ListBox without scrollbars", 600, 550, -1, -1)

    Local $cListView = GUICtrlCreateListView("", 2, 2, 596, 293)
    Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)
    $hListView = GUICtrlGetHandle($cListView)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)

    ;subclass listview
    $wProcNewLV = DllCallbackRegister("_LVWndProc", "ptr", "hwnd;uint;wparam;lparam")
    $wProcOldLV = _WinAPI_SetWindowLong($hListView, $GWL_WNDPROC, DllCallbackGetPtr($wProcNewLV))

    _GUICtrlListView_InsertColumn($cListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($cListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($cListView, 2, "Column 3", 100)
    _GUICtrlListView_InsertColumn($cListView, 3, "Column 4", 396)

    For $i = 0 To 41
        _GUICtrlListView_AddItem($cListView, "Row " & $i + 1 & ": Col 1")
        _GUICtrlListView_AddSubItem($cListView, $i, "Row " & $i + 1 & ": Col 2", 1)
        _GUICtrlListView_AddSubItem($cListView, $i, "Row " & $i + 1 & ": Col 3", 2)
        _GUICtrlListView_AddSubItem($cListView, $i, "Row " & $i + 1 & ": Col 4", 3)
    Next

    Local $sTxt
    For $i = 0 To 50
        $sTxt &= "Line " & $i & "|"
    Next
    Local $cList = GUICtrlCreateList("", 2, 320, 596, 200)
    GUICtrlSetData(-1, $sTxt)
    Local $hList = GUICtrlGetHandle(-1)

;works without this, but seems to remove sliver of scrollbar button on right edge
    _GUIScrollBars_EnableScrollBar($hList, $SB_BOTH, $ESB_DISABLE_BOTH)

    _GUIScrollBars_ShowScrollBar($hList, $SB_BOTH, False)
    ;subclass listbox
    $wProcNewLB = DllCallbackRegister("_LBWndProc", "ptr", "hwnd;uint;wparam;lparam")
    $wProcOldLB = _WinAPI_SetWindowLong($hList, $GWL_WNDPROC, DllCallbackGetPtr($wProcNewLB))

    ;mouse won't scroll list until top index item is one greater than visible items
    _GUICtrlListBox_SetTopIndex($hList, 15);set to item one greater than visible items
    _GUICtrlListBox_SetTopIndex($hList, 0);rest back to first item - scrolling by mouse now works
    ;on restore from minimize, scrolling stops again until selected item one greater than visible items
;_WinAPI_SetWindowPos($hList, 0, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER))

    GUISetState()

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    _Exit()
EndFunc


Func _Exit()
    If $wProcOldLV Then _WinAPI_SetWindowLong($hListView, $GWL_WNDPROC, $wProcOldLV)
    If $wProcOldLB Then _WinAPI_SetWindowLong($hList, $GWL_WNDPROC, $wProcOldLB)
    GUIDelete($hGui);prevents crash on exit caused by DllCallbackFree()
    DllClose($iDLLUser32)
    If $wProcNewLV Then DllCallbackFree($wProcNewLV)
    If $wProcNewLB Then DllCallbackFree($wProcNewLB)
    Exit
EndFunc


Func _LVWndProc($hWnd, $Msg, $wParam, $lParam)
    #forceref $hWnd, $Msg, $wParam, $lParam
    Switch $Msg
        Case $WM_NCCALCSIZE
            _RemoveVHScroll($hWnd)
        Case $WM_WINDOWPOSCHANGING
            Local $tWINDOWPOS = DllStructCreate($tagWINDOWPOS, $lParam)
            ;uncomment for mouse scrolling - no mouse scrolling without, but border is not erased (vertical key scrolling flickers visibly))
            DllStructSetData($tWINDOWPOS, "Flags", _
            BitAND(DllStructGetData($tWINDOWPOS, "Flags"), BitNOT($SWP_FRAMECHANGED)))
    EndSwitch
    ;pass the unhandled messages to default WindowProc
    Local $aResult = DllCall($iDLLUser32, "lresult", "CallWindowProcW", "ptr", _
    $wProcOldLV, "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    If @error Then Return -1
    Return $aResult[0]
EndFunc   ;==>_LVWndProc

Func _LBWndProc($hWnd, $Msg, $wParam, $lParam)
    #forceref $hWnd, $Msg, $wParam, $lParam
    Switch $Msg
        Case $WM_NCCALCSIZE
            _RemoveVHScroll($hWnd) ;listview will add these styles again when restored from minimize
        Case $WM_WINDOWPOSCHANGING
            Local $tWINDOWPOS = DllStructCreate($tagWINDOWPOS, $lParam)
            DllStructSetData($tWINDOWPOS, "Flags", _
            BitAND(DllStructGetData($tWINDOWPOS, "Flags"), BitNOT($SWP_FRAMECHANGED)))
    EndSwitch
    ;pass the unhandled messages to default WindowProc
    Local $aResult = DllCall($iDLLUser32, "lresult", "CallWindowProcW", "ptr", _
    $wProcOldLB, "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    If @error Then Return -1
    Return $aResult[0]
EndFunc   ;==>_LBWndProc


Func _RemoveVHScroll($hWnd)
    Local $iLVStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
    $iLVStyle = BitAND($iLVStyle, BitNOT($WS_VSCROLL))
    $iLVStyle = BitAND($iLVStyle, BitNOT($WS_HSCROLL))
    _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iLVStyle)
EndFunc

I see fascists...

Link to comment
Share on other sites

  • 5 months later...

This seemed to work for me when I wanted to disable the scroll bars for a listview:

#include <TreeviewConstants.au3>

...

GUICtrlCreateListView("Header", 10, 10, 125, 307, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_NOSORTHEADER, $TVS_NOSCROLL))

LVS_NOSCROLL, not TVS_NOSCROLL.

They do have the same value, but TVS_NOSCROLL is a treeview style.

Using that style not only removes the scrollbar,

but also prevents scrolling through more items than can be displayed.

This example script shows that using LVS_NOSCROLL prevents scrolling by keyboard arrow/home/end/up/dn keys or mouse wheel

through more items than can be displayed in the listview.

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $listview, $cLabel, $iBuffer
    GUICreate("Scroll listview items", 220, 250, 100, 200)
    $listview = GUICtrlCreateListView("col1|col2|col3  ", 10, 10, 200, 150, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_NOSORTHEADER, $LVS_NOSCROLL))
    For $i = 0 To 59
        GUICtrlCreateListViewItem("item"&$i&"|col2|col3", $listview)
    Next
    $cLabel = GUICtrlCreateLabel("Item Count: " & GUICtrlSendMsg($listview, $LVM_GETITEMCOUNT, 0, 0), 10, 170, 100, 16)
    GUISetState()
    Do
        For $iIdx = 0 To 59
        If GUICtrlSendMsg($listview, $LVM_GETITEMSTATE, $iIdx, $LVIS_SELECTED) Then
            If $iBuffer <> $iIdx Then
                $iBuffer = $iIdx
                GUICtrlSetData($cLabel, "Item Selected: " & $iIdx)
            EndIf
        EndIf
        Next
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

I see fascists...

Link to comment
Share on other sites

  • 8 months later...

Sorry for reviving the topic, the more I have a problem.

UDF using the scroll bar is removed if you have many more items and press right or left arrow, move the list.

I do not want the list by moving horizontally, can anyone help?

Example:

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

Global $hGui, $hListView, $hList, $iDLLUser32 = DllOpen("user32.dll")
Global $wProcNewLV, $wProcOldLV

$hGui = GUICreate("Scrollable ListView/ListBox without scrollbars", 240, 110, -1, -1)
Local $cListView = GUICtrlCreateListView("", 2, 2, 210, 100, $LVS_NOCOLUMNHEADER, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)
$hListView = GUICtrlGetHandle($cListView)
tira_barra($cListView)

; Add columns
_GUICtrlListView_InsertColumn($cListView, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($cListView, 1, "Column 2", 100)

; Add items
_GUICtrlListView_AddItem($cListView, "Row 1: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 2: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 3: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 4: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 6: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 7: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 8: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 9: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 10: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 11: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 12: Col 1")
_GUICtrlListView_AddItem($cListView, "Row 13: Col 1")

GUISetState()

GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
_Exit()

Func tira_barra($cListView)
        $wProcNewLV = DllCallbackRegister("_LVWndProc", "ptr", "hwnd;uint;wparam;lparam")
        $wProcOldLV = _WinAPI_SetWindowLong($hListView, $GWL_WNDPROC, DllCallbackGetPtr($wProcNewLV))
EndFunc   ;==>tira_barra

Func _Exit()
        If $wProcOldLV Then _WinAPI_SetWindowLong($hListView, $GWL_WNDPROC, $wProcOldLV)
        GUIDelete($hGui);prevents crash on exit caused by DllCallbackFree()
        DllClose($iDLLUser32)
        Exit
EndFunc   ;==>_Exit

Func _LVWndProc($hWnd, $Msg, $wParam, $lParam)
        #forceref $hWnd, $Msg, $wParam, $lParam
        Switch $Msg
                Case $WM_NCCALCSIZE
                        _RemoveVHScroll($hWnd)
                Case $WM_WINDOWPOSCHANGING
                        Local $tWINDOWPOS = DllStructCreate($tagWINDOWPOS, $lParam)
                        ;uncomment for mouse scrolling - no mouse scrolling without, but border is not erased (vertical key scrolling flickers visibly))
                        DllStructSetData($tWINDOWPOS, "Flags", _
                                        BitAND(DllStructGetData($tWINDOWPOS, "Flags"), BitNOT($SWP_FRAMECHANGED)))
        EndSwitch
        ;pass the unhandled messages to default WindowProc
        Local $aResult = DllCall($iDLLUser32, "lresult", "CallWindowProcW", "ptr", _
                        $wProcOldLV, "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
        If @error Then Return -1
        Return $aResult[0]
EndFunc   ;==>_LVWndProc

Func _RemoveVHScroll($hWnd)
        Local $iLVStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
        $iLVStyle = BitAND($iLVStyle, BitNOT($WS_VSCROLL))
        $iLVStyle = BitAND($iLVStyle, BitNOT($WS_HSCROLL))
        _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iLVStyle)
EndFunc   ;==>_RemoveVHScroll
Link to comment
Share on other sites

This hacked listview was my dump on the forum, so I guess I should be the one to deal with it.

I spent a bit more time on this soon after posting the above code,

I've cleaned it up and added a few more things, I'll post it shortly

It works smoothly without any scrollbar artifacts.

arrow key/pgup/pgdn/home/end and mouse wheel scrolling

To block horiz scrolling return 0 for the WM_KEYDOWN message

if wParam = VK_RIGHT (0x27)

I see fascists...

Link to comment
Share on other sites

You were adding extended window and listview styles together when creating the listview.

The extended style listview parameter should only be used for $WS_EX_xxxx extended styles

Using it for both $WS_EX_xxxx and $LVS_EX_xxxxx extended styles is asking for trouble,

as the combined styles can equal another $WS_EX_xxxx style or an invalid one.

This is the updated scrollable scrollbarless listview

Right arrow key blocked in WM_KEYDOWN message and vertical scrolling by keys or mouse wheel.

NOTE: The listview style $LVS_EX_GRIDLINES introduces glitchy missing grid lines when mouse wheel scrolling, this is a known listview bug.

Using the LVN_ENDSCROLL notification in WM_NOTIFY to invalidate the listview clears this up.

Edit: fixed last two 'known' issues

Two remaining issues

Slight flicker when initially mouse scrolling from top or bottom - Fixed

Mouse scrolling tends to leave blank space at the bottom, key scrolling does not,

probably because of hidden horiz scrollbar and need for vertical scrollbar synchronization - Fixed

Edit: If not using XP, you could remove the WM_NOTIFY message handler, listview performance is much better in Win7, no flickering, (minor flicker with pg up/dn)

(possibly same for Vista with this mod, but untested)

enjoy

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

Opt("MustDeclareVars", 1)

Global $wProcOldLV, $tSCROLLINFO
Global $cListView, $hListView, $iDLLUser32 = DllOpen("user32.dll")

_Main()

Func _Main()
    Local $hGui, $Msg, $iExStyles, $iCB
    $hGui = GUICreate("Scrollable ListView /wo scrollbars", 240, 116, -1, -1)
    GUISetBkColor(0x494949)

    ;advisable to only add $WS_EX_xxxx extended styles here, use SetExtendedListViewStyle for extended listview styles
    ;$cListView = GUICtrlCreateListView("", 2, 2, 210, 100, $LVS_NOCOLUMNHEADER, 0) ; flat, no borders $WS_EX_TRANSPARENT
    $cListView = GUICtrlCreateListView("", 2, 2, 204, 100, $LVS_NOCOLUMNHEADER) ; ($WS_EX_CLIENTEDGE default listview extended style)
    ;$cListView = GUICtrlCreateListView("", 2, 2, 210, 100, $LVS_NOCOLUMNHEADER, $WS_EX_DLGMODALFRAME) ; raised border edge
    ;$cListView = GUICtrlCreateListView("", 2, 2, 210, 100, $LVS_NOCOLUMNHEADER, $WS_EX_STATICEDGE) ; sunken border
    $iExStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER) ;$LVS_EX_DOUBLEBUFFER required for flicker control
    ;use this instead of adding extended styles when creating listview
    _GUICtrlListView_SetExtendedListViewStyle($cListView, $iExStyles)
    GUICtrlSetFont(-1, 8.5) ;fixed font size (themes can change font size)
    $wProcOldLV = _InitializeLV($cListView, $iCB, $tSCROLLINFO) ;set font before adjusting listview size to number of items displayable - Note: initialize before adding items or scrollbar will show
    $hListView = GUICtrlGetHandle($cListView)
    GUICtrlSetBkColor(-1, 0x494949)
    GUICtrlSetColor(-1, 0xDADADA)

    ; Add columns
    _GUICtrlListView_InsertColumn($cListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($cListView, 1, "Column 2", 100)

    ; Add items
    For $i = 0 To 100
        _GUICtrlListView_AddItem($cListView, "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)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") ;can be removed in Win7 (maybe Vista as well) listview performance better than XP (or add OS check and include if XP)
    GUISetState()

    While 1
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE

                _Exit($hListView, $hGui, $iCB, $wProcOldLV)
        EndSwitch
    WEnd

EndFunc   ;==>_Main

Func _InitializeLV($cLV, ByRef $iCallback, ByRef $tInfo)
    ;coded by rover 2k12
    ;http://www.autoitscript.com/forum/topic/124308-listview-without-scrollbar/page__view__findpost__p__971386
    ;create struct for setting mouse scrolling limit
    $tInfo = DllStructCreate($tagSCROLLINFO)
    DllStructSetData($tInfo, "cbSize", DllStructGetSize($tInfo))
    DllStructSetData($tInfo, "fMask", BitOR($SIF_RANGE, $SIF_TRACKPOS))
    Local $hLV = GUICtrlGetHandle($cLV)
    Local $aPos = ControlGetPos($hLV, "", $hLV)
    ;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)
    $iCallback = DllCallbackRegister("_LVWndProc", "ptr", "hwnd;uint;wparam;lparam")
    Return _WinAPI_SetWindowLong($hLV, $GWL_WNDPROC, DllCallbackGetPtr($iCallback))
EndFunc   ;==>_InitializeLV

Func _Exit($hLV, $hWnd, $iCallback, $pProcOldLV)
    If IsInt($pProcOldLV) And IsHWnd($hLV) Then _WinAPI_SetWindowLong($hLV, $GWL_WNDPROC, $pProcOldLV)
    If IsHWnd($hWnd) Then GUIDelete($hWnd);prevents crash on exit caused by DllCallbackFree()
    If $iCallback Then DllCallbackFree($iCallback)
    If $iDLLUser32 Then DllClose($iDLLUser32)
    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__971386
    #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 = GUICtrlSendMsg($cListView, $LVM_GETCOUNTPERPAGE, 0, 0) ;get number of displayable items that fit in listview
                DllCall($iDLLUser32, "bool", "GetScrollInfo", "hwnd", $hWnd, "int", $SB_VERT, "struct*", $tSCROLLINFO) ; >= 3.3.8.x
                ;DllCall($iDLLUser32, "int", "GetScrollInfo", "hwnd", $hWnd, "int", $SB_VERT, "ptr", DllStructGetPtr($tSCROLLINFO)) ; < 3.3.8.x
                Local $iMax = DllStructGetData($tSCROLLINFO, "nMax")
                Local $iTrkPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
                If (($iTrkPos + $iCnt) <= $iMax) Or ($iDelta > 0) Then GUICtrlSendMsg($cListView, $WM_VSCROLL, $iDirn, 0)
            EndIf
        Case $WM_WINDOWPOSCHANGING
            DllCall($iDLLUser32, "int", "ShowScrollBar", "hwnd", $hWnd, "int", $SB_BOTH, "int", 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($iDLLUser32, "lresult", "CallWindowProcW", "ptr", _
            $wProcOldLV, "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__971386
    #forceref $hWnd, $Msg, $wParam
    Local $tNMHDR, $hWndFrom, $iCode
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hListView
            Switch $iCode ;fix painting issues with scrolling, gridlines, item add/delete
                Case $LVN_DELETEITEM
                    ;prevent flicker on item deletion
                    DllCall($iDLLUser32, 'int', 'InvalidateRect', 'hwnd', $hWndFrom, 'ptr', 0, 'int', 1)
                Case $LVN_BEGINSCROLL
                    ;fixes slight flicker when initially mouse scrolling from top or bottom, or mouse scrolling after any keypress
                    DllCall($iDLLUser32, "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $WM_SETREDRAW, "wparam", 0, "lparam", 0) ;disable screen painting at onset of scrolling
                Case $LVN_ENDSCROLL, $LVN_ITEMCHANGED
                    ;prevent scrolling flicker (fixes gridline bug)
                    DllCall($iDLLUser32, "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $WM_SETREDRAW, "wparam", 1, "lparam", 0) ;enable screen painting at end of scrolling
                    DllCall($iDLLUser32, '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

Link to comment
Share on other sites

Post #10 updated with two fixes

This code can have a custom themed scrollbar or themed scroll up/dn buttons added

I have an example of that, maybe I'll post it in examples if there is interest.

I see fascists...

Link to comment
Share on other sites

With this code is possible to withdraw the bars 2 or 3 in the same listview gui?

Link to comment
Share on other sites

With this code is possible to withdraw the bars 2 or 3 in the same listview gui?

can you elaborate further on that?

When you say withdraw do you mean remove?

what bars?, do you mean rows or columns?

I see fascists...

Link to comment
Share on other sites

O.K. I see what you mean, the gridlines.

That style sets a fixed grid for the whole listview.

However, you could use the UDF group functions to create a header for a group of items

I see fascists...

Link to comment
Share on other sites

What you want with the edited gridlines has to be done by some kind of transparency or painting over the listvew.

That is beyond the scope of the modification here, look on the forum for ideas.

Just did some more testing in Win 7 x64

I coded this in XP (more bugs and poor performance) to eliminate flickering.

Listview performance in Win 7 is much better

If you won't be running run this on XP and you don't see any flicker or can live with the slight flicker when scrolling with pg up/dn

then remove the WM_NOTIFY message handler and GuiRegisterMsg() line

or include the WM_NOTIFY message handler and add an OS check .

If XP Then GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

If using your own message handler then set a flag to run the functions in the message handler if XP

I see fascists...

Link to comment
Share on other sites

can you elaborate further on that?

When you say withdraw do you mean remove?

what bars?, do you mean rows or columns?

Remove all listview scroll bar that is in the gui.

post-69288-0-76621700-1331898033_thumb.j

Edited by Belini
Link to comment
Share on other sites

What OS are you trying this on?

What AutoIt version?

Is that the code I posted, or have you changed something?

Edit: I see what the problem is, this code uses the latest AutoIt 3.3.8,1

The bool type is not in older AutoIt versions, so the hide scrollbar call fails,

and one of the dll calls uses the new "struct*" param instead of "ptr" with DllStructGetPtr()

so the mouse scrolling won't work in an older version without changes

Edit: rewording

Let me guess, that's Win2000, not XP with classic (no theme) style.

I have XP x86 and Win 7 x64, and with or without a theme there are no scrollbars in XP or Win 7

This is coded using Unicode AutoIt, the API calls are all Unicode not Ansi.

Unlikely it would work on Win2k without an older AutoIt version and a downgrading of the code to Ansi and dllcall/struct changes

For performance, these lines are called with a dll pseudo handle, instead of using the UDF versions, so there are differences in the 3.3.8.x/3.3.9.x versions

Try changing these lines in _LVWndProc()

DllCall($iDLLUser32, "int", "GetScrollInfo", "hwnd", $hWnd, "int", $SB_VERT, "ptr", DllStructGetPtr($tSCROLLINFO))
DllCall($iDLLUser32, "int", "ShowScrollBar", "hwnd", $hWnd, "int", $SB_BOTH, "int", 0)

Replace bool with lparam or lresult for return type in SendMessageW in WM_NOTIFY (_GUICtrlListView_BeginUpdate / _GUICtrlListView_EndUpdate)

I don't know where I copied that sendmessage from with bool for return?

DllCall($iDLLUser32, "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $WM_SETREDRAW, "wparam", 0, "lparam", 0)
Edited by rover

I see fascists...

Link to comment
Share on other sites

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

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

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