Delphi中能把窗口打印出来吗?(50分)

  • 主题发起人 主题发起人 两只小猪
  • 开始时间 开始时间

两只小猪

Unregistered / Unconfirmed
GUEST, unregistred user!
我想把运行后的窗口中的东西按原样排列打印出来,能不能直接打印窗口呢,该怎么做?
或者把Panel中的打印出来也行 ,望大侠指点!!!
 
unit u_prev;

interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
qrprntr, ComCtrls, ToolWin, ExtCtrls, Menus, ImgList, StdCtrls, comobj, Grids,
Db, DBTables, QuickRpt;

type
Tf_prev = class(TForm)
QRPreview1: TQRPreview;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
ToolButton8: TToolButton;
ToolButton10: TToolButton;
ImageList1: TImageList;
ToolButton4: TToolButton;
ToolButton9: TToolButton;
ToolButton11: TToolButton;
ToolButton12: TToolButton;
ToolButton13: TToolButton;
StatusBar1: TStatusBar;
PopupMenu1: TPopupMenu;
N751: TMenuItem;
N501: TMenuItem;
N251: TMenuItem;
PopupMenu2: TPopupMenu;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
PrintersetupDialog1: TPrinterSetupDialog;
PrintDialog1: TPrintDialog;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N1001: TMenuItem;
N1101: TMenuItem;
N1251: TMenuItem;
N7551: TMenuItem;
N502: TMenuItem;
N252: TMenuItem;
ToolButton14: TToolButton;
SaveDialog1: TSaveDialog;
N15: TMenuItem;
StringGrid1: TStringGrid;
Query1: TQuery;
StringGrid2: TStringGrid;
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure QRPreview1PageAvailable(Sender: TObject;
PageNum: Integer);
procedure ToolButton7Click(Sender: TObject);
procedure ToolButton8Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton10Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ToolButton13Click(Sender: TObject);
procedure N751Click(Sender: TObject);
procedure N501Click(Sender: TObject);
procedure N251Click(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure MenuItem2Click(Sender: TObject);
procedure MenuItem3Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N14Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N1001Click(Sender: TObject);
procedure N1101Click(Sender: TObject);
procedure N1251Click(Sender: TObject);
procedure N7551Click(Sender: TObject);
procedure N502Click(Sender: TObject);
procedure N252Click(Sender: TObject);
procedure ToolButton14Click(Sender: TObject);
procedure N15Click(Sender: TObject);
procedure SaveExcel(psSaveFile :string);
private
{ Private declarations }
public
{ Public declarations }
end;

var
f_prev: Tf_prev;
pagecount:integer;
implementation
uses pass;
{$R *.DFM}
procedure Tf_prev.FormClose(Sender: TObject;
var Action: TCloseAction);
begin

try
qrpreview1.qrprinter:=nil;
qrpreview1.qrprinter.free;
stringgrid1.Destroy;
except
end;

end;

procedure Tf_prev.ToolButton2Click(Sender: TObject);
begin

qrpreview1.ZoomToWidth;
end;

procedure Tf_prev.ToolButton5Click(Sender: TObject);
begin

if pagecount=0 then
exit;
qrpreview1.pagenumber:=1;
toolbutton5.enabled:=false;
toolbutton6.enabled:=false;
if pagecount>1 then

begin

toolbutton7.enabled:=true;
toolbutton8.enabled:=true;
end
else
begin

toolbutton7.enabled:=false;
toolbutton8.enabled:=false;
end
 
怎么那么多按钮,看不懂啊,能不能明白点?
 
用RMFormReport控件可以指定Panel控件打印的!我用他作过完税凭证打印!没问题!
OK啦,要给分啊!
 
RMFormReport控件在哪里啊?具体怎么用,能详细点吗?
 
帮帮忙啊,解决了问题分数奉送
 
procedure TForm1.btn1Click(Sender: TObject);
begin
Printer.begin
Doc;
Form1.PaintTo(printer.Handle,10,10);
printer.EndDoc;
end;
 
from1.Print ;
不就是一句话吗?
还用搞得那么麻烦,贴那么多代码
 
刚刚试了一下,用Leehawk老兄给出的代码
procedure TForm1.btn1Click(Sender: TObject);
begin
Printer.begin
Doc;
Form1.PaintTo(printer.Handle,10,10);
printer.EndDoc;
end;
可以打印窗口,可是窗口中paintbox控件中的曲线图打不出来啊?
怎么回事?
 
http://2552.tomore.com/2/3939.html
下载试一下!如果要打图的话需要有RMPrintChart
RMFormReport1.PrintControl := quickrep1;
if TButton(Sender).tag = 1 then
RMFormReport1.PrintReport
else
RMFormReport1.ShowReport;
自己好好用用,功能很多,我只用个打印窗口和曲线图两个功能,有新发现可以告诉我一声!
 
我把图复制到Image中就可以打印出来了
可是很小,怎么才能把窗口上的按打印机输出的图纸的比例打印出来呢?
 
多人接受答案了。
 
后退
顶部