Justificar Memo ou RichEdit
oi galera,
alguem poderia me dar uma ´luz´ sobre como fazer com q um memo ou um richedit justifique o texto?
eu fiz uma função que justifica uma linha, mas faz 3 dias q eu estou tentando adapta-la ao Memo/Rich e não consegui nenhum progresso, isso porque ao justificar um Documento, ao inves de uma linha, nem todas as linhas serão justificadas, por exemplo, algumas podem ser centralizadas, outras serem finais de paragrafo etc..
Qualquer dica é bem vinda (claro =P), mesmo que seja muito tecnica, não estou sabendo aonde mecher no componente para que ele faça isso, será que alguem sabe algo?
obrigado, fabio nascimento.
alguem poderia me dar uma ´luz´ sobre como fazer com q um memo ou um richedit justifique o texto?
eu fiz uma função que justifica uma linha, mas faz 3 dias q eu estou tentando adapta-la ao Memo/Rich e não consegui nenhum progresso, isso porque ao justificar um Documento, ao inves de uma linha, nem todas as linhas serão justificadas, por exemplo, algumas podem ser centralizadas, outras serem finais de paragrafo etc..
Qualquer dica é bem vinda (claro =P), mesmo que seja muito tecnica, não estou sabendo aonde mecher no componente para que ele faça isso, será que alguem sabe algo?
obrigado, fabio nascimento.
Lord_angel
Curtidas 0
Respostas
Marcelino Lavor
25/04/2003
ME DÁ TEU E-MAIL QUE TE ENVIO UM PROGRAMA QUE EU DESENVOLVIR JÁ PRONTO.
GOSTEI 0
Lord_angel
25/04/2003
fhpnascimento@bol.com.br
vlw!
vlw!
GOSTEI 0
(conta Desativada)
25/04/2003
No richedit, use
[size=18:7bff8a0694]Ok ?[/size:7bff8a0694]
Richedit1.alignment:=taleftjustify; //Para justificar à esquerda Richedit1.alignment:=tacenter; //Para justificar no centro Richedit1.alignment:=tarightjustify; //Para justificar à direita
[size=18:7bff8a0694]Ok ?[/size:7bff8a0694]
GOSTEI 0
Lord_angel
25/04/2003
eu preciso alinhamento justificado manow, mas vlw por tentar ajudar =P
GOSTEI 0
Famsouza
25/04/2003
Se possivel mande o programa richedit com o texto justificado(com o codigo fonte)
famsouza@pop.com.br
Desde ja agradeço, Felipe Augusto
famsouza@pop.com.br
Desde ja agradeço, Felipe Augusto
GOSTEI 0
Lulinha
25/04/2003
Caso alguém tenha a solução pra mim favor mandar um e-mail para mim!
Obrigado!
Luís Ledebour
Obrigado!
Luís Ledebour
GOSTEI 0
Rakov
25/04/2003
pra mim tambem
GOSTEI 0
Leoback
25/04/2003
Senhores,
Infelizmente não disponho desse código que vocês precisam. Mas lembro-me muito bem que Bruno Sonino, em seu livro 365 dicas... descreve uma função interessante (e grande) sobre justificação (alinhamento à esquerda e direita ao mesmo tempo) de texto em um memo.
Desculpem-me por não ter o código... mas vale a pena procurar o livro.
Um abraço
Leo
Infelizmente não disponho desse código que vocês precisam. Mas lembro-me muito bem que Bruno Sonino, em seu livro 365 dicas... descreve uma função interessante (e grande) sobre justificação (alinhamento à esquerda e direita ao mesmo tempo) de texto em um memo.
Desculpem-me por não ter o código... mas vale a pena procurar o livro.
Um abraço
Leo
GOSTEI 0
Info.wtomfs
25/04/2003
Tentem isso
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function SubstituiCaractere (vString, vStr1, vStr2 : string) : string;
begin
while Pos(vStr1, vString) <> 0 do
vString := Copy(vString, 1, Pos(vStr1, vString)-1)+vStr2+
Copy(vString, Pos(vStr1, vString)+Length(vStr1), Length(vString)-(Pos(vStr1, vString)+Length(vStr1)-1));
Result := vString
end; { SubstituiCaractere }
//
function PadR (Cadeia : string; Tamanho : integer; Caractere : string) : string;
begin
while Length(Cadeia) < Tamanho do
Cadeia := Cadeia + Caractere;
Result := Copy(Cadeia, 1, Tamanho)
end; { PadR }
//
function Alltrim (Cadeia : string) : string;
var Inicio, Fim : integer;
begin
Inicio := 1;
while (Copy(Cadeia, Inicio, 1) = ´ ´) and (Inicio < Length(Cadeia)) do
Inc(Inicio);
Fim := Length(Cadeia);
while (Copy(Cadeia, Fim, 1) = ´ ´) and (Fim > Inicio) do
Dec(Fim);
Result := Copy(Cadeia, Inicio, Fim-Inicio+1)
end; { Alltrim }
function JstString (StringInicial : string; TamanhoFinal : byte) : string;
var
AUXString : string;
TamanhoAUXString ,
i : byte;
begin
AUXString := Alltrim(StringInicial);
AUXString := SubstituiCaractere(AUXString, ´ ´, ´ ´);
TamanhoAUXString := Length(AUXString);
i := TamanhoAUXString;
while (TamanhoAUXString < TamanhoFinal) and (Pos(´ ´, AUXString)<>0) do
begin
while (Copy(AUXString, i, 1) <> ´ ´) and (i > 0) do
Dec(i);
if i > 0 then
begin
AUXString := Copy(AUXString, 1, i-1)+´ ´+Copy(AUXString, i, TamanhoAUXString+1);
Inc(TamanhoAUXString)
end; { if }
while (Copy(AUXString, i, 1) = ´ ´) and (i > 0) do
Dec(i);
if i = 0 then
i := TamanhoAUXString
end; { while }
Result := AUXString
end; { JstString }
//
function JstParagrafo (Paragrafo : string; Largura : word) : string;
var Inicio, Fim : word;
begin
if Largura = 0 then
Largura := 1;
Paragrafo := Alltrim(Paragrafo);
Paragrafo := SubstituiCaractere(Paragrafo, #10, ´´);
Paragrafo := SubstituiCaractere(Paragrafo, 13, ´´);
Paragrafo := SubstituiCaractere(Paragrafo, ´ ´, ´ ´);
Inicio := 1;
Result := ´´;
while Inicio <= Length(Paragrafo) do begin
while (Inicio <= Length(Paragrafo)) and (Copy(Paragrafo, Inicio, 1) = ´ ´) do
Inc(Inicio);
Fim := Inicio + Largura; // -1;
if Fim <= Length(Paragrafo) then
begin
while (Fim > Inicio) and (Copy(Paragrafo, Fim, 1) <> ´ ´) do
Dec(Fim);
while (Fim > Inicio) and (Copy(Paragrafo, Fim, 1) = ´ ´) do
Dec(Fim);
if Fim = Inicio then
Fim := Inicio + Largura-1
end; { if }
if Fim >= Length(Paragrafo) then
Result := Result + PadR(Alltrim(Copy(Paragrafo, Inicio, Fim-Inicio+1)), Largura, ´ ´)
else
Result := Result + Alltrim(JstString(Copy(Paragrafo, Inicio, Fim-Inicio+1), Largura)) + #13+10;
Inicio := Fim+1
end { while }
end; { JstParagrafo }
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo2.Text := JstParagrafo(Memo1.Text, StrToInt(Edit1.Text))
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
end;
end.
Espero ter ajudado!!!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function SubstituiCaractere (vString, vStr1, vStr2 : string) : string;
begin
while Pos(vStr1, vString) <> 0 do
vString := Copy(vString, 1, Pos(vStr1, vString)-1)+vStr2+
Copy(vString, Pos(vStr1, vString)+Length(vStr1), Length(vString)-(Pos(vStr1, vString)+Length(vStr1)-1));
Result := vString
end; { SubstituiCaractere }
//
function PadR (Cadeia : string; Tamanho : integer; Caractere : string) : string;
begin
while Length(Cadeia) < Tamanho do
Cadeia := Cadeia + Caractere;
Result := Copy(Cadeia, 1, Tamanho)
end; { PadR }
//
function Alltrim (Cadeia : string) : string;
var Inicio, Fim : integer;
begin
Inicio := 1;
while (Copy(Cadeia, Inicio, 1) = ´ ´) and (Inicio < Length(Cadeia)) do
Inc(Inicio);
Fim := Length(Cadeia);
while (Copy(Cadeia, Fim, 1) = ´ ´) and (Fim > Inicio) do
Dec(Fim);
Result := Copy(Cadeia, Inicio, Fim-Inicio+1)
end; { Alltrim }
function JstString (StringInicial : string; TamanhoFinal : byte) : string;
var
AUXString : string;
TamanhoAUXString ,
i : byte;
begin
AUXString := Alltrim(StringInicial);
AUXString := SubstituiCaractere(AUXString, ´ ´, ´ ´);
TamanhoAUXString := Length(AUXString);
i := TamanhoAUXString;
while (TamanhoAUXString < TamanhoFinal) and (Pos(´ ´, AUXString)<>0) do
begin
while (Copy(AUXString, i, 1) <> ´ ´) and (i > 0) do
Dec(i);
if i > 0 then
begin
AUXString := Copy(AUXString, 1, i-1)+´ ´+Copy(AUXString, i, TamanhoAUXString+1);
Inc(TamanhoAUXString)
end; { if }
while (Copy(AUXString, i, 1) = ´ ´) and (i > 0) do
Dec(i);
if i = 0 then
i := TamanhoAUXString
end; { while }
Result := AUXString
end; { JstString }
//
function JstParagrafo (Paragrafo : string; Largura : word) : string;
var Inicio, Fim : word;
begin
if Largura = 0 then
Largura := 1;
Paragrafo := Alltrim(Paragrafo);
Paragrafo := SubstituiCaractere(Paragrafo, #10, ´´);
Paragrafo := SubstituiCaractere(Paragrafo, 13, ´´);
Paragrafo := SubstituiCaractere(Paragrafo, ´ ´, ´ ´);
Inicio := 1;
Result := ´´;
while Inicio <= Length(Paragrafo) do begin
while (Inicio <= Length(Paragrafo)) and (Copy(Paragrafo, Inicio, 1) = ´ ´) do
Inc(Inicio);
Fim := Inicio + Largura; // -1;
if Fim <= Length(Paragrafo) then
begin
while (Fim > Inicio) and (Copy(Paragrafo, Fim, 1) <> ´ ´) do
Dec(Fim);
while (Fim > Inicio) and (Copy(Paragrafo, Fim, 1) = ´ ´) do
Dec(Fim);
if Fim = Inicio then
Fim := Inicio + Largura-1
end; { if }
if Fim >= Length(Paragrafo) then
Result := Result + PadR(Alltrim(Copy(Paragrafo, Inicio, Fim-Inicio+1)), Largura, ´ ´)
else
Result := Result + Alltrim(JstString(Copy(Paragrafo, Inicio, Fim-Inicio+1), Largura)) + #13+10;
Inicio := Fim+1
end { while }
end; { JstParagrafo }
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo2.Text := JstParagrafo(Memo1.Text, StrToInt(Edit1.Text))
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
end;
end.
Espero ter ajudado!!!
GOSTEI 0
Fabio Medeiros
25/04/2003
ME DÁ TEU E-MAIL QUE TE ENVIO UM PROGRAMA QUE EU DESENVOLVIR JÁ PRONTO.
me manda o programa tambem (se possivel com o codigo fonte).
fabiotoledo144@gmail.com
pois estou precisando montar um contrato de prestação de seviços de várias páginas mas encontrei esse problema de nao justificar os textos.
Desde já obrigado.
GOSTEI 0
Edmilson Malaquia
25/04/2003
Boa tarde
Gostaria do fontes se possível.
jrmalaquias@gmail.com
Gostaria do fontes se possível.
jrmalaquias@gmail.com
GOSTEI 0