Replace Text with Image

General TRichView support forum. Please post your questions here
Post Reply
LonelyRanger
Posts: 11
Joined: Sun Jul 23, 2006 6:11 am

Replace Text with Image

Post by LonelyRanger »

Hello,

QUESTION 1
========
The components are still fairly new to me but progressing through it slowly. My question, if you dont mind answering, is about replacing text that is added to a RichViewEdit with an image (smileys).

For Example: if the text is entered on a new line, I want to new line to be examined and replace ":)" with a smiley image.

Maybe there is an easier way to go about it than i have mentioned above, i dont know. All thoughts welcome.

QUESTION 2
========
If (during runtime) I change a TextSyle Item property it will change all the text in the RichViewEdit relating to that TextStyle.

For Example: I have a line of text with Arial and Bold, then i add another line after changing the TextStyle that i want to be Courier and Italics, it will change everything to the new TextStyle. How can i not make everything change but only the text i want. (this is done just before i add the text)


Thankyou,
LR
Last edited by LonelyRanger on Sun Jul 23, 2006 10:15 am, edited 1 time in total.
LonelyRanger
Posts: 11
Joined: Sun Jul 23, 2006 6:11 am

Replace Text with Image

Post by LonelyRanger »

that :) is meant to be a ": )" sorry.
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

Post by Michel »

Hi!
Your smiley idea sounds conceptually similar to AutoCorrect. Search for "AutoCorrect" in the ActionTest source code to see what it does and from what events.
As to styles, take a look at ApplyStyleConversion() in the Help and in at least one of the smaller Editor demos (and ActionTest if you like). Also, it has been mentioned on these forums a few times.
Good luck!
Michel
LonelyRanger
Posts: 11
Joined: Sun Jul 23, 2006 6:11 am

Post by LonelyRanger »

I will look into it,

Thankyou Michel!
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1) For smilies, see the demo
Demos\Delphi\Assorted\Graphics\Emoticons\
It shows several ways of detecting smilies.

2) In your e-mail, you also asked about adding text with URLs.
You can see the following demos:
Demos\Delphi\MultiDemo, "Chat simulation" (user enters one line of plain text, URLs are detected when copying to chat window)
Demos\Delphi\Assorted\Hypertext\URLs (detecting URLs on typing, detecting all URLs in TRichView)

3) Yes, if you change properties of some text style, it affects all text fragments that use this text style. So, for each new text formatting, a new text style must be used. That does not mean that you must create a huge number of styles for all possible text formatting. Styles can be created dynamically, and reused if possible.
Demos:
- Demos\Delphi\Editors\Editor 2\ (applying commands like "Make Bold" to the selected fragment in editor)
- http://www.trichview.com/forums/viewtopic.php?t=63
Post Reply