今天又研究了一下列表框的自绘问题,对自绘又有了一些进一步的认识
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg,ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
ListBox1: TListBox;
Button1: TButton;
procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
x,y,w,h : LongInt;
Bitmap1: TBitmap;
begin
//listbox1的style属性应设置为 lbOwnerDrawVariable