PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Anonymous on July 03, 2004, 08:52:27 AM

Title: Horizontal scrollbar on listbox - how to?
Post by: Anonymous on July 03, 2004, 08:52:27 AM
This might be a PowerBASIC issue, but as it is causing me a problem in FireFly I thought I would ask here first.

I have a regular (non owner-drawn) listbox on a form. I've ticked the WS_HSCROLL attribute on the properties dialog. I've also added the LBS_DISABLENOSCROLL (and this causes the horizontal scrollbar to appear, but disabled). I added the LBS_HASSTRINGS which made no difference at all.

Some of the string that I put into the listbox extends past the right side of the listbox, but at no time does the horizontal scrollbar enable! I'd like to have the ability to scroll the listbox horizontally but haven't figured how to do this yet.

Am I missing something obvious?

Andrew
Title: Horizontal scrollbar on listbox - how to?
Post by: TechSupport on July 03, 2004, 09:33:56 AM
From Rector and Newcomer:

"A horizontal scroll bar requires that you use the WS_HSCROLL style. But the scroll bar will not appear automatically if a line of the list box is wider than the list box itself. You must actually measure each line in the list box and set the scroll bar yourself."

They then give a C example of doing that.

In my experience, I have only used the WS_HSCROLL whenever I had the LBS_MULTICOLUMN style set.
Title: Horizontal scrollbar on listbox - how to?
Post by: Anonymous on July 03, 2004, 12:17:57 PM
Thanks for that. I can probably live without the horizontal scrollbar if it's going to be a toughie, but sometimes when you ask these dumb questions someone makes your day with a simple suggestion :)

Andrew
Title: Horizontal scrollbar on listbox - how to?
Post by: Peter Jinks on July 03, 2004, 02:00:02 PM
Kazmax,

Take a look at the LB_SETHORIZONTALEXTENT message. From MSDN;

QuoteAn application sends an LB_SETHORIZONTALEXTENT message to set the width, in pixels, by which a list box can be scrolled horizontally (the scrollable width). If the width of the list box is smaller than this value, the horizontal scroll bar horizontally scrolls items in the list box. If the width of the list box is equal to or greater than this value, the horizontal scroll bar is hidden.

Regards,

Pete.
Title: Horizontal scrollbar on listbox - how to?
Post by: David J Walker on June 30, 2005, 06:28:05 PM
QuoteControl Add ListBox, hDlg, %ID_LIST,, 4,  25, 110, 140, %WS_CHILD Or %LBS_EXTENDEDSEL Or _
                      %WS_VSCROLL Or %WS_HSCROLL Or %LBS_DISABLENOSCROLL Or %LBS_HASSTRINGS, _
                      %WS_EX_CLIENTEDGE Call DlgProc
  Control Send hDlg, %ID_LIST, %LB_SETHORIZONTALEXTENT, 1000, 0

Produces horizontal scrollbar in PB, can't seem to get it to happen in FF.

I'm using something like:
QuoteControl Send HWND_FRMBATCHREN, HWND_FRMBATCHREN_LISTFILES, %WS_HSCROLL Or %LBS_HASSTRINGS, 0, 0                                    
Control Send HWND_FRMBATCHREN, HWND_FRMBATCHREN_LISTFILES, %LB_SETHORIZONTALEXTENT , 2000, 0

What am I missing?
Title: Horizontal scrollbar on listbox - how to?
Post by: Peter Jinks on June 30, 2005, 10:24:55 PM
David,

Try
Control Send HWND_FRMBATCHREN, IDC_FRMBATCHREN_LISTFILES, %LB_SETHORIZONTALEXTENT , 2000, 0

In your PB code, you are using the control's ID - in the FireFly code, you are using the handle (hWnd). CONTROL SEND needs the ID.

Alternatively, just go for the SDK style instead, which does use the control's handle;
SendMessage HWND_FRMBATCHREN_LISTFILES, %LB_SETHORIZONTALEXTENT, 2000, 0

:)

Regards,

Pete.
Title: Horizontal scrollbar on listbox - how to?
Post by: David J Walker on July 01, 2005, 03:27:23 PM
Cheers Pete!  :D

SendMessage HWND_FRMBATCHREN_LISTFILES, %LB_SETHORIZONTALEXTENT, 2000, 0

Does the job!

I thought it would be something like that, I still seem to be mixing up my IDs and handles.  Need more practice!