TIP: Click on subject to list as thread! ANSI
echo: delphi
to: SIMON HUGGINS
from: CHRIS MANN
date: 1997-05-09 01:23:00
subject: Owner draw listboxes

On May 06 20:22 97, Simon Huggins of 2:440/7.15 wrote:
 SH> Yep, I worked that out but, I thought that someone *MUST* have some 
 SH> code somewhere which does something similar.
This code is from the Delphi 2 Developer's Guide. Hope it helps you out.
procedure TTabListbox.CreateParams(var Params: TCreateParams);
{ We must OR in the styles necessary for tabs and horizontal scrolling
  These styles will be used by the API CreateWindowEx() function. }
begin
  inherited CreateParams(Params);
  { lbs_UseTabStops style allows tabs in listbox
    ws_HScroll style allows horizontal scrollbar in listbox }
  Params.Style := Params.Style or lbs_UseTabStops or ws_HScroll;
end;
function TTabListbox.GetLBStringLength(S: String): word;
{ This function returns the length of the listbox string S in pixels }
var
  Size: TSize;
  XS: String;
begin
  { Get the length of the text string }
  Result := LoWord(GetTabbedTextExtent(Canvas.Handle, PChar(S),
         StrLen(PChar(S)), FNumTabStops, FTabStops^));
  { Add a little bit of space to the end of the scrollbar
      extent for looks }
  XS := 'x';
  GetTextExtentPoint32(Canvas.Handle, 'x', 1, Size);
  Inc(Result, Size.cx);
end;
Chris
--- Msgedsq 2.2e
---------------
* Origin: Esc1.71 - When you're old enough to drive the bus. (1:157/534.30)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.