AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Tabulatorpositionen im RichEdit

Ein Thema von taaktaak · begonnen am 29. Apr 2008 · letzter Beitrag vom 5. Mai 2009
 
Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#3

Re: Tabulatorpositionen im RichEdit

  Alt 29. Apr 2008, 18:59
Hallo,

Vielleicht macht der Code von den Newsgroups das was du möchtest.

Zitat von P. Below:
Tab positions are a paragraph property in this control, so you use the Paragraph.Tab property to set tabstop positions. At least that is the theory.
Unfortunately the Tab property has been plagued by a longstanding bug, so you are better off setting tabstops by using the EM_SETPARAFORMAT message. Here is an example, add the
Richedit unit to your uses clause for the message and TParaformat type.


Delphi-Quellcode:
{-- SetTabstops -------------------------------------------------------} 
{: Set tabstops at the indicated positions in the current paragraph
@Param re is the richedit control to modify
@Param TabPositions is an array of positions to set. The unit used
  are inches and the array needs to be sorted.
@Precondition  re <> nil
@Desc Note: if the TabPositions array contains more than MAX_TAB_STOPS
  entries the extras will not be used.


}
{ Created 2004-04-15 by P. Below


-----------------------------------------------------------------------}
 
procedure SetTabstops( re: TRichedit; TabPositions: array of single );
Var
  pf: TParaFormat;
  i : Integer;
  charwidth : Integer;
begin
  Assert( Assigned( re ), 'SetTabstops: re cannot be nil' );
  FillChar( pf, sizeof(pf), 0);
  pf.cbSize := Sizeof( pf );
  pf.dwmask := PFM_TABSTOPS;
  if High(TabPositions) >= MAX_TAB_STOPS then
    pf.cTabCount := MAX_TAB_STOPS
  else
    pf.cTabCount := High(TabPositions)+1;
  For i:= 0 To pf.cTabCount-1 Do
    pf.rgxTabs[i] := Trunc(TabPositions[i] * 1440);

  re.perform( EM_SETPARAFORMAT, 0, Integer( @pf ));
end; { SetTabstops } 


procedure TForm1.Button1Click(Sender: TObject);
begin
  with RichEdit1 do
  begin
    Clear;
    SelStart := GetTextLen; // position caret at end
    SelAttributes.Style := [];
    SelAttributes.Color := clBlack;
    SetTabstops( richedit1, [0.5, 1.0, 1.5, 2.5] );
    SelText := 'STRING1'+#9+'STRING2'+#9+'STRING3'+#13#10+
      'A'#9'B'#9'C'#9'D'#9'E';
  end;
end;
Thomas
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:03 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz