We help IT Professionals succeed at work.

RichEdit And Plain Text Question.

hyperion66 asked
Medium Priority
Last Modified: 2013-11-22
Hello, I would like to see how i could use richedit in plain text mode without having richedit displaying colors
Everytime i paste text from the web into richedit when richedit is in plain text mode. What i would like to do is make richedit act like TMemo but with Richedit's Memory Compacity!, To overcome the 64k Limit.
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)

Hi viktor,

 setting plaintext to true gives plaintext but also displays the format commands...
 I think we need to wright here a DefaultConverter. A descendant of TConversion which will convert the richedit text (which is stripping of all the rich format commands from the plain text)

Regards, ZiF.
Hello Zif. Nice to hear you are staying. I just came from school and immediately heard the news. I'm happy you;ll be back in a while.... About the Plain text I think that's a really good idea ;)

Viktor Ivanov


Yes I know how to turn Richedit into plain text mode by switching it to true, but thats not my problem, my problem is when Richedit is switched to plain text mode and goto paste any kind of colored text from webpages etc. I can see the colors even when richedit is in plain text mode how can I change richedit from displaying colors when richedit is in plain text mode. to see what i mean just create a new form with richedit and copy any colored text from this web page and you will see what i mean.  
I tried it and I have no problem with the Color. It displays it in black color. What version of Delphi are you using. I use Delphi 3.



I'm Useing Delphi Professional 3.0, Did you copy Red or blue text from a webpage and paste it in richedit? Because when i paste any color from the web like " Red " i see red in richedit when i paste.
Yes, I did that, but the color stays black.........I'm using Delphi3 Client/Server
Here is something you might try though =)

procedure TForm1.Button1Click(Sender: TObject);
     SendMessage(RichEdit1.Handle, WM_PASTE, 0,0);
     RichEdit1.SelAttributes.Color := clRed;

I've used a button to paste the text, but if you are not using button for that just create a procedure that will get the WM_PASTE message and if  it returns true just excute the code above

Viktor Ivanov
Instead clRed use clBlack or whatever color you want the text to be =)



Ok I'll try once more to explain what i ean sorry if i have not explained this good enough. viktornet see comments in the headings on this page there blue and italic. Select it and copy it. now paste it into richedit when its in text mode by pressing CTRL + V and tell me if it is Blue and italic in richedit.

That's what I did, and the color and font everything is same as usual. Nothing changes... Let me try it again so we can be sure... Hey, I just tried it and the color is blac, and the font isn;t italic....Are you sure the font of the form and/or panel that the richedit lays on isn't changed, because if you change the form's font the rich edit's font changes too...Why don't you send me a sample app to try it on my computer...I use Win95

Viktro Ivanov


ok i will compile and copy of richedit text example, i don't know why mine is doing it. what is your email so i can send a compiled copy along with the source.
My e-mail is viktor@megsinet.net, and I also have it in my profile...

Viktor Ivanov
What happened, why do you accept my answer?


Because there's no point in keeping this topic up when I cannot seem to get richedit to display only plaintext, i'll email you a copy of source and a note on what is happening.
Ok, send it to me so I can see what's going on. o O

BTW, Why don;t you use my method to convert the text to black when it has been pasted into the richedit.....???

Rich.SelAttributes.Color := clBlack;

This will select everything in the richedit, change the color to black and then deselect it...
PS. I want to take a look at a sample so I can see what's the difference and if it can be fixed

Viktor Ivanov


I would but i don't like the way it repaints.
Ok, here something I found on the net today.....take a look at it and see if it helps a little,,,,,
    Q: Can a Borland Pascal program use static variables > with
    more than 64 kilobytes?
    A: No!
    Q: I said *static* variables. Are there other and does it
    work with them?
    A: Yes, see "Is there a Solution" below, but first read the rest
    here to avoid wasting time trying other alternatives, because
    they all do not work.
    Q: Does it help to split a large array in several small arrays
    (all parts smaller than 64k, but in total larger than 64k) ?
    A: No!
    Q: Does it help to declare some of the variables in a Unit?
    A: No!
    Q: Does it help to declare some in the Implementation Part of
    a unit?
    A: No!
    Q: Does it help to use the protected mode of Borland Pascal
    7 ?
    A: No!
    Q: Are you sure ??
    A: Yes !!
    Q: Why ??
    A: All programs written in Borland Pascal use only one
    segment for all variables and the Intel 80xxx processors are
    limited to 64k per segment.
    Q: That's silly!!
    A: Tell Borland!! (Or Intel or both).
    Q: Is there a Solution ?
    A: Yes! There are two solutions:

    1) don't use *STATIC* variables for storing huge amounts of
    data. This will allow to store more than 64k in total, but
    never more than 64k in *one* array, so yes you must split
    them but that alone doesn't help. You must also make them

    2) use another Compiler: there are a few Pascal compilers
    available that are more or less Borland compatible and that
    don't have these limitations (they are 32-bit Compilers).

    Q: Why is Borland Pascal not a 32-bit Compiler?
    A: It's too old. Tell Borland you want a new version.
    Q: What is non-static memory?
    A: For example Heap, XMS, EMS, ... Heap is directly
    accessible, XMS needs a driver (himem.sys), EMS too
    (HIMEM.SYS + EMM386.EXE) and is not commonly
    available on all computers, so better use XMS instead of
    Q: What is the Heap ?
    A: Heap is in real mode all free memory below the 640
    kilobyte limit, in protected mode (available in Borland
    Pascal 7 only) all free memory below the 16 Megabyte limit
    (and usually *ALL* free memory but we're only talking about
    Borland Pascal here).
    Q: How can I use the heap?
    A: Memory on the heap can only be accessed with pointers.
    Try this example, then adapt the principle to your programs:

          arr    = array [1..30000] of longint; { this is your data }
          arrptr = ^arr;                        { that's a pointer to the data }
          data : arrptr;       { this is such a pointer variable }
          if memavail < sizeof(arr) then halt; { check if enough memory available}
          new (data);                          { allocate the memory }
          for i := 1 to 30000 do data^[i]:=0;  { use it, note the ^ sign here !! }
          dispose (data);                      { release the memory }
      Note: instead of data you could also do
        data : array [1..10000] of arrptr;

    Q: Does this have disadvantages
    A: Yes! It's slower and a bit dangerous.
    Q: Using the heap is dangerous?
    A: Yes!

    Double-check that you *always*, I mean really *ALWAYS*
    allocate all heap memory before you use it. Otherwise you
    will see the same thing happening that we are used to from C
    programs: in Windows it's called "General Protection
    Violation", other systems call it "Protected Mode Exception
    #13" or similar. In real mode the program will usually not
    cause such an error, it will just silently overwrite imporant
    things like other data, the program itself, other programs,
    DOS or whatever it finds in memory.
    This can cause anything from no negative effect at all to
    completely freezing the PC with only the reset button and
    power switch still operational. In extreme cases it may also
    cause data on the hard disk to be overwritten. That's very
    unlikely but in theory possible.
    Q: How can I use XMS memory?
    A: See
    http://www.brain.uni-freiburg.de/~klaus/pascal/sources/ for
    a unit that allows to use XMS.
    Q: What about other Pascal compilers?
    A: Check FPK-Pascal and GNU-Pascal. Both are free 32-bit
    Pascal compilers available for DOS that are more or less
    Borland compatible. If you want a Pascal compiler for Linux
    or OS/2, the two same compilers are available for these
    operating systems too plus a few more, see
    Q: This sounds as if the FAQ writer doesn't like Borland
    Pascal, right?
    A: Wrong, I *love* it and use it all the time, but I *hate*
    Borland for not offering new versions.
    Q: What about Delphi?
    A: It's not available for DOS,
    it's not available for Linux,
    it's not availalbe for OS/2.
Viktor Ivanov


It is interesting thanks i'll look into it.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.