杀
杀大龙
Unregistered / Unconfirmed
GUEST, unregistred user!
例子
// pas, 请先把 image1拉大一点。 显示背景更清楚, image2导入一幅背景图片
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, jpeg, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
procedure print;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.print;
begin
//清理
image1.Picture := nil;
//打印背景,背景存在image2; 它可以是jpg 或bmp; 这里的打印背景模式是”充满“
image1.Canvas.StretchDraw(image1.ClientRect,image2.Picture.Graphic);
//设置为“透明“字体,为打印文字做准备;
image1.Canvas.Brush.Style := bsClear;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
print;
// 打印两个 label 的内容
image1.Canvas.TextOut(5,5,label1.caption);
image1.Canvas.TextOut(25,25,label2.caption);
end;
end.
随便给窗体文件,注意两个名字相同,此后缀为dfm;窗体文件不包括图片,自己
导入吧。
object Form1: TForm1
Left = 193
Top = 117
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Image1: TImage
Left = 48
Top = 24
Width = 233
Height = 209
end
object Image2: TImage
Left = 368
Top = 48
Width = 105
Height = 105
Stretch = True
end
object Label1: TLabel
Left = 320
Top = 176
Width = 92
Height = 13
Caption = 'wosldfjs fslfjksdlfjkls'
end
object Label2: TLabel
Left = 320
Top = 200
Width = 101
Height = 13
Caption = 'sdfsfsdfdkfskdfjklsdfk'
end
object Button1: TButton
Left = 216
Top = 288
Width = 75
Height = 25
Caption = 'printText'
TabOrder = 0
OnClick = Button1Click
end
end
// pas, 请先把 image1拉大一点。 显示背景更清楚, image2导入一幅背景图片
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, jpeg, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
procedure print;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.print;
begin
//清理
image1.Picture := nil;
//打印背景,背景存在image2; 它可以是jpg 或bmp; 这里的打印背景模式是”充满“
image1.Canvas.StretchDraw(image1.ClientRect,image2.Picture.Graphic);
//设置为“透明“字体,为打印文字做准备;
image1.Canvas.Brush.Style := bsClear;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
print;
// 打印两个 label 的内容
image1.Canvas.TextOut(5,5,label1.caption);
image1.Canvas.TextOut(25,25,label2.caption);
end;
end.
随便给窗体文件,注意两个名字相同,此后缀为dfm;窗体文件不包括图片,自己
导入吧。
object Form1: TForm1
Left = 193
Top = 117
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Image1: TImage
Left = 48
Top = 24
Width = 233
Height = 209
end
object Image2: TImage
Left = 368
Top = 48
Width = 105
Height = 105
Stretch = True
end
object Label1: TLabel
Left = 320
Top = 176
Width = 92
Height = 13
Caption = 'wosldfjs fslfjksdlfjkls'
end
object Label2: TLabel
Left = 320
Top = 200
Width = 101
Height = 13
Caption = 'sdfsfsdfdkfskdfjklsdfk'
end
object Button1: TButton
Left = 216
Top = 288
Width = 75
Height = 25
Caption = 'printText'
TabOrder = 0
OnClick = Button1Click
end
end