[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Richedit TabStops

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month18 days, 22 hours left to enroll

834 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