Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Layout columns in RichEdit

522 views
Skip to first unread message

Stuart Macaulay

unread,
Oct 12, 2001, 1:22:05 AM10/12/01
to
Hi,

I was wondering if someone has any ideas on creating a table / columns with
the RichEdit componet e.g.

Server Name OS HDD Space
Moose Win NT 4.0gb

Basically I'm having trouble lining up the detail with the column heading.
Any help would be appreciated.

Cheers
Stuart


Peter Below (TeamB)

unread,
Oct 12, 2001, 2:53:38 PM10/12/01
to
In article <3bc67e5a_1@dnews>, Stuart Macaulay wrote:
> I was wondering if someone has any ideas on creating a table / columns with
> the RichEdit componet e.g.
>
> Server Name OS HDD Space
> Moose Win NT 4.0gb
>
> Basically I'm having trouble lining up the detail with the column heading.

Set tabstops and separate the items with tabs (#9 character) to align them to
the tabstops. The Paragraph.Tab property is somewhat broken, so better use
the API directly to set the tabstops.

The following method sets tabstops every 5 average character positions, based
on the current paragraphs font.

Uses richedit;

procedure TForm1.Button2Click(Sender: TObject);
Const
tabs : Array [0..5] of Integer = (5,10,15,20,25,30);
teststring = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
Var
pf: TParaFormat;
i : Integer;
charwidth : Integer;
begin
FillChar( pf, sizeof(pf), 0);
pf.cbSize := Sizeof( pf );
pf.dwmask := PFM_TABSTOPS;
pf.cTabCount := 6;
Canvas.Font.Assign( richedit1.SelAttributes );
charwidth := (Canvas.TextWidth( teststring ) * 1440)
div
(Screen.PixelsPerInch * Length(teststring));
// average charwidth in twips
For i:= 0 To High( tabs ) Do
pf.rgxTabs[i] := tabs[i] * charwidth;

If richedit1.perform( EM_SETPARAFORMAT, 0, Integer( @pf )) = 0
Then ShowMessage('Failed');
end;

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Stuart Macaulay

unread,
Oct 14, 2001, 4:38:53 AM10/14/01
to
Thanks for your help.

Cheers
Stuart


"Peter Below (TeamB)" <10011...@compuXXserve.com> wrote in message
news:VA.00007b0...@antispam.compuserve.com...

0 new messages