Listbox horizontal scroll range

From Liberty BASIC Family
Jump to navigation Jump to search

Description

The horizontal scroll range of a listbox is not adjusted if the font is changed, so if the font size is increased you cannot scroll to the end of the text.

Example code to demonstrate the bug.

 ListArray$(0) = "This is a very long string which will not "; _
 "fit in its entirety across the width of the listbox, so "; _
 "the horizontal scroll bar needs to be activated."
 WindowWidth = 700
 stylebits #w.listbox,_WS_HSCROLL, 0, 0, 0
 listbox #w.listbox, ListArray$(), [], 5, 20, 620, 130
 open "Horizontal scroll" for window as #w
 #w.listbox "font Arial 14; reload"
 wait

Example code to work around the bug.

The scroll range is set explicitly by sending a LB_SETHORIZONTALEXTENT message.

 ListArray$(0) = "This is a very long string which will not "; _
 "fit in its entirety across the width of the listbox, so "; _
 "the horizontal scroll bar needs to be activated."
 WindowWidth = 700
 stylebits #w.listbox,_WS_HSCROLL, 0, 0, 0
 listbox #w.listbox, ListArray$(), [], 5, 20, 620, 130
 open "Horizontal scroll" for window as #w
 hlb = hwnd(#w.listbox)
 calldll #user32, "SendMessageA", hlb as ulong, _
   _LB_SETHORIZONTALEXTENT as long, _
   930 as long, 0 as long, res as long
 #w.listbox "font Arial 14; reload"
 wait