将代码贴上
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
application.CreateForm(tform2,form2);
form2.ShowModal;
form2.Free;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, QRPrntr, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses unit1,unit4;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
application.CreateForm(tform4,form4);
form4.QuickRep1.Preview;
end;
procedure TForm2.FormShow(Sender: TObject);
begin
form1.Hide;
end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form1.Show;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
close;
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, QuickRpt, StdCtrls, QRPrntr;
type
TForm3 = class(TForm)
QRPreview1: TQRPreview;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses unit2;
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
begin
close;
end;
procedure TForm3.FormShow(Sender: TObject);
begin
form2.Hide;
end;
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form2.Show;
end;
end.
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, QuickRpt;
type
TForm4 = class(TForm)
QuickRep1: TQuickRep;
procedure QuickRep1Preview(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
uses unit3;
{$R *.dfm}
procedure TForm4.QuickRep1Preview(Sender: TObject);
begin
form3.qrpreview1.QRPrinter:=quickrep1.QRPrinter;
form3.Show;
end;
end.
其中用到了quickreport
form1.button1调出打印窗体form2;
form2.button1调出预览窗体form3,form3中的QRPreview1对form4中的QuickRep1内容进行预览.
问题出在预览后用form3.button1退出,将隐藏的form2恢复显示时,form2不可用!!!