Tem como Justificar Um Memo?

Delphi

30/08/2005

Oi, Preciso Justificar as Linhas de Um Memo, mesmo que ele fique alinhado a esquer, centro e direita ele tem q ficar justificado..
tem como??
Obrigado


Daniel Martins

Daniel Martins

Curtidas 0

Respostas

Adriano Santos

Adriano Santos

30/08/2005

[color=red:0efd86f594][b:0efd86f594]Não testei cara, peguei essa dica aqui nos meus arquivos e nem sei se funciona[/b:0efd86f594][/color:0efd86f594]

Question:

 How can I create a single line edit control that is right or centered justified?

 Answer:

 You can use a TMemo component, since the TEdit component  does not directly support center and right justification. 
 In addition, you will need to prevent the user from pressing  the Enter, Ctrl-Enter, and a variety of arrow key combinations  to prevent more than one line to be added to the memo. This  can be accomplished by scanning the TMemo´s text string for  carriage return and line feed characters and deleting them  during the TMemo´s Change and KeyPress events. Optionally, you could replace any carriage returns with spaces to accommodate  a multi-line paste operation.

 Example:

 procedure TForm1.FormCreate(Sender: TObject);
 begin
   Memo1.Alignment := taRightJustify;
   Memo1.MaxLength := 24;
   Memo1.WantReturns := false;
   Memo1.WordWrap := false;
 end;

 procedure MultiLineMemoToSingleLine(Memo : TMemo);
 var
   t : string;
 begin
   t := Memo.Text;
   if Pos(#13, t) > 0  then begin
     while Pos(13, t) > 0 do
       delete(t, Pos(13, t), 1);
     while Pos(10, t) > 0 do
       delete(t, Pos(10, t), 1);
     Memo.Text := t;
   end;
 end;

 procedure TForm1.Memo1Change(Sender: TObject);
 begin
   MultiLineMemoToSingleLine(Memo1);
 end;

 procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
 begin
   MultiLineMemoToSingleLine(Memo1);
 end;




GOSTEI 0
POSTAR