Recent

Author Topic: Changing the color of a line  (Read 1394 times)

Barry55

  • New Member
  • *
  • Posts: 20
Changing the color of a line
« on: January 02, 2021, 06:33:20 pm »
I am sure I am doing something really stupid, but I can't seem to change to color of a line. I have attached a small example, to show what I mean. I am displaying the amount of free space for the various drives in the system (Windows) and if there is less than say 10% free change the line of the relevant disk to red.

In this example I would expect line 3 to display in red

Also I was using TMemo before (I changed as Tmemo can't color individual lines) and was using Trimright to supress the blank line at the end, this does not seem to work in richmemo as I get 2 blank lines?

please can you help
Many thanks
Barry

gsa

  • New member
  • *
  • Posts: 9
Re: Changing the color of a line
« Reply #1 on: January 03, 2021, 01:23:57 pm »
Your main problem is the line:

Code: Pascal  [Select][+][-]
  1. RDiskMemo.Text := Trimright (RDiskMemo.text);

This erases the formatting.

Commenting this line will show red characters, but with false offsets. StartPos should be 0.

Gerd

Barry55

  • New Member
  • *
  • Posts: 20
Re: Changing the color of a line
« Reply #2 on: January 03, 2021, 02:48:03 pm »
Thank you removing this line did indeed allow me to correctly color the lines. I had to add an additional character to NewCount to cope with the CR.

However this then leaves me with the issue of 2 blank lines at the end of the Richmemo, if I can't use trimright do you have any suggestions on how I remove them ?

Many thanks again for your help
regards
Barry

gsa

  • New member
  • *
  • Posts: 9
Re: Changing the color of a line
« Reply #3 on: January 03, 2021, 06:39:08 pm »

However this then leaves me with the issue of 2 blank lines at the end of the Richmemo, if I can't use trimright do you have any suggestions on how I remove them ?


Sorry but i don't have a solution for your problem.

I get four lines and the carret is set to the beginning of the fifth line. To me this seems expected behavior.

Gerd

Barry55

  • New Member
  • *
  • Posts: 20
Re: Changing the color of a line
« Reply #4 on: January 03, 2021, 07:05:54 pm »
Thank you. I agree in the sample code I uploaded I get four lines and the carret is set to the beginning of the fifth line. I also agree that without the Trimright statement this is the expected behaviour.

What I want is the carret to be at the end of the 4th line and with a normal memo I was using Trimright to achieve this. Since I cannot use Trimright in Richmemo I was hoping there was another solution.

Thanks again

Barry

 

TinyPortal © 2005-2018