关于fastreport的动态建立报表问题.(100分)

  • 主题发起人 主题发起人 newmaid
  • 开始时间 开始时间
N

newmaid

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在要在ManualBuild事件中建立一动态的TFrMemoview控件.建立不成功(显示不出来).
但是,原来在fastreport中的frmemoview控件就显示得出来.不解?!
procedure TForm1.fr1ManualBuild(Page: TfrPage);
var v :tfrmemoview;
begin
v := TfrMemoView.Create;

v.SetBounds(140, 240, 100, 100);
v.Prop['Alignment'] := frtaCenter;

v.Prop['Font.size'] := 14;
v.Prop['Font.name'] := '隶书';
v.Name := 'demo1';
v.Memo.Text := '测试';
Page.Objects.Add(v);
//page.ShowBandByName('主项数据1');
end;
请问有什么不对吗?请大家指教,新手,请不吝指教,万分感谢!!!!
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, FR_Class, StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
fr_Tree_Print: TfrReport;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
fr: TfrReport;
ACanvas: TCanvas;
bmp: TBitmap;
test_r: trect;
procedure textWH(s: string;
f: Tfont;
var W, h: integer);
var
TextRect: Trect;
begin
ACanvas.Font.Assign(f);
DrawText(ACanvas.Handle, pchar(s), -1, TextRect, DT_LEFT or DT_CALCRECT);
DrawText(ACanvas.Handle, pchar(s), -1, TextRect, DT_LEFT);
w := TextRect.right - TextRect.left + 6;
h := TextRect.Bottom - TextRect.top + length(s) div 2 + 2;
end;
procedure Textdraw(var r: trect;
s: string;
f: tfont;
p: tfrpage);
var
fm: TfrMemoView;
W, h: integer;
begin

fm := TfrMemoView.Create;
fm.Prop['textonly'] := true;
fm.Prop['ALIGNMENT'] := 2;
fm.Font.Assign(f);
fm.Prop['top'] := r.Top;
fm.Prop['left'] := r.Left;
textWH(s, f, w, h);
fm.Prop['width'] := w;
fm.Prop['height'] := h;
r.Bottom := r.Top + h;
r.Right := r.Left + w;
fm.Memo.Text := s;
p.Objects.Add(fm)
end;
begin
fr := fr_Tree_Print;
bmp := TBitmap.Create;
ACanvas := bmp.Canvas;
fr.Pages[0].Clear;
ACanvas.Font.Assign(font);
fr.Pages[0].Clear;
test_r := rect(100, 100, 120, 120);
Textdraw(test_r, '测试', font, fr.Pages[0]);
freeandnil(bmp);
fr.ShowReport;
end;

end.
 
procedure Textdraw(var r: trect;
s: string;
f: tfont;
p: tfrpage);
这个 过程 我整个 系统 都这么用的
 
2楼的同志,我声明是要在ManualBuild事件中建立.不是在其它事件中.
按键事件中是可以正确建立tfrmemoview控件的.谢谢
 
难道是你没有设置 top left width height ?
fm.Prop['top'] := r.Top;
fm.Prop['left'] := r.Left;
textWH(s, f, w, h);
fm.Prop['width'] := w;
fm.Prop['height'] := h;
 
后退
顶部