procedure TfmCmnSetOption.ListBox1DrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
ListBox: TListBox;
Canvas: TCanvas;
ARect: TRect;
R: TRect;
Bmp: TBitmap;
begin
inherited;
if not (Control is TListBox) then Exit;
ListBox := TListBox(Control);
Bmp := TBitmap.Create;
try
Bmp.PixelFormat := pf24bit;
Bmp.Width := Rect.Right-Rect.Left;
Bmp.Height := Rect.Bottom - Rect.Top;
ARect := Bounds(0, 0, Bmp.Width, Bmp.Height);
R.Left := ARect.Left + 1;
R.Right := ARect.Right - 1;
R.Top := ARect.Top + 1;
R.Bottom := ARect.Bottom - 1;
Canvas := Bmp.Canvas;
Canvas.Font.Assign(ListBox.Font);
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := ListBox.Color;
Canvas.FillRect(ARect);
Canvas.Brush.Color := csShadowColor;
if odSelected in State then
begin
Canvas.Brush.Color := csSelectedColor;
Canvas.Font.Color := clBlue;
end else
begin
Canvas.Brush.Color := csNormalColor;
Canvas.Font.Color := clBlack;
end;
Canvas.RoundRect(R.Left, R.Top, R.Right, R.Bottom, 1, 1);
Canvas.TextOut(R.Left + 8, 3, Format('%d¡¢%s', [index+1, ListBox.Items[Index]]));
BitBlt(ListBox.Canvas.Handle, Rect.Left, Rect.Top, Bmp.Width, Bmp.Height, Canvas.Handle, 0, 0, SRCCOPY);
finally
Bmp.Free;
end;
end;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
ListBox: TListBox;
Canvas: TCanvas;
ARect: TRect;
R: TRect;
Bmp: TBitmap;
begin
inherited;
if not (Control is TListBox) then Exit;
ListBox := TListBox(Control);
Bmp := TBitmap.Create;
try
Bmp.PixelFormat := pf24bit;
Bmp.Width := Rect.Right-Rect.Left;
Bmp.Height := Rect.Bottom - Rect.Top;
ARect := Bounds(0, 0, Bmp.Width, Bmp.Height);
R.Left := ARect.Left + 1;
R.Right := ARect.Right - 1;
R.Top := ARect.Top + 1;
R.Bottom := ARect.Bottom - 1;
Canvas := Bmp.Canvas;
Canvas.Font.Assign(ListBox.Font);
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := ListBox.Color;
Canvas.FillRect(ARect);
Canvas.Brush.Color := csShadowColor;
if odSelected in State then
begin
Canvas.Brush.Color := csSelectedColor;
Canvas.Font.Color := clBlue;
end else
begin
Canvas.Brush.Color := csNormalColor;
Canvas.Font.Color := clBlack;
end;
Canvas.RoundRect(R.Left, R.Top, R.Right, R.Bottom, 1, 1);
Canvas.TextOut(R.Left + 8, 3, Format('%d¡¢%s', [index+1, ListBox.Items[Index]]));
BitBlt(ListBox.Canvas.Handle, Rect.Left, Rect.Top, Bmp.Width, Bmp.Height, Canvas.Handle, 0, 0, SRCCOPY);
finally
Bmp.Free;
end;
end;
回复Comments
作者:
{commentrecontent}