Jump to content

Recommended Posts

Posted

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

Posted

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

George

  Reveal hidden contents
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!"

Posted

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

  • 1 year later...
Posted

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
Posted

  On 3/8/2012 at 11:09 AM, 'Belini said:

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

Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...