BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tab Stops in TRichEdit

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Ivan Kossey
Guest





PostPosted: Sun Oct 01, 2006 10:25 pm    Post subject: Tab Stops in TRichEdit Reply with quote



Hi All,

If the text loaded in TRichEdit contains tabulations, it shows them with
default alignment 8. How can I change tab alignment for entire text? For
example make the alignment 4 instead 8.

For example if there is at line begin one tab character, the line begins at
column 9. I want to have col.5 for one tabulation, col. 9 for two tabs, col.
13 for three tabs and so on.

Thanks and regards
Ivan
Back to top
Ivan Kossey
Guest





PostPosted: Sun Oct 01, 2006 10:36 pm    Post subject: Re: Tab Stops in TRichEdit Reply with quote



Sorry, the NG Delphi.vcl.component.using.Win32 is more suitable for this
question.

Von: "Ivan Kossey" <spamers.sollen.sterben (AT) cablenet (DOT) de>
Betreff: Tab Stops in TRichEdit
Datum: воскресенье, 1 октября 2006 г. 19:25

Hi All,

If the text loaded in TRichEdit contains tabulations, it shows them with
default alignment 8. How can I change tab alignment for entire text? For
example make the alignment 4 instead 8.

For example if there is at line begin one tab character, the line begins at
column 9. I want to have col.5 for one tabulation, col. 9 for two tabs, col.
13 for three tabs and so on.

Thanks and regards
Ivan



"Ivan Kossey" <spamers.sollen.sterben (AT) cablenet (DOT) de> schrieb im Newsbeitrag
news:451ffa0e (AT) newsgroups (DOT) borland.com...
Quote:
Hi All,

If the text loaded in TRichEdit contains tabulations, it shows them with
default alignment 8. How can I change tab alignment for entire text? For
example make the alignment 4 instead 8.

For example if there is at line begin one tab character, the line begins
at column 9. I want to have col.5 for one tabulation, col. 9 for two tabs,
col. 13 for three tabs and so on.

Thanks and regards
Ivan


Back to top
Peter Below (TeamB)
Guest





PostPosted: Mon Oct 02, 2006 11:37 pm    Post subject: Re: Tab Stops in TRichEdit Reply with quote



Ivan Kossey wrote:

Quote:
Hi All,

If the text loaded in TRichEdit contains tabulations, it shows them
with default alignment 8. How can I change tab alignment for entire
text? For example make the alignment 4 instead 8.

For example if there is at line begin one tab character, the line
begins at column 9. I want to have col.5 for one tabulation, col. 9
for two tabs, col. 13 for three tabs and so on.


The concept of a "column" only makes sense when you write text with a
fixed-spaced font, which hardly anybody does these days. You set
tabstops in a richedit control using positions measured in inches, for
example. Tabstops are a paragraph property, so you set them using the
Paragraph.Tab and .TabCount properties. If the richedit is still empty
the settings made in the Paragraph property will apply to all text
entered later. Check the online help for the TParaAttributes class.

Those properties of TRichedit.Paragraph have been a bit buggy in older
Delphi versions, and I don't know if that problem was ever fixed. And
they use units of 1/20 inch (a.k.a. points). I prefer to set tabstops
using the API:

Setting tabstops in a richedit control

{-- 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;


--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Back to top
Ivan Kossey
Guest





PostPosted: Wed Oct 04, 2006 12:57 am    Post subject: Re: Tab Stops in TRichEdit Reply with quote

Thank You, Peter!

Quote:
The concept of a "column" only makes sense when you write text with a
fixed-spaced font, which hardly anybody does these days.

I need fixed-spaced font.

Quote:
You set
tabstops in a richedit control using positions measured in inches, for
example.

I suppose if the regional setting is made for Germany the positions will be
measured in Centimeters.
Can I set tab stops in pixels?

Quote:
Tabstops are a paragraph property, so you set them using the
Paragraph.Tab and .TabCount properties. If the richedit is still empty
the settings made in the Paragraph property will apply to all text
entered later. Check the online help for the TParaAttributes class.

Those properties of TRichedit.Paragraph have been a bit buggy in older
Delphi versions, and I don't know if that problem was ever fixed. And
they use units of 1/20 inch (a.k.a. points). I prefer to set tabstops
using the API:

Setting tabstops in a richedit control

{-- 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;


--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Back to top
Peter Below (TeamB)
Guest





PostPosted: Wed Oct 04, 2006 3:02 am    Post subject: Re: Tab Stops in TRichEdit Reply with quote

Ivan Kossey wrote:

Quote:
Thank You, Peter!

The concept of a "column" only makes sense when you write text with
a fixed-spaced font, which hardly anybody does these days.

I need fixed-spaced font.

You set
tabstops in a richedit control using positions measured in inches,
for example.

I suppose if the regional setting is made for Germany the positions
will be measured in Centimeters. Can I set tab stops in pixels?

No, the richedit itself actually expects the measure in twips (1/1440
inch), and that is locale-independent. But you can convert from pixels
to inch or fractions thereof using the Screen.PixelsPerInch property.
As its name indicates it tells you how many pixels make up a logical
inch on the screen in the current video mode.



--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.