谁能帮我看看这段代码哪里错了!(100分)

  • 主题发起人 主题发起人 Butian
  • 开始时间 开始时间
B

Butian

Unregistered / Unconfirmed
GUEST, unregistred user!
你先放一个TQRPreview控件,然后在QRReport的OnPreview事件中写上
procedure TForm1.QuickRep1Preview(Sender: TObject);
begin
QRPreview1.QRPrinter := TQRPrinter(Sender);
end;
然后在Form.Show中写
procedure TForm1.FormShow(Sender: TObject);
begin
QuickRep1.Preview;
end;
最后放一个Button写OnClick
procedure TForm1.Button1Click(Sender: TObject);
var
E: TMetaFile;
B: TBitmap;
begin
E := QRPreview1.QRPrinter.GetPage(1);
//想要第几页就GetPage几,从1开始
B := TBitmap.Create;
try
with TMetafileCanvas.Create(E, 0)do
try
B.Height := E.Height;
B.Width := E.Width;
B.Canvas.Draw(0, 0, E);
B.SaveToFile('C:/B.bmp');
finally
Free;
end;
finally
B.Free;
end;
end;

 
这么久了,还没有回复!
唉!
 
提示说出什么错?看了代码,没发现有错的地方啊?[?]
 
缺少语句
E := TMetafile.Create;
把它加在语句
with TMetafileCanvas.Create(E, 0)do
之前即可;
 
with TMetafileCanvas.Create(E, 0)do
这句应该就是create了E了。。。
 
已经Create过了。
在E := QRPreview1.QRPrinter.GetPage(1);
中QRPrinter=()什么意思?
所以E=Nil!
 
又没人理我了!!!
 
什么!!!
不懂??
 
This example shows how to create or augment a metafile using a metafile canvas
object. This metafile can then
be used to draw on the canvas of another object
such as a paintbox or a printer.
MyMetafile := TMetafile.Create;
with TMetafileCanvas.Create(MyMetafile, 0)do
try
Brush.Color := clRed;
Ellipse(0,0,100,100);
...
finally
Free;
end;
Form1.Canvas.Draw(0,0,MyMetafile);
{1 red circle }
To add to an existing metafile image, create a metafile canvas and play the
source metafile into the metafile canvas:
with TMetafileCanvas.Create(MyMetafile, 0)do
try
Draw(0,0,MyMetafile);
Brush.Color := clBlue;
Ellipse(100,100,200,200);
...
finally
Free;
end;
Form1.Canvas.Draw(0,0,MyMetafile);
{1 red circle and 1 blue circle }
 
后退
顶部