Solved

Richedit TabStops

Posted on 1998-08-05
4
2,473 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
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now