各位朋友,代码如下,总共有22个问题之多,希望论坛上有耐心的朋友可以详细解答里面所提及的问题,谢谢!!!procedure Textdraw(r: trect; s: string; f: tfont; p: tfrpage; ALIGNMENT, FRAMETYP: integer);//问题1:这个函数的整体作用是什么?
var  //问题2:Trect这个类的作用是什么呢?
{
  PRect = ^TRect;
  TRect = packed record
    case Integer of
      0: (Left, Top, Right, Bottom: Longint);//问题3:里面的几个参数是什么意思?
      1: (TopLeft, BottomRight: TPoint);//问题4:里面的几个参数又是什么意思?什么时候该用0,什么时候该用1?
}
  fm: TfrMemoView;
  W, h: integer;
begin  fm := TfrMemoView.Create;
  fm.Prop['textonly'] := true;
  fm.Prop['ALIGNMENT'] := ALIGNMENT;//问题5:这句是什么意思?
  fm.Font.Assign(f);//问题6:这句又是什么意思,用了这句之后有什么作用?  fm.Prop['top'] := r.Top;//问题7:为什么不直接将一个数值赋给该MEMO的TOP,而需要将R.top的值赋给它,这样有什么作用?
  fm.Prop['left'] := r.Left;//问题8:为什么不直接将一个数值赋给该MEMO的left,而需要将R.left的值赋给它,这样有什么作用?
  fm.Prop['FRAMETYP'] := FRAMETYP;
  fm.Prop['width'] := r.Right - r.Left;//问题9:为什么要将r.Right-r.Left赋给它,而不是直接赋一个值给Width
  fm.Prop['height'] := r.Bottom - r.Top;//问题10:r.Bottom是一个什么属性来的,为什么要将r.Bottom-r.Top赋给它,而不是直接赋一个值给Height
  fm.Memo.Text := s;  p.Objects.Add(fm)
end;procedure TForm1.Button2Click(Sender: TObject);
var
  Arect: TRect;
  pw, ph: integer;
  page: tfrpage;
  x, y, y_Begin_Top: integer;
  textFont: TFont;
  Arow: integer;
  oldF1, nowF1, nowF2, nowF3: string;
  procedure newpage;//问题11:这个过程的整体作用是什么呢?
  begin
    fr.Pages.Add;
    page := fr.Pages[fr.Pages.Count - 1];//问题12:这句话是什么意思?
    pw := fr.Pages[0].Prop['width'];//问题13:将页宽赋值给PW是目的是什么?
    ph := fr.Pages[0].Prop['height'];问题14:将页高赋值给PH的目的又是什么?
    x := 10;//问题15:X和Y的作用是什么?是表示页面的哪个值?
    y := 10;
  end;begin
  fr.Pages[0].Clear;
  fr.Pages.Clear;//问题16:为什么前面已经有了一句Clear,这里又要有一句Clear,这两句Clear有什么作用?
  textFont := TFont.Create;
  textFont.Assign(Font);//问题17:这句是什么意思?
  textFont.Size := 13;
  oldF1 := '';
  for Arow := 1 to ADODataSet1.RecordCount do
    begin      ADODataSet1.RecNo := Arow;
      nowF1 := ADODataSet1.Fieldbyname('f1').AsString;
      nowF2 := ADODataSet1.Fieldbyname('f2').AsString;
      nowF3 := ADODataSet1.Fieldbyname('f3').AsString;
      if (Arow = 0) or (oldF1 <> nowF1) then
        begin
          newpage;
          x := 20;
          y := 20;
          Arect := Rect(x, y, x + 200, y + 20);
{
function Rect(Left, Top, Right, Bottom: Integer): TRect;
begin
  Result.Left := Left;
  Result.Top := Top;
  Result.Bottom := Bottom;
  Result.Right := Right;
end;//问题18:这个Rect函数的作用是什么?里面的各个参数又是表示什么意思?}
          Textdraw(Arect, '详细记录:' + nowF1, textFont, page, 3, 0);
          x := x + 200;
          y := y + 20;          y := y + 4;
          y_Begin_Top := -1;//问题19:这个y_Begin_top变量的作用是什么?
        end;      x := 20;
      Arect := Rect(x, y, x + 100, y + 20);
      Textdraw(Arect, nowF1, textFont, page, 3, 15);
      x := x + 100;      if y_Begin_Top < 0 then
        begin
          y_Begin_Top := y;
        end;      if (Arow = ADODataSet1.RecordCount) then
        begin
          Arect := Rect(x, y_Begin_Top, x + 100, y + 20);
          Textdraw(Arect, nowF2, textFont, page, 11, 15);
          y_Begin_Top := -1;
        end
      else
        begin
          ADODataSet1.RecNo := Arow + 1;
          if (ADODataSet1.Fieldbyname('f1').AsString <> nowF1)
            or
            (ADODataSet1.Fieldbyname('f2').AsString <> nowF2) then
            begin
              Arect := Rect(x, y_Begin_Top, x + 100, y + 20);
              Textdraw(Arect, nowF2, textFont, page, 11, 15);
              y_Begin_Top := -1;
            end;
        end;      x := x + 100;
      Arect := Rect(x, y, x + 100, y + 20);
      Textdraw(Arect, nowF3, textFont, page, 3, 15);      y := y + 20;
      oldF1 := nowF1;
    end;  fr.DesignReport;  fr.PrepareReport;//问题20:这句是什么意思?
  fr.ShowPreparedReport;//问题21:这句又是什么意思,另外,为什么不直接用ft.showreport?
end;//问题22:这个函数在哪个地方是画线的,哪个地方是使数值居中的?

解决方案 »

  1.   

    http://www.2ccc.com/article.asp?articleid=3262下载本电子书看看吧
      

  2.   


    procedure Textdraw(r: trect; s: string; f: tfont; p: tfrpage; ALIGNMENT, FRAMETYP: integer);//问题1:这个函数的整体作用是什么? 
    //-- 创建一个文本框var  //问题2:Trect这个类的作用是什么呢?
    //--标示区域
    {
      PRect = ^TRect;
      TRect = packed record
        case Integer of
          0: (Left, Top, Right, Bottom: Longint);//问题3:里面的几个参数是什么意思?
          1: (TopLeft, BottomRight: TPoint);//问题4:里面的几个参数又是什么意思?什么时候该用0,什么时候该用1?
    }
    //--Left, Top, Right, Bottom 左,上,右,下
    //--TopLeft = 左上    BottomRight: 右下
      fm: TfrMemoView;
      W, h: integer;
    begin  fm := TfrMemoView.Create;
      fm.Prop['textonly'] := true;
      fm.Prop['ALIGNMENT'] := ALIGNMENT;//问题5:这句是什么意思?
    //--对齐方式   fm.Font.Assign(f);//问题6:这句又是什么意思,用了这句之后有什么作用?
    //-- 设置字体 
    //--fm.Font 和 参数f 一样
      fm.Prop['top'] := r.Top;//问题7:为什么不直接将一个数值赋给该MEMO的TOP,而需要将R.top的值赋给它,这样有什么作用?
    //--fastreport 这样规定的  fm.Prop['left'] := r.Left;//问题8:为什么不直接将一个数值赋给该MEMO的left,而需要将R.left的值赋给它,这样有什么作用?
    //--fastreport 这样规定的  fm.Prop['FRAMETYP'] := FRAMETYP;  fm.Prop['width'] := r.Right - r.Left;//问题9:为什么要将r.Right-r.Left赋给它,而不是直接赋一个值给Width
    //--fastreport 这样规定的
      fm.Prop['height'] := r.Bottom - r.Top;//问题10:r.Bottom是一个什么属性来的,为什么要将r.Bottom-r.Top赋给它,而不是直接赋一个值给Height
    //--fastreport 这样规定的  fm.Memo.Text := s;  p.Objects.Add(fm)
    end;procedure TForm1.Button2Click(Sender: TObject);
    var
      Arect: TRect;
      pw, ph: integer;
      page: tfrpage;
      x, y, y_Begin_Top: integer;
      textFont: TFont;
      Arow: integer;
      oldF1, nowF1, nowF2, nowF3: string;
      procedure newpage;//问题11:这个过程的整体作用是什么呢?
    //-- 开始新的一页  begin
        fr.Pages.Add;
        page := fr.Pages[fr.Pages.Count - 1];//问题12:这句话是什么意思?
    // 当前页page  := fr中的最后一页(就是上边 fr.Pages.Add 新加的)    pw := fr.Pages[0].Prop['width'];//问题13:将页宽赋值给PW是目的是什么?
        //-- 暂时没用    ph := fr.Pages[0].Prop['height'];问题14:将页高赋值给PH的目的又是什么?
        //--下面作比较用    x := 10;//问题15:X和Y的作用是什么?是表示页面的哪个值?
        y := 10;
        //-- 自己用的变量 算位置用的  end;begin
      fr.Pages[0].Clear;
      //-- 可以去掉  fr.Pages.Clear;//问题16:为什么前面已经有了一句Clear,这里又要有一句Clear,这两句Clear有什么作用?
    //-- 清空所有的页  textFont := TFont.Create;
      textFont.Assign(Font);//问题17:这句是什么意思?
      //--将 textFont 设置的 和 窗体的 字体 一样  textFont.Size := 13;
      oldF1 := '';
      for Arow := 1 to ADODataSet1.RecordCount do
        begin      ADODataSet1.RecNo := Arow;
          nowF1 := ADODataSet1.Fieldbyname('f1').AsString;
          nowF2 := ADODataSet1.Fieldbyname('f2').AsString;
          nowF3 := ADODataSet1.Fieldbyname('f3').AsString;
          if (Arow = 0) or (oldF1 <> nowF1) then
            begin
              newpage;
              x := 20;
              y := 20;
              Arect := Rect(x, y, x + 200, y + 20);
    {
    function Rect(Left, Top, Right, Bottom: Integer): TRect;
    begin
      Result.Left := Left;
      Result.Top := Top;
      Result.Bottom := Bottom;
      Result.Right := Right;
    end;//问题18:这个Rect函数的作用是什么?里面的各个参数又是表示什么意思?
    //--就是获得一个 TRect  左,上,右,下
    }
              Textdraw(Arect, '详细记录:' + nowF1, textFont, page, 3, 0);
              x := x + 200;
              y := y + 20;          y := y + 4;
              y_Begin_Top := -1;//问题19:这个y_Begin_top变量的作用是什么?
             //--y_Begin_Top  记录要合并的那个字段 的  上(垂直开始) 位置。
            end;      x := 20;
          Arect := Rect(x, y, x + 100, y + 20);
          Textdraw(Arect, nowF1, textFont, page, 3, 15);
          x := x + 100;      if y_Begin_Top < 0 then
            begin
              y_Begin_Top := y;
            end;      if (Arow = ADODataSet1.RecordCount) then
            begin
              Arect := Rect(x, y_Begin_Top, x + 100, y + 20);
              Textdraw(Arect, nowF2, textFont, page, 11, 15);
              y_Begin_Top := -1;
            end
          else
            begin
              ADODataSet1.RecNo := Arow + 1;
              if (ADODataSet1.Fieldbyname('f1').AsString <> nowF1)
                or
                (ADODataSet1.Fieldbyname('f2').AsString <> nowF2) then
                begin
                  Arect := Rect(x, y_Begin_Top, x + 100, y + 20);
                  Textdraw(Arect, nowF2, textFont, page, 11, 15);
                  y_Begin_Top := -1;
                end;
            end;      x := x + 100;
          Arect := Rect(x, y, x + 100, y + 20);
          Textdraw(Arect, nowF3, textFont, page, 3, 15);      y := y + 20;
          oldF1 := nowF1;
        end;  fr.DesignReport;  fr.PrepareReport;//问题20:这句是什么意思?
      //-- 准备 报表  fr.ShowPreparedReport;//问题21:这句又是什么意思,另外,为什么不直接用ft.showreport?
      //-- 预览已经准备好的报表
      //-- 两句 可以 由 ft.showreport 代替  
    end;//问题22:这个函数在哪个地方是画线的,哪个地方是使数值居中的?
    //--fm.Prop['FRAMETYP'] FRAMETYP 画线
    //--fm.Prop['ALIGNMENT'] 数值居中