?
Solved

Richedit TabStops

Posted on 1998-08-05
4
Medium Priority
?
2,633 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 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

765 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