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)
|