Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7952019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:44:11+00:00 2026-06-04T02:44:11+00:00

(Someone edit the title if you can understand and define my problem better.) The

  • 0

(Someone edit the title if you can understand and define my problem better.)

The problem which I am having is with style formatting of a RichEdit “reverting” back to the default “nothing” aka [] and then back to whatever I set it to, bold or italic for example.

The thing that is at fault – I assume, since I have no idea how it is breaking things – is a procedure (REMainLinesCheck) that checks for amount of lines in the RichEdit and deletes the first one until a certain point is reached (to show a maximum of 14 lines at once) like so:

while REMain.Lines.Count > 14 do
  REMain.Lines.Delete(0); 

I have 6 occurrences of the above procedure in other procedures that add lines to the RichEdit, but none of them change RichEdit.SelAttributes.Style but one, which was adding only one Bold line like so:

REMain.SelAttributes.Style := [fsBold];
REMain.Lines.Add('something');
REMainLinesCheck;

So I have removed all occurrences except that one and started poking around, it didn’t take long to see that it was working in fact fine, regular and bold lines where being added normally and excess lines where being deleted – no problems. But as soon as I reintroduced REMainLinesCheck procedure into another procedure (for clarity purposes, lets call it Proc3Lines, because that’s what it does: adds 3 lines and then calls the check for excess lines), every line that follows this Proc3Lines that should be Bold is not… From what I have experienced here it seems that REMainLinesCheck does something in Proc3Lines, since without it everything is fine.

Obviously it’s not a circle of procedures that call each other, but the other parts of the code have nothing to do with this RichEdit, not to mention that I don’t change RichEdit.SelAttributes.Style anywhere for REMain except that one place that I have shown, there is another RichEdit in the same unit that I do change its line’s style like that, but that cannot possibly be related in any way… could it? (No it does not, I just checked.)

Basically: what the hell Delphi? It cannot get any simpler than this and I am still managing to fail, can someone explain and/or fix this? Ask questions, I’ll elaborate as much as I can if something is not clear.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:44:12+00:00Added an answer on June 4, 2026 at 2:44 am

    To apply a format to a new added line, use the following:

    procedure TForm1.Button1Click(Sender: TObject);
    var
      LineIndex: Integer;
    begin
      LineIndex := RichEdit1.Lines.Add('Something');
      RichEdit1.SelStart := RichEdit1.Perform(EM_LINEINDEX, LineIndex, 0);
      RichEdit1.SelLength := RichEdit1.Perform(EM_LINELENGTH, RichEdit1.SelStart, 0);
      RichEdit1.SelAttributes.Style := [fsBold];
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What a crappy title. Maybe someone can edit it for me. Here's the scoop:
Can someone offer some insight on why the code doesnt work? [edit: fixed code
Can someone help me out on this. I have a problem with the return
Note: The title of this was changed to better reflect the actual problem. I've
I understand the title may be a little vague, but, hopefully, I can explain
I'm not sure what this practice is actually called, so perhaps someone can edit
Was'nt sure of the title, but I have this task which I am having
Edit: I have added an answer on how to fix this in case someone
EDIT: This code now works correctly, I only left it in case someone finds
Someone can tell me what API's to use to gather outlook contacts list ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.