Ever wanted to use some fancy Unicode emotes in your Delphi application? Well good luck with that, because the RichEdit controls are using a library that’s so old it even supports Windows 95! An OS that had no support for more than 16 years (support ended December 31, 2001)!
So why isn’t embarcadero also dropping support for that and use a library for at least Windows XP (let’s be serious, enough people are still using it). The reason probably would be because either way embarcadero want’s to still support it (like Windows 3.11) or because Microsoft doesn’t offer really good alternatives.
So let’s look at the possibilities Microsoft gives us here; Looking at the MSDN-Page about the RichEdit-Control (https://msdn.microsoft.com/en-us/library/windows/desktop/bb787873(v=vs.85).aspx) we can see that it’s documented from version 1.0 (Windows 95) up to 4.1 (Windows XP), but aren’t there any other versions? I mean Microsoft can’t seriously not have updated their RichEdit-Control since Windows XP, right? They have! But not for everyone! If you want to use a version higher than 4.1 you would need Microsoft Office.
This is obviously not a solution having Microsoft Office as requirement for your application and embarcadero probably thinks the same way. So what are your solutions? Use the latest version you can use without worrying about too much! In this case it would be version 4.1 which also supports Unicode.
Getting RichEdit 4.1
To enable support for RichEdit 4.1 in your RichEdit-controls you need to load the library and tell your control to use another version:
unit UnicodeRichEdit; interface uses Vcl.Controls, Vcl.ComCtrls; type TUnicodeRichEdit = class(TRichEdit) protected procedure CreateParams(var Params: TCreateParams); override; end; implementation uses System.Classes; procedure TDSUnicodeRichEdit.CreateParams(var Params: TCreateParams); begin inherited; // Tell the RichEdit control to use 4.1 CreateSubClass(Params, 'RICHEDIT50W'); end; var FRichEditUnicodeModule: HMODULE; initialization begin // Load the library FRichEditUnicodeModule := LoadLibrary('MSFTEDIT.DLL'); if FRichEditUnicodeModule &lt;= HINSTANCE_ERROR then begin raise Exception.Create('Could not load library "MSFTEDIT.DLL"!'); end; end; finalization begin // Free the library if FRichEditUnicodeModule &lt;&gt; 0 then begin FreeLibrary(FRichEditUnicodeModule); end; end; end.
A complete package ready to install is also available at GitHub: https://github.com/delphi-sucks/DSUnicodeRichEdit
- Download the latest version from https://github.com/delphi-sucks/DSUnicodeRichEdit/archive/master.zip
- Open the project-file “src/DSUnicodeRichEdit.dpk”
- Install it (right click on the project in the project overview and “Install”)
- Go to Tools > Options > Delphi Options > Library
- Add the path to the src folder to the Library-Path (repeat this step for every platform you want to use this component with)
It’s a bit tricky but with a small amount of code you can have Unicode emotes in your RichEdit control and also enjoy the old new features of version 4.1. If you are concerned about reliability then don’t worry; After a long period of use in a production environment I had no single error. You only have to consider that you need to have at least Windows XP otherwise it won’t run.
Have RichEdit-controls with Unicode support by using the DSUnicodeRichEdit package.