uses Richedit;
procedure HochTief(RE: TRichEdit; Offset: Integer);
var
CForm: TCharFormat;
P: Integer;
begin
zeromemory(@CForm, SizeOf(CForm));
P := Integer(@CForm);
with CForm do begin
cbSize := SizeOf(CForm);
dwMask := CFM_OFFSET;
yOffset := Offset;
end;
RE.Perform(EM_SETCHARFORMAT, SCF_SELECTION, P);
RE.SetFocus;
end;
// Beispielaufrufe:
// Hochstellung
procedure TForm1.Button2Click(Sender: TObject);
begin
HochTief(RichEdit1, 50);
end;
// Tiefstellung
procedure TForm1.Button3Click(Sender: TObject);
begin
HochTief(RichEdit1, -50);
end;
// Normal
procedure TForm1.Button4Click(Sender: TObject);
begin
HochTief(RichEdit1, 0);
end;
// Dachform
procedure TForm1.Button5Click(Sender: TObject);
var x, lg, lg2, amplitude: integer;
s, c: string;
p: pchar;
begin
Richedit1.clear;
Richedit1.Font.Name := 'Arial';
Richedit1.Font.Size := 9;
amplitude := 25;
c := #0;
s := ' Das ist ein Versuch für Hoch-Tief';
lg := length(s);
lg2 := lg div 2;
for x := 1 to lg2 do begin
p := pchar(s[x] + c);
HochTief(RichEdit1, pred(x) * amplitude);
Richedit1.perform(EM_REPLACESEL, 1, Integer(p));
end;
for x := lg2 + 1 to lg do begin
p := pchar(s[x] + c);
HochTief(RichEdit1, lg2 * amplitude * 2 - pred(x) * amplitude);
Richedit1.perform(EM_REPLACESEL, 1, Integer(p));
end;
end;