写得比较匆忙,下面的代码是把panel的东西,画到一个image里面去,你可以用下面的bmp变量,是内存里面的一幅图片,怎么处理都可以
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, ExtCtrls, jpeg;
type
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
Panel2: TPanel;
Image1: TImage;
Button2: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
bmp : TBitmap;
DestR, SourceR : TRect;
begin
bmp := TBitmap.Create;
bmp.Width := Panel1.Width;
bmp.Height := Panel1.Height;
DestR := Rect(0, 0, bmp.Width, bmp.Height);
SourceR := Rect(Panel1.Left, Panel1.Top, Panel1.Left + Panel1.Width, Panel1.Height + Panel1.Top) ;
bmp.Canvas.CopyRect(DestR, Form1.Canvas, SourceR);
Image1.Picture.Assign(bmp);
bmp.Free;
end;
end.
object Form1: TForm1
Left = 143
Top = 98
Width = 765
Height = 366
BorderIcons = [biSystemMenu, biMinimize]
Caption = '演示拷贝Panel内容'
Color = clBtnFace
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = '宋体'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PixelsPerInch = 96
TextHeight = 12
object Panel1: TPanel
Left = 16
Top = 8
Width = 361
Height = 273
Caption = 'Panel1'
TabOrder = 0
object Label1: TLabel
Left = 68
Top = 40
Width = 36
Height = 12
Caption = 'Label1'
end
object Label2: TLabel
Left = 96
Top = 96
Width = 36
Height = 12
Caption = 'Label2'
end
object Label3: TLabel
Left = 108
Top = 144
Width = 36
Height = 12
Caption = 'Label3'
end
object Button2: TButton
Left = 224
Top = 76
Width = 75
Height = 25
Caption = 'Button2'
TabOrder = 0
end
object Memo1: TMemo
Left = 116
Top = 176
Width = 185
Height = 89
ImeName = '中文 (简体) - 拼音加加3.11'
Lines.Strings = (
'Memo1')
TabOrder = 1
end
end
object Button1: TButton
Left = 668
Top = 296
Width = 75
Height = 25
Caption = '拷贝'
TabOrder = 1
OnClick = Button1Click
end
object Panel2: TPanel
Left = 384
Top = 8
Width = 361
Height = 273
Caption = 'Panel2'
TabOrder = 2
object Image1: TImage
Left = 1
Top = 1
Width = 359
Height = 271
Align = alClient
AutoSize = True
Center = True
end
end
end