Jump to content

Horizontal Scroll Bar in Listbox


Recommended Posts

Here is the code:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $MESSAGE = "The following buttons have been clicked"
    Local $add, $clear, $mylist, $close, $msg
    
    GUICreate("My GUI list") ; will create a dialog box that when displayed is centered

    $add = GUICtrlCreateButton("Add", 64, 32, 75, 25)
    $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25)
    $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97)
    GUICtrlSetLimit(-1, 200)    ; to limit horizontal scrolling
    GUICtrlSetData(-1, $MESSAGE)
    $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25)

    GUISetState()

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()

        Select
            Case $msg = $add
                GUICtrlSetData($mylist, "You clicked button No1|")
            Case $msg = $clear
                GUICtrlSetData($mylist, "")
            Case $msg = $close
                MsgBox(0, "", "the closing button has been clicked", 2)
                Exit
        EndSelect
    WEnd
EndFunc

I would like to enable a horizontal scroll bar on the listbox if the text exceeds the borders. Anyone know how to do it?

post-55486-12690180637053_thumb.jpg

Link to comment
Share on other sites

  • Moderators

nasim007,

Anyone know how to do it?

Yes. :(

Add the horizontal scrollbar style to the control:

$mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97, BitOR($GUI_SS_DEFAULT_LIST, $WS_HSCROLL))

Note the use of BitOR. If you specify a particular style (or extended style), you overwrite the current values, so if you want to keep them you need to specify them as well. As most styles are expressed at the bit level (look at the hex values to see what I mean) merely adding the styles can lead to some strange results. Always use BitOR to make sure the correct bits are set. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Melba23,

That makes it three times that you helped me out. Thanks so much. I looked up and down the help file but I didn't know I could apply that style. I thought I was limited to the ListboxConstants.au3 file.

Thanks again!

EDIT: For my program I am populating the listbox with filepaths. Using your suggestion I can make a statically defined limit to the scroll bar using GUICtrlSetLimit. Meaning when the app runs, the empty listbox will already contain a horizonatal scroll bar at a fixed size. Before I go nuts in creating a whole slew of logic blocks trying to figure it out, can I make it so it only appears like the vertical scroll bar; only if the characters exceeds the width of the list box??

Edited by nasim007
Link to comment
Share on other sites

  • Moderators

nasim007,

You might find these recent topics of interest: :(

Making scrollbars appear only when necessary

Using ellipsis styles

You will have to adapt the techniques used, but they should give you a few pointers on how you might go about it. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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