Justify QRDDRichText

1

I'm creating a report in Delphi using QuickReport .

In the database I write formatted text (ie, with justified parts, other aligned left-centered ones).

To justify the text in TDBrichedt I used the following code:

procedure TfrmAnotacoes.FormShow(Sender: TObject);
begin
  inherited;
  SendMessage(edtAnot.handle,
              EM_SETTYPOGRAPHYOPTIONS,
              TO_ADVANCEDTYPOGRAPHY,
              TO_ADVANCEDTYPOGRAPHY)
end;



    procedure TfrmAnotacoes.JustifyRichEdit(RichEdit :TCustomRichEdit; AllText :Boolean);
    var
      ParaFormat :TParaFormat;
      SelStart,
      SelLength :Integer;
    begin
      ParaFormat.cbSize := SizeOf(ParaFormat);
        SelStart := RichEdit.SelStart;
        SelLength := RichEdit.SelLength;
        if AllText then
          RichEdit.SelectAll;
        ParaFormat.dwMask := PFM_ALIGNMENT;
        ParaFormat.wAlignment := PFA_JUSTIFY;
        SendMessage(RichEdit.handle, EM_SETPARAFORMAT, 0, LongInt(@ParaFormat));
    // Restaura seleção caso tenhamos mudado para All
        RichEdit.SelStart := SelStart;
        RichEdit.SelLength := SelLength;
    end;

I would like to justify the text in QRDBRichText as it comes from the bank, but I can not!

    
asked by anonymous 21.12.2015 / 15:01

1 answer

2

As far as I know, the real problem is that the component does not support justified alignment, what you can do and if you are aware of it, is to change the component class and add this property, ie High level. p>

How to circumvent the situation?

Format the text in a common Rich in the form, when calling the DBRich you pass the text to it, in reading the Bank data to DBRich it really loses formatting!

Here's a% of what can help you:

{uses RichEdit;}
procedure JustifyText;
  var Format: TParaFormat2; // declarada na RichEdit.pas
begin
  FillChar(Format, SizeOf(TParaFormat2), 0);
  Format.cbSize := SizeOf(TParaFormat2);
  Format.dwMask := PFM_ALIGNMENT; 
  Format.wAlignment := PFA_JUSTIFY;
{Dependendo da implementação do componente, o paragrafo sairá alinhado a esquerda ao invés de justificado. Neste caso será necessário atualizar para um compativel com o formato RTF 3.0}
  SendMessage(RichEdit.Handle, EM_SETPARAFORMAT, 0, LPARAM(@Format));
end;

PS: I quit QReport for centuries because of these nonsense for lack of implementation, rough reports and difficult to format! There are good tools available nowadays as Procedure or FastReport . Among others ...

    
21.12.2015 / 16:36