Justificar Textos

16/12/2003

0

Bom pessoal encontrei isso no help do delphi
BOOL SetTextJustification(

HDC hdc,// handle of device context
int nBreakExtra,// length of extra space, in logical units
int nBreakCount // count of space characters in line of text
);
e isso:
in the first paragraph, the text was not justified; in the second paragraph, the text was justified by calling the GetTextExtentPoint32 and SetTextJustification functions.
que mostra numa figura um texto sem justificar e outro justificado, porém não consegui usar a função SetTExtJustification, tentei assim:

SetTextJustification(RichEdit1.Handle, COntaEspacoEmBranco(RichEdit1.Text), RichEdit1.Lines.Count);
Simplesmente não faz nada, nem erro dá, testei em tempo de execução mudar o alinhamento para direita, esquerda, centro, porém não sai da configuração que está em tempo de projeto. Alguém já usou esta função SetTextJustification. Se já me passem um exemplo.

Desde já agradeço.


Fabio Colli

Fabio Colli

Responder

Posts

16/12/2003

Fabio.hc

Tente esta função:

function Justifica(mCad:string;mMAx:integer):string;
var
   mPos,mPont,mTam,mNr,mCont:integer;
   mStr:string;
begin
   mTam:=Length(mCad);
   if mTam>=mMax then
      Result:=copy(mCad,1,mMax)
   else
      mStr:=´´;
   mCont:=0;
   mPont:=1;
   mNr:=mMax-mTam;
   while mCont<mNr do
      begin
      mPos:=pos(mStr,copy(mCad,mPont,100));
      if mPos=0 then
         begin
         mStr:=mStr+´ ´;
         mPont:=1;
         continue;
         end
      else
         begin
         mCont:=mCont+1;
         Insert(´ ´,mCad,mPos+mPont);
         mPont:=mPont+mPos+length(mStr);
         end;
   Result:=mCad;
end;



Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar