怎样在Panel控件里进行背景图的平铺? 怎样在Panel控件里进行背景图的平铺? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在panel的onResize里面写代码,根据其尺寸动态生成TImage,然后计算她的位置不就行了,是不是嫌这个方法太笨了? unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}type TMyPanel = class(TPanel) private FBitmap: TBitmap; procedure SetBitmap(const Value: TBitmap); protected procedure Paint; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; property Bitmap: TBitmap read FBitmap write SetBitmap; //需要平铺画的图 end;procedure TForm1.FormCreate(Sender: TObject);begin with TMyPanel.Create(Self) do begin { 画图测试 } Bitmap.LoadFromFile('C:\WINDOWS\Gone Fishing.bmp'); Parent := Self; Align := alClient; end;end;{ TMyPanel }constructor TMyPanel.Create(AOwner: TComponent);begin inherited; FBitmap := TBitmap.Createend;destructor TMyPanel.Destroy;begin FBitmap.Free; inherited;end;procedure TMyPanel.Paint;var I, J: Integer; Rect: TRect;begin { 平铺画图 } Rect := ClientRect; for I := Rect.Top div FBitmap.Height to Rect.Bottom div FBitmap.Height do for J:= Rect.Left div FBitmap.Width to Rect.Right div FBitmap.Width do BitBlt(Canvas.Handle, J * FBitmap.Width - Rect.Left, I * FBitmap.Height - Rect.Top, FBitmap.Width, FBitmap.Height, FBitmap.Canvas.Handle, 0, 0, SRCCOPY);end;procedure TMyPanel.SetBitmap(const Value: TBitmap);begin FBitmap.Assign(Value);end;end. clientdataset的问题 F1Book中ObjCreatePicture方法使用?? insert 后报错 帮帮忙,在线等 怎样在form4中用form1中的数据? 请教 关于 Access2007 压缩后的排序问题 数据库问题。 请问如何用程序将TOlecontainer打开的对象激活? 关于用asp做Multi-Tier的中间层的问题? 谁有delphi 6.0 update pack 2 Enterprise edition的serial number and key fastreport 与 ACTIVEFORM 如何控制ListView的滚动。
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}type TMyPanel = class(TPanel)
private
FBitmap: TBitmap;
procedure SetBitmap(const Value: TBitmap);
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override; property Bitmap: TBitmap read FBitmap write SetBitmap; //需要平铺画的图
end;procedure TForm1.FormCreate(Sender: TObject);
begin
with TMyPanel.Create(Self) do
begin
{ 画图测试 }
Bitmap.LoadFromFile('C:\WINDOWS\Gone Fishing.bmp');
Parent := Self;
Align := alClient;
end;
end;{ TMyPanel }constructor TMyPanel.Create(AOwner: TComponent);
begin
inherited;
FBitmap := TBitmap.Create
end;destructor TMyPanel.Destroy;
begin
FBitmap.Free;
inherited;
end;procedure TMyPanel.Paint;
var
I, J: Integer;
Rect: TRect;
begin
{ 平铺画图 }
Rect := ClientRect;
for I := Rect.Top div FBitmap.Height to Rect.Bottom div FBitmap.Height do
for J:= Rect.Left div FBitmap.Width to Rect.Right div FBitmap.Width do
BitBlt(Canvas.Handle, J * FBitmap.Width - Rect.Left, I * FBitmap.Height - Rect.Top,
FBitmap.Width, FBitmap.Height, FBitmap.Canvas.Handle, 0, 0, SRCCOPY);
end;procedure TMyPanel.SetBitmap(const Value: TBitmap);
begin
FBitmap.Assign(Value);
end;end.