Prueba con esta:
Código Delphi
[-]
var
Str,Str2:string;
f:byte;
ARect:TRect;
Ancho_Letra,Ancho_de_Antes:integer;
_Left:Integer;
begin
f:=0;
_Left:=0;
Str:=BASIC_List.Items[Index];
while f<=length (Str) do begin
if (Str[f]<#32) or (Str[f] in [#144..#164]) then begin
case ord(Str[f]) of
144..164:
begin
Ancho_Letra:=BASIC_List.Canvas.TextWidth(Str[f]);
Str2:=copy(Str,0,f);
Ancho_de_Antes:=BASIC_List.Canvas.TextWidth(Str2);
BASIC_List.Canvas.Font.Style:=[fsUnderline,fsItalic];
ARect:=Rect;
ARect.Left:=ARect.Left+Ancho_de_Antes+1;
ARect.Right:=ARect.Right+Ancho_de_Antes+Ancho_Letra+1;
BASIC_List.Canvas.TextRect(aRect, ARect.Left, aRect.Top,
chr(ord(Str[f])-79));
end;
else begin
end;
end;
inc (f);
end
else begin
Ancho_Letra:=BASIC_List.Canvas.TextWidth(Str[f]);
Str2:=copy(Str,0,f);
Ancho_de_Antes:=BASIC_List.Canvas.TextWidth(Str2);
BASIC_List.Canvas.Font.Style:=[];
ARect:=Rect;
ARect.Left:=_Left;
if (fthen begin ARect.Right:=_Left+Ancho_Letra;
end;
_LEft := _LEft + Ancho_Letra;
BASIC_List.Canvas.TextRect(aRect, ARect.Left + 1, aRect.Top, Str[f]);
inc(f);
end;
end;
if odFocused in State then begin
BASIC_List.Canvas.Brush.Style := bsClear;
BASIC_List.Canvas.Rectangle(Rect);
DrawFocusRect(BASIC_List.Canvas.Handle, Rect);
end;
end;
De todas forma la condición
(Str[f] in [#144..#164]) nunca se cumple y por lo tanto nunca va a entar en la primera parte del procedimiento.