Board index » delphi » tlistbox have horz scroll?

tlistbox have horz scroll?

can the tlistbox be set to scroll horizontally?  if so how?  i didn't
see an option in the object inspector.

darrin
--
Please reply by Post & E-Mail or just E-Mail.

 

Re:tlistbox have horz scroll?


hi Darrin,

Just Today I saw a ListBox on the Delphi Super page that had this option,
so would be a good idea to look there and search for ListBox

Regards

Alex

laserjet <laser...@concentric.net> wrote in article
<33AAA073.8643C...@concentric.net>...

Quote
> can the tlistbox be set to scroll horizontally?  if so how?  i didn't
> see an option in the object inspector.

> darrin
> --
> Please reply by Post & E-Mail or just E-Mail.

Re:tlistbox have horz scroll?


On Fri, 20 Jun 1997 09:23:31 -0600, laserjet <laser...@concentric.net>
wrote:

Quote
>can the tlistbox be set to scroll horizontally?  if so how?  i didn't
>see an option in the object inspector.

>darrin
>--
>Please reply by Post & E-Mail or just E-Mail.

No, the standard Delphi listbox does not have that property. You can
create an inherited class and define a new property there. All you
have to do is to send the message LB_SETHORIZONTALEXTENT. Look at the
Win32 help file.

-------------------------------
mailto p...@singular.singular.gr
http://www.singular.gr

Re:tlistbox have horz scroll?


Quote
Paul Lambadaris wrote:
> >can the tlistbox be set to scroll horizontally?  if so how?  i didn't
> >see an option in the object inspector.
> No, the standard Delphi listbox does not have that property. You can
> create an inherited class and define a new property there. All you
> have to do is to send the message LB_SETHORIZONTALEXTENT. Look at the
> Win32 help file.

How would one go about doing that in 16-bit land?

--
+--------------------------------+
|        The Messiah             |
+--------------------------------+
|   Remove the spam blockers     |
+--------------------------------+
|  Ou' sont les neiges d' antan  |
|         Villon                 |
+________________________________+
|    There is a man...           |
|   playing a violin...          |
|   and the strings...           |
| are the nerves in his own arm. |
| A twisted soul- the mortar...  |
|  despair- the bricks...        |
| to build a temple of sadness.  |
|  The Crow, J. O'Barr           |
+--------------------------------+

Re:tlistbox have horz scroll?


On Fri, 20 Jun 1997 09:23:31 -0600, laserjet <laser...@concentric.net>
wrote:

Quote
>can the tlistbox be set to scroll horizontally?  if so how?  i didn't
>see an option in the object inspector.

>darrin
>--
>Please reply by Post & E-Mail or just E-Mail.

I had the same problem recently, I managed to fix it by using two
fairly simple procedures. (and it works in 16bit)

{ This function calculates the largest line length in a list box }
function MaxListLineLength(lbSender: TListBox): integer;
var
  Width, i: integer;

begin
  Result := 0;
  for i := 0 to lbSender.Items.Count-1 do begin
    Width := lbSender.Canvas.TextWidth(lbSender.Items[i]);
    if Width > Result then Result := Width;
  end;
end;

Then use this next function to actually set the width and enable the
scrollbar

{ Enable the horizontal scroll bar on a list box }
procedure EnableHorizontalScroll(lbSender: TListBox);
var
  MaxWidth: integer;

begin
  lbSender.Font.Assign(lbSender.Font);
  MaxWidth := MaxListLineLength(lbSender) + 20; { Add a little slack }
  SendMessage(lbSender.Handle, lb_SetHorizontalExtent, MaxWidth, 0);
end;

Hope this helps

Dave Verwer (d...@linkg.co.uk)

Re:tlistbox have horz scroll?


Try this:

SendMessage(ListBox3.Handle, LB_SETHORIZONTALEXTENT,
              ListBox3.Canvas.TextWidth('A') * nnn, 0 );  }

replacing "nnn" with the actual width of your widest line (you'll have
to calculate if you use proportional fonts).

David

Re:tlistbox have horz scroll?


There is no way to scroll a ListBox horizontally (sorry)
but you have 2 solutions to avoid this problme:
1 -- use a ListView with the right options (it should be in the Win95 tab)
2 -- create a new control derived from TListBox and use the ownerdraw mode
to do what you want to have (I did it with Visual C++ and I thing it's
possible on Delphi)

                                                Christophe CAEL
                                                chc...@infonie.fr

laserjet <laser...@concentric.net> a crit dans l'article
<33AAA073.8643C...@concentric.net>...

Quote
> can the tlistbox be set to scroll horizontally?  if so how?  i didn't
> see an option in the object inspector.

> darrin
> --
> Please reply by Post & E-Mail or just E-Mail.

Re:tlistbox have horz scroll?


To insert a horizontal scroll in yor listbox, add the following
instruction in the FormCreate event.

SendMessage(Listbox1.Handle,LB_SetHorizontalExtent, nnnn, LongInt(0));

then make sure nnnn is larger than your listbox width and you have a
scroll bar.
                                            Good Luck Jim
On Tue, 01 Jul 1997 08:10:20 GMT, gene...@linkg.co.uk (LINK Group

Quote
Consultants) wrote:
>On Fri, 20 Jun 1997 09:23:31 -0600, laserjet <laser...@concentric.net>
>wrote:

>>can the tlistbox be set to scroll horizontally?  if so how?  i didn't
>>see an option in the object inspector.

>>darrin
>>--
>>Please reply by Post & E-Mail or just E-Mail.

>I had the same problem recently, I managed to fix it by using two
>fairly simple procedures. (and it works in 16bit)

>{ This function calculates the largest line length in a list box }
>function MaxListLineLength(lbSender: TListBox): integer;
>var
>  Width, i: integer;

>begin
>  Result := 0;
>  for i := 0 to lbSender.Items.Count-1 do begin
>    Width := lbSender.Canvas.TextWidth(lbSender.Items[i]);
>    if Width > Result then Result := Width;
>  end;
>end;

>Then use this next function to actually set the width and enable the
>scrollbar

>{ Enable the horizontal scroll bar on a list box }
>procedure EnableHorizontalScroll(lbSender: TListBox);
>var
>  MaxWidth: integer;

>begin
>  lbSender.Font.Assign(lbSender.Font);
>  MaxWidth := MaxListLineLength(lbSender) + 20; { Add a little slack }
>  SendMessage(lbSender.Handle, lb_SetHorizontalExtent, MaxWidth, 0);
>end;

>Hope this helps

>Dave Verwer (d...@linkg.co.uk)

Other Threads