Solved

Richedit TabStops

Posted on 1998-08-05
4
2,554 Views
Last Modified: 2013-11-22
I am having a problem with setting tabstops in Richedit.
The code is:::

procedure TForm1.SetTabs(Sender: TObject);
begin
     with Richedit1.Paragraph do
          begin
               Tab[0] := 100;
               Tab[1] := 200;
               Tab[2] := 300;
          end;
end;

No matter how many tabs I set, it always leaves off the last one.
This code produces 2 tabstops. After that, they are all default
positions.
If I set 5 tabstops, there are only 4 in the Richedit.
And yes, If I set one, none show up.
They are in the right place just missing one.
The window is created and visible when this code is performed.
Thanks for the help,, Jim
0
Comment
Question by:JStan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Expert Comment

by:Jacco
ID: 1359921
This I didn't know.

I did know that TabAlignments and TabKinds are not supported by the RichEd20.DLL to be displayed. (They are loaded and saved though)
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1359922
Sure it has...after each setting of the tab it returns the last one unless you specify which one to be executed, and when to be executed..

//Vik
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 100 total points
ID: 1359923
Jstan

Here is a complex but valuble code snippet I received from Russell L. Smith (Thanx russell) some time ago...It shows how set the tabs in a rich edit etc depending on font and pixels etc...

first add this to your private section

procedure SetTabSize(RichEdit: TRichEdit; TabSize: Integer);

then here is the snippet

procedure TForm1.SetTabSize(RichEdit: TRichEdit; TabSize: Integer);
                            var
                              nSelStart: Integer;
                              tmFont: TTextMetric;
                              nTextFontWidth: Integer;
                              nxLogPixels: Integer;
                              nTabStop: Integer;
                            begin
                              // select the entire memo
                              nSelStart := RichEdit.SelStart;
                              RichEdit.SelectAll;

                              // get the avg pixel width of the rich edit's font
                              with TGraphicControl.Create(Self) do
                              begin
                                Canvas.Font := RichEdit.Font;
                                GetTextMetrics(Canvas.Handle, tmFont);
                                nTextFontWidth := tmFont.tmAveCharWidth;
                                nxLogPixels := GetDeviceCaps(Canvas.Handle, LOGPIXELSX);
                                Free;
                              end;

                              // set ten tab stops
                              RichEdit.Paragraph.Tab[0] := (TabSize - 1) * nTextFontWidth * 72 div
                            nxLogPixels;
                              for nTabStop := 1 to 9 do
                                RichEdit.Paragraph.Tab[nTabStop] := (nTabStop + 1) * TabSize *
                            nTextFontWidth * 72 div nxLogPixels;

                              // deselect
                              RichEdit.SelStart := nSelStart;
                            end;

Hope this helps

Later
BoRiS

0
 

Author Comment

by:JStan
ID: 1359924
That'll do it.
Thanks a lot

Jim
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to send memory stream from ics Client To ics server ? 11 180
Base1 Encode/Decode 3 90
How to build JSON File in Delphi 6 3 71
Get weeknumber and year from date 4 31
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question