Board index » delphi » Listbox horizontal scroll?

Listbox horizontal scroll?

I have a listbox that fills an MDI child window which I use to display
error messages (align=alClient, and a double click goes to the point of
error in another window). Sometimes the messages are too long to fit in
the available width, but I can't find any way to add horizontal scrolling
to the listbox, and it means I can't see some (or most) of the message...

Can anyone help?

TIA,

-----------------------------------------------------------------
 John English              | mailto:j...@brighton.ac.uk
 Senior Lecturer           | http://www.comp.it.bton.ac.uk/je
 Dept. of Computing        | ** NON-PROFIT CD FOR CS STUDENTS **
 University of Brighton    |    -- see http://burks.bton.ac.uk
-----------------------------------------------------------------

 

Re:Listbox horizontal scroll?


Quote
John English wrote:
> I have a listbox that fills an MDI child window which I use to display
> error messages (align=alClient, and a double click goes to the point of
> error in another window). Sometimes the messages are too long to fit in
> the available width, but I can't find any way to add horizontal scrolling
> to the listbox, and it means I can't see some (or most) of the message...

Try:

sendmessage(listbox1.handle,lb_sethorizontalextent,width,0);

where width is the pixel width of your longest line.

--
Kent Briggs, kbri...@briggsoft.com
Briggs Softworks, http://www.briggsoft.com

Re:Listbox horizontal scroll?


Quote
Kent Briggs wrote:
> John English wrote:
> > I have a listbox that fills an MDI child window which I use to display
> > error messages (align=alClient, and a double click goes to the point of
> > error in another window). Sometimes the messages are too long to fit in
> > the available width, but I can't find any way to add horizontal scrolling
> > to the listbox, and it means I can't see some (or most) of the message...

> Try:

> sendmessage(listbox1.handle,lb_sethorizontalextent,width,0);

> where width is the pixel width of your longest line.

Thanks. This presumably involves doing a GetTextExtent on the listbox
to get the pixel width? Which means I need a device context? Which
means doing GetDC for Screen or some such? Am I going in the right
direction here?

-----------------------------------------------------------------
 John English              | mailto:j...@brighton.ac.uk
 Senior Lecturer           | http://www.comp.it.bton.ac.uk/je
 Dept. of Computing        | ** NON-PROFIT CD FOR CS STUDENTS **
 University of Brighton    |    -- see http://burks.bton.ac.uk
-----------------------------------------------------------------

Re:Listbox horizontal scroll?


Quote
"John English" <j...@brighton.ac.uk> wrote in message
> > where width is the pixel width of your longest line.

> Thanks. This presumably involves doing a GetTextExtent on the listbox
> to get the pixel width? Which means I need a device context? Which
> means doing GetDC for Screen or some such? Am I going in the right
> direction here?

You could, but it would probably be easier to use

wd := aListBox.Canvas.TextWidth (theText);

Re:Listbox horizontal scroll?


Quote
Bruce Roberts wrote:

> "John English" <j...@brighton.ac.uk> wrote in message

> > > where width is the pixel width of your longest line.

> > Thanks. This presumably involves doing a GetTextExtent on the listbox
> > to get the pixel width? Which means I need a device context? Which
> > means doing GetDC for Screen or some such? Am I going in the right
> > direction here?

> You could, but it would probably be easier to use

> wd := aListBox.Canvas.TextWidth (theText);

Thanks, Bruce; between you and Kent Briggs you've cracked it. There
was one other detail I needed:

  wd := (wd * Screen.PixelsPerInch) div 72;

On a 1024x768 display, the pixel size needs adjusting, or the tail end
of the line is still missing. I've had to do this in a couple of other
places in my app, and it made the tail end of the line visible in this
case too.

Again, many thanks.

-----------------------------------------------------------------
 John English              | mailto:j...@brighton.ac.uk
 Senior Lecturer           | http://www.comp.it.bton.ac.uk/je
 Dept. of Computing        | ** NON-PROFIT CD FOR CS STUDENTS **
 University of Brighton    |    -- see http://burks.bton.ac.uk
-----------------------------------------------------------------

Other Threads