Solved

RichEdit And Plain Text Question.

Posted on 1998-09-08
19
730 Views
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.
0
Comment
Question by:hyperion66
  • 11
  • 7
19 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 100 total points
ID: 1339055
Click on the RichEdit and find the property that says PlainText. Set that to true and there is your plain text =)

Regards,
Viktor Ivanov
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1339056
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.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339057
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 ;)

Regards,
Viktor Ivanov
0
 

Author Comment

by:hyperion66
ID: 1339058
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.  
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339059
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.

//Viktor
0
 

Author Comment

by:hyperion66
ID: 1339060
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.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339061
Yes, I did that, but the color stays black.........I'm using Delphi3 Client/Server
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339062
Here is something you might try though =)

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

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

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339063
Instead clRed use clBlack or whatever color you want the text to be =)

//Vik
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:hyperion66
ID: 1339064
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.

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339065
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

Regards,
Viktro Ivanov
0
 

Author Comment

by:hyperion66
ID: 1339066
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.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339067
My e-mail is viktor@megsinet.net, and I also have it in my profile...

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339068
What happened, why do you accept my answer?
0
 

Author Comment

by:hyperion66
ID: 1339069
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.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339070
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.SelectAll;
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

Regards,
Viktor Ivanov
0
 

Author Comment

by:hyperion66
ID: 1339071
I would but i don't like the way it repaints.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339072
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
    dynamic.

    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
    EMS.
    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:
----------------------------------------------------------------------------

       type
          arr    = array [1..30000] of longint; { this is your data }
          arrptr = ^arr;                        { that's a pointer to the data }
       var
          data : arrptr;       { this is such a pointer variable }
       begin
          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 }
       end.
      Note: instead of data you could also do
       var
        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
    http://www.brain.uni-freiburg.de/~klaus/pascal/web-list.html
    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.
-------------------
Regards,
Viktor Ivanov
0
 

Author Comment

by:hyperion66
ID: 1339073
It is interesting thanks i'll look into it.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
proper way to parse url in delphi 2 132
TVirtualStringTree  search using TEdit 7 79
Help on project with Soap 10 43
Working with hours 3 31
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now