打印整个form 以及form里面所有内容
解决方案 »
- 判斷血量內存失效......
- delphi+dbexpress+mysql如何发布在别的机器上用
- 无效使用关键字?
- DBGrid 中数据导出到Excel 问题
- 关于csdn的专家分等级
- 用delphi打开excel时候,如何让excel的保存按钮和文件->保存功能失效?
- 有谁用过或见过TIdEncoderMIME和Idbase64Encoder控件的吗?
- 高分简单
- 方法的重载与虚方法.Delphi 高手请进.....
- DBGRID在ADO+SQL环境中的Lookup问题
- TAdoDataSet过滤(Filter)和定位(Locate)时不能区分大小写的问题(在线等待帮助……)
- 关于DELPHI2007的几点疑惑
procedure TFormPrintWindows.ButtonPrintPanelClick(Sender: TObject);
var
Bitmap: TBitmap;
FromLeft, FromTop, PrintedWidth, PrintedHeight: Integer;
begin
Printer.BeginDoc;
try
Bitmap := TBitmap.Create;
try
Bitmap.Width := Panel1.Width;
Bitmap.Height := Panel1.Height;
Bitmap.PixelFormat := pf24bit; {Avoid palettes}
{Copy the panel area from the form into a separate bitmap}
Bitmap.Canvas.CopyRect(Rect(0, 0, Bitmap.Width, Bitmap.Height), FormPrintWindows.Canvas,
Rect(Panel1.Left, Panel1.Top, Panel1.Left + Panel1.Width - 1,
Panel1.Top + Panel1.Height - 1) );
{Assumes 10% left, right and top margin}
{Assumes bitmap aspect ratio > ~0.75 for portrait mode}
PrintedWidth := MulDiv(Printer.PageWidth, 80, 100); {80%}
PrintedHeight := MulDiv(PrintedWidth, Bitmap.Height, Bitmap.Width);
FromLeft := MulDiv(Printer.PageWidth, 10, 100); {10%}
FromTop := MulDiv(Printer.PageHeight, 10, 100); {10%}
PrintBitmap(Printer.Canvas, Rect(FromLeft, FromTop, FromLeft + PrintedWidth,
FromTop + PrintedHeight), Bitmap);
finally
Bitmap.Free
end;
finally
Printer.EndDoc
end;
end;