K
kouchun
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses Windows, SysUtils, Messages, Classes, Graphics, Controls,
StdCtrls, ExtCtrls, Forms, Quickrpt, QRCtrls;
type
TQuickReport1 = class(TQuickRep)
private
public
end;
var
QuickReport1: TQuickReport1;
implementation
{$R *.DFM}
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm2 = class(TForm)
QuickRep1: TQuickRep;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
end.
unit1 中的是獨立的一個quick report , unit2中的是在一張form 上放的一個quick report,現我要在第3張form 中分別動態創建unit1 和 unit2 ,代碼如下:
if NOT Assigned( QuickReport1) then
begin
Application.CreateForm( TQuickReport1, QuickReport1);
with QuickReport1do
begin
PreviewModal;
end;
freeAndNil( QuickReport1);
end;
if NOT Assigned( Form2) then
begin
Application.CreateForm( TForm2, Form2);
with Form2.QuickReport1do
begin
PreviewModal;
end;
freeAndNil( Form2 );
end;
1.) 第一種方法經常會出現內存報錯, 第2種卻很少出現....到底是什麼原因??
2.) Application.CreateForm( TForm2, Form2)
Form2 := TForm2.Create(self)
With TForm2.Create(self)do
這幾種create 方法本質上到底是不是一樣的,那個最安全?
3.) 還有quick report 是不是在線程上運行的??
interface
uses Windows, SysUtils, Messages, Classes, Graphics, Controls,
StdCtrls, ExtCtrls, Forms, Quickrpt, QRCtrls;
type
TQuickReport1 = class(TQuickRep)
private
public
end;
var
QuickReport1: TQuickReport1;
implementation
{$R *.DFM}
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm2 = class(TForm)
QuickRep1: TQuickRep;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
end.
unit1 中的是獨立的一個quick report , unit2中的是在一張form 上放的一個quick report,現我要在第3張form 中分別動態創建unit1 和 unit2 ,代碼如下:
if NOT Assigned( QuickReport1) then
begin
Application.CreateForm( TQuickReport1, QuickReport1);
with QuickReport1do
begin
PreviewModal;
end;
freeAndNil( QuickReport1);
end;
if NOT Assigned( Form2) then
begin
Application.CreateForm( TForm2, Form2);
with Form2.QuickReport1do
begin
PreviewModal;
end;
freeAndNil( Form2 );
end;
1.) 第一種方法經常會出現內存報錯, 第2種卻很少出現....到底是什麼原因??
2.) Application.CreateForm( TForm2, Form2)
Form2 := TForm2.Create(self)
With TForm2.Create(self)do
這幾種create 方法本質上到底是不是一樣的,那個最安全?
3.) 還有quick report 是不是在線程上運行的??