Scalabium Software

SMExport advertising
Knowledge for your independence'.
Home Delphi and C++Builder tips


#10: How can I add the horizontal scrollbar into listbox?

If you want to add a horizontal scrollbar in TListBox
(which have a vertical scrollbar only by default),
you need send a LB_SETHORIZONTALEXTENT message:
SendMessage(ListBox1.Handle, LB_SETHORIZONTALEXTENT, FMaxItemWidth, 0);

For example, the next code shows how you can scroll a data
with maximum width of item strings:

procedure TForm1.FormCreate(Sender: TObject);
var i, intWidth, intMaxWidth: Integer;
begin
  intMaxWidth := 0;
  for i := 0 to ListBox1.Items.Count-1 do
  begin
    intWidth := ListBox1.Canvas.TextWidth(ListBox1.Items.Strings[i] + 'x');
    if intMaxWidth < intWidth then
      intMaxWidth := intWidth;
  end;
  SendMessage(ListBox1.Handle, LB_SETHORIZONTALEXTENT, intMaxWidth, 0);
end;


Published: August 10, 1999

See also
 
Database Information Manager
Clarion to Text converter/a>
SMDBGrid
ABA Document Convert
Excel Reader (dll)
Viewer for TNEF-files (winmail.dat)
Paradox to MS Access converter
Metafile Convert
Paradox Password Recovery
ABA Spreadsheet Convert
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2017, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising