怎样打印TPanel中的所有东西(包括图像、图形Shape、文本)? (100分)

  • 主题发起人 主题发起人 Vinson
  • 开始时间 开始时间
componentcount得到成员数量
components.name得到名称
.............classname得到类名
再下去就不知道你是什么意思了
 
ReportMachine
http://rmachine.y365.com/
 
我也有此难题!!渴求答案!!!!
 
有人知道怎么做吗?我发这个帖子已经半年多了![:(]
 
这里有一些代码,你试一试
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls ,Clipbrd, Grids, jpeg, ComCtrls,Printers;
type
TForm1 = class(TForm)
Panel1: TPanel;
Image1: TImage;
Label1: TLabel;
Image2: TImage;
Image3: TImage;
Image4: TImage;
CheckBox1: TCheckBox;
RadioButton1: TRadioButton;
StatusBar1: TStatusBar;
DisplayButton: TButton;
ExitButton: TButton;
PrintButton: TButton;
procedure DisplayButtonClick(Sender: TObject);
procedure ExitButtonClick(Sender: TObject);
procedure PrintButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
function PanelImage(aPanel:TPanel): TBitmap;
var
Ofs: Integer;
begin
Result := TBitmap.Create;
try
Result.Width := aPanel.ClientWidth;
Result.Height := aPanel.ClientHeight;
Result.Canvas.Brush :=aPanel.Brush;
Result.Canvas.FillRect(aPanel.ClientRect);
Result.Canvas.Lock;
try
if GetWindowLong(aPanel.Handle, GWL_STYLE) and WS_BORDER <> 0 then
Ofs := -1 //do
n't Panel form border
else
Ofs := 0;
// There is no border
aPanel.PaintTo(Result.Canvas.Handle, Ofs, Ofs);
finally
Result.Canvas.Unlock;
end;
except
Result.Free;
raise;
end;
end;
procedure TForm1.DisplayButtonClick(Sender: TObject);
var
FormImage: TBitmap;
begin
FormImage := PanelImage(Panel1);
try
//Clipboard.Assign(FormImage);
Image2.Picture.Assign(FormImage);
finally
FormImage.Free;
end;

end;

procedure TForm1.ExitButtonClick(Sender: TObject);
begin
Close;
end;

procedure TForm1.PrintButtonClick(Sender: TObject);
var
FormImage: TBitmap;
begin
FormImage := PanelImage(Panel1);
Printer.begin
Doc;
Printer.Canvas.Draw(20,20,FormImage);
Printer.EndDoc;
end;

end.
 
接受答案了.
 
后退
顶部