我用DBMemo1關聯一個備注型字段(text型),輸入多行後。
打印,用QRDBRichText1捆定該字段。我的問題是:能不能
判斷QRDBRichText1顯示了幾行,好動態分配空間。(或者
能知道數據庫中的該字段是幾行也可以)
請高手賜教。謝。

解决方案 »

  1.   

    function TMyClass.LinesVisible(AMemo: TObject): integer;  对Memo管用,传MEmo进去
    Var
      OldFont: HFont;
      Hand: THandle;
      TM: TTextMetric;
      Rect: TRect;
      tempint: integer;
    begin
      Hand := GetDC((AMemo as TMemo).Handle);
      try
        OldFont := SelectObject(Hand, (AMemo as TMemo).Font.Handle);
        try
          GetTextMetrics(Hand, TM);
          (AMemo as TMemo).Perform(EM_GETRECT, 0, longint(@Rect));
          tempint := (Rect.Bottom - Rect.Top) div
             (TM.tmHeight + TM.tmExternalLeading);
        finally
          SelectObject(Hand, OldFont);
        end;
      finally
        ReleaseDC((AMemo as TMemo).Handle, Hand);
      end;
      Result := tempint;
    end;