Justify Qrddrichtext

Asked

Viewed 1,135 times

1

I’m creating a report in Delphi using the QuickReport.

In the Database I write a formatted text (this eh, with justified parts, others aligned to the left other centralized).

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’m not getting!

1 answer

2

As far as I know, real problem is that the component does not support justified alignment, what you can do and if you have knowledge to do so, is, change the class of the component and add this property, this is High level.

How to get around the situation?

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

Here a Procedure that might 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 abandoned Qreport centuries ago due to this nonsense due to lack of implementation, Reports rough and hard to format! There are good tools nowadays for easy use such as FastReport or RaveReport. Among others...

  • the rich and dbrich are ok, the bad eh that the quickreport is used in a report generator here from the company, so it is not so easy to abandon it

  • did not understand. vc meant "There are good tools nowadays easy to use as "nothing"? is it? = P

  • 1

    The friend sorry me, is who cut when I sent the reply from the text editor! , I will edit and add!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.