Jump to content
Sign in to follow this  
gobsor

ListView Scrollbar

Recommended Posts

gobsor

Hey!

I made a ListView with 4 items, each wide enough (set to 60px width) to put 2 chars in using _AddSubItem(), but if i add items/subitems (with only 2 chars, like DE, EN, FR...) to it, there pops up a scrollbar to scroll left right, even though its totally unnecessary to scroll since there's enough place in each index-box to put 2 chars in. Is there a way to disable left-right-scrolling/scrollbar in ListView? up-down-scrolling should still be available.

Thanks in advance,

gob

Share this post


Link to post
Share on other sites
GEOSoft

The font is affecting it. You will probably have to make the columns wider by a few px.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
gobsor

Allright, I decreased the width of one column by 10 px and now it works, but now I got another "column" on the most right hand-side (10px width) when there's no items (font) added yet.

I wanted columns to perfectly fit into the whole ListView table. Though, any chance to disable across-scrolling?

Regards

Share this post


Link to post
Share on other sites
Belini

Remove the vertical bar of the listview:

#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", 300, 120, -1, -1)
Local $cListView = GUICtrlCreateListView("", 2, 2, 296, 100)
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")
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

Share this post


Link to post
Share on other sites
rover

Remove the vertical bar of the listview:

#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", 300, 120, -1, -1)
Local $cListView = GUICtrlCreateListView("", 2, 2, 296, 100)
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")
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

It's unfinished code and does not address several issues.

Next time try linking to the original post and/or accrediting the author.

ListView without ScrollBar ?


I see fascists...

Share this post


Link to post
Share on other sites
Belini

the code was posted in another forum that did not include the author's name, I'll pay more attention going forward.

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.