要答就答这样的问题@@@@@ (30分)

  • 主题发起人 主题发起人 small pig
  • 开始时间 开始时间
S

small pig

Unregistered / Unconfirmed
GUEST, unregistred user!
大家替我解决问题,我的程序没写好,望富翁来完成,点击Button1按钮,DBEDIT等控件不能打印出来,如果frReport1.ShowReport;加在procedure TForm2.LoadControl(Control: TControl);过程最后一行,每次FRREPORT SHOW一次就在报表中显示一个窗体上的控件,点关闭报表,又显示第二个,直到没有,问:怎么修改我的代码在FASTREPORT显示窗体上要俘获的控件,
private
lTitleY, lGridY, lGridH: Integer;
Page: TfrPage;
public
procedure LoadControl(Control: TControl);
//为各种图象控件赋值
function GetPoint(Control: TControl): TPoint;//得到控件在窗体上的位置
function ViewAssign(m1: TfrMemoView;
Control: TControl): Boolean;//
end;

var
Form2: TForm2;
implementation
{$R *.dfm}
const
C_LEFT = 20;
C_HEIGHT = 20;
function TForm2.ViewAssign(m1: TfrMemoView;
Control: TControl): Boolean;
begin
Result := true;
if Control is TLabel then
begin
//标准控件
m1.Font.Assign(TLabel(Control).Font);
m1.Memo.Text := TLabel(Control).Caption;
end
else
if Control is TDBEdit then
begin
m1.Font.Assign(TDBEdit(Control).Font);
m1.Memo.Text := TDBEdit(Control).Text;
end
else
if Control is TDBMemo then
begin
m1.Font.Assign(TDBMemo(Control).Font);
m1.Memo.Assign(TDBMemo(Control).Lines);
end
else
Result := false;
end;

function TForm2.GetPoint(Control: TControl): TPoint;
var
Point: TPoint;
begin
Point.x := 0;
Point.y := 0;
Point := Control.ClientToScreen(point);
Point := Form2.ScreenToClient(Point);
Result := Point;
end;

procedure TForm2.LoadControl(Control: TControl);
var
m: TfrMemoView;
BandDetail: TfrBandView;
begin
frReport1.Pages.Clear;
frReport1.Pages.Add;
Page := frReport1.Pages[0];
//附加一页
BandDetail := TfrBandView(frCreateObject(gtBand, ''));
BandDetail.BandType := btMasterData;
BandDetail.Name := 'BandDetail';
Page.Objects.Add(BandDetail);
BandDetail.SetBounds(0, C_HEIGHT * 3, 0, 0);
if Control.Parent.Visible = False then
exit;
m := TfrMemoView(frCreateObject(gtMemo, ''));
m.gapx := 0;
m.gapy := 0;
m.dx := 0;
m.SetBounds(GetPoint(Control).x + C_LEFT, GetPoint(Control).y + lTitleY,
Control.Width, Control.Height);
if not ViewAssign(m, Control) then
exit;
m.Name := Control.Name;
Page.Objects.Add(m);
end;

procedure TForm2.Button1Click(Sender: TObject);
var
i :integer;
begin
for i := 0 to ComponentCount - 1do
if (TControl(Components).Visible) and (Components is TControl) then
begin
LoadControl(TControl(Components));
end;
frReport1.ShowReport;
end;
 
各位请回答
 

Similar threads

后退
顶部