Z
zouming
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么在listbox中隔行自画图象会出现不显示,单击选择后才显示图象?代码如下:
procedure TTaxAndCostStandardForm.LB_MessageDrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
with LB_Message.Canvas do
begin
FillRect(Rect);
Font.Name := LB_Message.Items[Index];
Font.Size := 0; // use font's preferred size
TextOut(Rect.Left+Image1.ClientWidth+1, Rect.Top+1, LB_Message.Items[Index]);
case LB_Message.ItemIndex of
0,4:
Draw(Rect.Left+1, Rect.Top+1, Image1.Picture.Graphic);
end;
UpDate;
//TextOut(Rect.Left+1, Rect.Top+1, ListBox1.Items[Index]);
end;
end;
procedure TTaxAndCostStandardForm.LB_MessageMeasureItem(
Control: TWinControl; Index: Integer; var Height: Integer);
begin
with LB_Message.Canvas do
begin
Font.Name := LB_Message.Items[Index];
Font.Size := 0; // use font's preferred size
Height := TextHeight('Wg') + 2; // measure ascenders and descenders
Image1.Height := Height;
Image1.Width := Height;
end;
end;
procedure TTaxAndCostStandardForm.LB_MessageDrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
with LB_Message.Canvas do
begin
FillRect(Rect);
Font.Name := LB_Message.Items[Index];
Font.Size := 0; // use font's preferred size
TextOut(Rect.Left+Image1.ClientWidth+1, Rect.Top+1, LB_Message.Items[Index]);
case LB_Message.ItemIndex of
0,4:
Draw(Rect.Left+1, Rect.Top+1, Image1.Picture.Graphic);
end;
UpDate;
//TextOut(Rect.Left+1, Rect.Top+1, ListBox1.Items[Index]);
end;
end;
procedure TTaxAndCostStandardForm.LB_MessageMeasureItem(
Control: TWinControl; Index: Integer; var Height: Integer);
begin
with LB_Message.Canvas do
begin
Font.Name := LB_Message.Items[Index];
Font.Size := 0; // use font's preferred size
Height := TextHeight('Wg') + 2; // measure ascenders and descenders
Image1.Height := Height;
Image1.Width := Height;
end;
end;