can anyone point me in the direction of some rich text formatter code? (1 Viewer)

CJ_London

Super Moderator
Staff member
Local time
Today, 09:07
Joined
Feb 19, 2013
Messages
16,607
I've provided my client with a simple notepad linked to forms based on a table of memo fields linked to the form name. It provides a help function and can be made editable as a means for users to add their own notes about what the form does, things to pay attention to etc.

I've been asked if they can use richtext functionality to provide colour/bold/italic etc.

The problem is the app hides the access window so they do not have access to the ribbon. And anyway the form is popup so even if they could see the ribbon, they still would not be able to access it.

I've provided some basic functionality with some formatting styled buttons which works providing the user does not overlap formats - if they do, it messes everything up.

So this is OK - hello world

but this is not - hello world

users being users - it gets messed up.

The issue is selstart, seltext and sellength return a value based on plain text - all formatting codes are ignored.

My current thinking is to have a two dimensional array of the formatting codes, one element providing the location within the plain text and the other the formatting code.

so the above full string including formatting is

<div><font color=red><u>hello</u></font><u> world</u></div>

my array stores

0...<div><font color=red><u>
5...</u></font><u>
11..</u></div>

I can then use selstart and sellength to interrogate the array to determine whether there is formatting code included and add it back in before updating the .text property (with the new formatting codes) and updating the array with the location and structure of the new codes.

But before going down this route, has anyone else tried an alternative solution (which works)?

Thanks in advance

CJ
 

isladogs

MVP / VIP
Local time
Today, 09:07
Joined
Jan 14, 2017
Messages
18,209
I have 2 different rich text editors - simple & complex
I've adapted & attached the simple one so it runs with no app window (therefore no ribbon).



Formatting can be done either using keyboard shortcuts or the popup formatting window
The latter gives more options but there is a knack to getting it to appear & there can be a slight delay.
After highlighting text to be formatted, the formatting window appears but is faint, move away from the text & it appears normally

See attached file - use SHIFT bypass to view the code. Its fairly straightforward to follow

The more complex one has a full set of formatting controls



I've not tested that without an app window & it would take a while to make that into a standalone version that I could pass on to you

Let me know if either look useful to you
 

Attachments

  • RichTextEditor.zip
    146.8 KB · Views: 279
  • RichTextDEMO.jpg
    RichTextDEMO.jpg
    95.6 KB · Views: 370
  • SDAHelpEditor.jpg
    SDAHelpEditor.jpg
    100.9 KB · Views: 368

CJ_London

Super Moderator
Staff member
Local time
Today, 09:07
Joined
Feb 19, 2013
Messages
16,607
brilliant Colin, thanks - I think the simpler one will be fine for my requirements.

While investigation options I saw there was a way of inserting images, but all the examples I found were a) for the old rtf format and b) purported to be quite slow and anyway outside the scope of my requirement. But it's good to know it can be done

I'll check it out this weekend
 

isladogs

MVP / VIP
Local time
Today, 09:07
Joined
Jan 14, 2017
Messages
18,209
Hi
Excellent. Hope it does the job OK
I did the code for both this & the more complex version several years ago so some of it may not be as tidy as I would do it now... but it works fine. Its very quick in use

The reason the more complex version has a rich text & 'HTML' version is that the Help feature has 2 options for each record:
a) Basic (Less Details) - rich text & hyperlinks only
b) More Details - rich text + images / video clips & hyperlinks
Obviously both have to be memo fields

a) uses a standard textbox
b) uses a web browser window which meant the report print preview had to use 'special code'

See attached screenshots
 

Attachments

  • HelpFileLessDetails.PNG
    HelpFileLessDetails.PNG
    41.4 KB · Views: 295
  • HelpFileMoreDetails.jpg
    HelpFileMoreDetails.jpg
    91.2 KB · Views: 292
  • HelpFileReport.jpg
    HelpFileReport.jpg
    87.6 KB · Views: 341

CJ_London

Super Moderator
Staff member
Local time
Today, 09:07
Joined
Feb 19, 2013
Messages
16,607
I did wonder about using a webbrowser control rather than a textbox but hadn't got around to investigating the possibilities
 

Users who are viewing this thread

Top Bottom