1、第一次调用打印窗口,正常显示。但关闭它,再打开它qrrichtext1是空白,没显示出来。2、退出系统后,系统出现。窗口句柄无效。。,就是说的我那个qrrichtext1。怎么办啊?愁死我了。

解决方案 »

  1.   

    试试看
    QRRichText1.Text.Assign(ADOQuery.FieldValues['文章名称']);
      

  2.   

    这应该不是QRREPORT的问题,你再查查别的方向。例如RTF的DLL是否安装正确等。
      

  3.   

    我没用什么DLL啊。
    大家真的没有解决方案了吗?
      

  4.   

    对于第一个问题,我不是在beforeprint中打印的,而是在quickRep的OnNeedData事件中给它赋的值,好像没有你说的问题,而第二个问题好像与qrrichText无关,是不是你程序其他地方内存出错引起的,再检查一下。给你段代码作参考吧
    unit LaiWenReport;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ExtCtrls, QuickRpt, Qrctrls, QRPrntr;type
      TfrmLaiWenReport = class(TForm)
        QuickRep1: TQuickRep;
        QRBand1: TQRBand;
        QRExpr1: TQRExpr;
        QRBand2: TQRBand;
        QRLabel1: TQRLabel;
        QRLabel3: TQRLabel;
        QRShape3: TQRShape;
        QRLabel4: TQRLabel;
        QRShape5: TQRShape;
        QRShape8: TQRShape;
        QRShape9: TQRShape;
        QRLabel5: TQRLabel;
        QRLabel6: TQRLabel;
        QRBand3: TQRBand;
        QRDBText1: TQRDBText;
        QRDBText3: TQRDBText;
        QRShape4: TQRShape;
        QRDBText4: TQRDBText;
        QRShape6: TQRShape;
        QRShape7: TQRShape;
        QRShape10: TQRShape;
        QRRichText1: TQRRichText;
        procedure QuickRep1Preview(Sender: TObject);
        procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
          var PrintReport: Boolean);
        procedure QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      frmLaiWenReport: TfrmLaiWenReport;implementationuses datamodual, ViewReport;
    {$R *.DFM}procedure TfrmLaiWenReport.QuickRep1Preview(Sender: TObject);
    begin
        frmViewReport.QRPreview1.QRPrinter := TQRPrinter(Sender);
    end;procedure TfrmLaiWenReport.QuickRep1BeforePrint(Sender: TCustomQuickRep;
      var PrintReport: Boolean);
    begin
        DMod.qryLWReport.First;
    end;procedure TfrmLaiWenReport.QuickRep1NeedData(Sender: TObject;
      var MoreData: Boolean);
    var
        i, inteval: Integer;
    begin
        MoreData := true;
        QRRichText1.Lines.Clear;
        QRRichText1.Lines.Add(DMod.qryLWReport.FieldByName('title').AsString);
        //以下是动态计算中间分割竖线的长度
        i := strlen(PChar(DMod.qryLWReport.FieldByName('title').AsString));
        inteval := QRRichText1.Width div QRRichText1.Font.Size;
        i := (i - i mod inteval) div inteval;
        QRShape4.Height := (i + 1) * QRBand3.Height;
        QRShape6.Height := (i + 1) * QRBand3.Height;
        QRShape7.Height := (i + 1) * QRBand3.Height;
        QRShape10.Height := (i + 1) * QRBand3.Height;
        if DMod.qryLWReport.Eof then
            MoreData := false;
        DMod.qryLWReport.Next;
    end;end.
      

  5.   

    另外你也可以试试这种办法,我朋友以前做过,就是使用TDBMemo链接数据库的某个字段,然后要赋值时先将其赋值给一个TMemo(当然都要设置成自动换行的那种),然后再从TMemo赋值给一个TQRMemo,
    Memo.Lines.Text := DBMemo.Lines.Text;
    QRMemo.Lines := Memo.Lines;  (前后赋值得方法不一样)
    你可以参考看看