unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class
(TForm)
ComboBox1: TComboBox;
procedure
ComboBox1DrawItem(Control: TWinControl; Index:
Integer
;
Rect: TRect; State: TOwnerDrawState);
private
public
end
;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure
TForm1
.
ComboBox1DrawItem(Control: TWinControl; Index:
Integer
;
Rect: TRect; State: TOwnerDrawState);
var
i, x:
Integer
;
s, s1:
String
;
begin
with
TCombobox(Control).Canvas
do
begin
fillrect(rect);
s := TCombobox(Control).items[index];
i := Pos(
'^'
, s);
s1 := Copy(s,
1
, i -
1
);
textout(rect
.
left+
2
,rect
.
top +
4
, s1);
x := TextWidth(s1);
Font
.
Size := Font
.
Size -
2
;
textout(rect
.
left+
2
+x,rect
.
top +
2
, Copy(s, i +
1
, Length(s) - Length(s1) -
1
));
Font
.
Size := Font
.
Size +
2
;
end
;
end
;
end
.