Solved

Richedit TabStops

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 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