In a rich edit or memo component, text can be left- or right-aligned or centered. To change text alignment, set the edit component's Alignment property. Alignment takes effect only if the WordWrap property is True; if word wrapping is turned off, there is no margin to align to.
For example, the following code attaches an OnClick event handler to a CharacterLeft menu item, then attaches the same event handler to both a CharacterRight and CharacterCenter menu item.
procedure TForm.AlignClick(Sender: TObject); begin Left1.Checked := False; { clear all three checks } Right1.Checked := False; Center1.Checked := False; with Sender as TMenuItem do Checked := True; { check the item clicked } with Editor do { then set Alignment to match } if Left1.Checked then Alignment := taLeftJustify else if Right1.Checked then Alignment := taRightJustify else if Center1.Checked then Alignment := taCenter; end;
switch(reinterpret_cast<int>(RichEdit1->Paragraph->Alignment)) { case 0: LeftAlign->Down = true; break; case 1: RightAlign->Down = true; break; case 2: CenterAlign->Down = true; break; }
You can also use the HMargin property to adjust the left and right margins in a memo control.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|