Board index » delphi » Tabstopps with Fixed-Width Font in Rich Edit

Tabstopps with Fixed-Width Font in Rich Edit

Hello together

I'm working with a TRichEdit Component and am trying to calculate the
tab-positions (all x characters) for fixed-width fonts. As TRichEdit
doesn't have a Canvas property I can't call the function
canvas.textwidth.

Does someone has an good idea who to get to the correct information.

Thanks in advance

Sent via Deja.com
http://www.deja.com/

 

Re:Tabstopps with Fixed-Width Font in Rich Edit


Hello,
Quote
> I'm working with a TRichEdit Component and am trying to calculate the
> tab-positions (all x characters) for fixed-width fonts. As TRichEdit
> doesn't have a Canvas property I can't call the function
> canvas.textwidth.

my experience with Tab-Stops are:
The TRichEdit set Tab in 1/72 Inches, this will be converted during
saving to a file or Printing to 1/1440 Inches.
Creating RTF Files with Wordpad save Tabs in 1/1440 Inches so there is a
loss of Information during transfer.

I have found that if I set the Tab Property to a Value of
TabSize * 72 (Where Tabsize is in Inch) (TabSize * 28,346 for cm)
the Tab Position ist correct on the Screen and during Printing .
Hope thats help a bit!
Best regards
Ekkehard
The Helpfile says "Tab specifies the position, in pixels, of a
particular tab stop." this is not correct!

Quote
rhe...@bigfoot.com wrote:

> Hello together

> I'm working with a TRichEdit Component and am trying to calculate the
> tab-positions (all x characters) for fixed-width fonts. As TRichEdit
> doesn't have a Canvas property I can't call the function
> canvas.textwidth.

> Does someone has an good idea who to get to the correct information.

> Thanks in advance

> Sent via Deja.com
> http://www.deja.com/

--
DomIS Internet Solution - Ekkehard Domning
Spahner Str. 11 - D-49751 S?gel
Mail: e...@domis.de Internet: http://www.domis.de

Re:Tabstopps with Fixed-Width Font in Rich Edit


In article <3A681B3C.C3A05...@192.168.0.5>, "Ekkehard Domning"

Quote
<domn...@t-online.de> writes:
>I have found that if I set the Tab Property to a Value of =

>TabSize * 72 (Where Tabsize is in Inch) (TabSize * 28,346 for cm)
>the Tab Position ist correct on the Screen and during Printing .
>Hope thats help a bit!
>Best regards
>Ekkehard
>The Helpfile says "Tab specifies the position, in pixels, of a
>particular tab stop." this is not correct!

Yes you're correct. MS paragraph units are in twips (1440/inch) and
ComCtrls.pas has . . .

procedure TParaAttributes.SetTab(Index: Byte; Value: Longint);
var
  Paragraph: TParaFormat;
begin
  GetAttributes(Paragraph);
  with Paragraph do
  begin
    rgxTabs[Index] := Value * 20;
    dwMask := PFM_TABSTOPS;
    if cTabCount < Index then cTabCount := Index;
    SetAttributes(Paragraph);
  end;
end;

A point is 1/72 inch, so Delphi tab values are in points, and at 96 pixels/inch
a point is 4/3 pxl, or 1 pixel = 3/4 point.

Alan Lloyd
alangll...@aol.com

Re:Tabstopps with Fixed-Width Font in Rich Edit


I think my question was not very well... I want to set tabstopps as in
a programming editor. It means I've a fixed-type font and want to set
the tabstop after 2, 3, 5, ... characters. How can I calculate the
correct positions for that?

Thanks

Roland

In article <20010119131546.01651.00000...@nso-fp.aol.com>,
  alangll...@aol.com (AlanGLLoyd) wrote:

Quote
> In article <3A681B3C.C3A05...@192.168.0.5>, "Ekkehard Domning"
> <domn...@t-online.de> writes:

> >I have found that if I set the Tab Property to a Value of =

> >TabSize * 72 (Where Tabsize is in Inch) (TabSize * 28,346 for cm)
> >the Tab Position ist correct on the Screen and during Printing .
> >Hope thats help a bit!
> >Best regards
> >Ekkehard
> >The Helpfile says "Tab specifies the position, in pixels, of a
> >particular tab stop." this is not correct!

> Yes you're correct. MS paragraph units are in twips (1440/inch) and
> ComCtrls.pas has . . .

> procedure TParaAttributes.SetTab(Index: Byte; Value: Longint);
> var
>   Paragraph: TParaFormat;
> begin
>   GetAttributes(Paragraph);
>   with Paragraph do
>   begin
>     rgxTabs[Index] := Value * 20;
>     dwMask := PFM_TABSTOPS;
>     if cTabCount < Index then cTabCount := Index;
>     SetAttributes(Paragraph);
>   end;
> end;

> A point is 1/72 inch, so Delphi tab values are in points, and at 96
pixels/inch
> a point is 4/3 pxl, or 1 pixel = 3/4 point.

> Alan Lloyd
> alangll...@aol.com

Sent via Deja.com
http://www.deja.com/

Re:Tabstopps with Fixed-Width Font in Rich Edit


Quote
<rhe...@bigfoot.com> wrote in message news:94gocp$vat$1@nnrp1.deja.com...
> I think my question was not very well... I want to set tabstopps as in
> a programming editor. It means I've a fixed-type font and want to set
> the tabstop after 2, 3, 5, ... characters. How can I calculate the
> correct positions for that?

Trunc (CharPosition * (72.0 / CharactersPerInch))

Other Threads