Author Topic: RichMemo ► no arrow visible in text  (Read 1061 times)

rvk

  • Hero Member
  • *****
  • Posts: 7120
Re: RichMemo ► no arrow visible in text
« Reply #15 on: October 28, 2026, 08:25:33 pm »
Question:
How to make ► (Alt + Num Block 16) work in my RichMemo as texteditor at runtime?
I'm also actually wondering why you use alt+14 or alt+16?

It's normally a control character which should be used directly.
Does it work in WordPad?
The music and arrow signs are just a representation in the OEM DOS charset. They are not actually official in most character sets there.

You should use Alt+9835 or type 266B then press Alt + X.
(I haven't tested this yet)
Edit: Just confirmed. Both these work on Windows 7 in Richmemo and are actually the correct way to enter these symbols.

I think richmemo does something strange on Windows 10 because it shouldn't display that character in riched20.dll (while it did work in tedit). And in the end of its translated to the normal unicode character. Not the char(14).




« Last Edit: October 28, 2026, 10:24:58 pm by rvk »

CM630

  • Hero Member
  • *****
  • Posts: 1842
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: RichMemo ► no arrow visible in text
« Reply #16 on: October 29, 2026, 02:54:55 pm »
Yet another bug in TRichMemo: when the Insert key is pressed it shall switch to INSERT mode and change the cursor from | to █. It changes the mode, but does not change the cursor.


...
I'm also actually wondering why you use alt+14 or alt+16?

It's normally a control character which should be used directly.
Does it work in WordPad?
...
It should work in every single text entering app in Windows, including WordPad (which is not included in windows 11).
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

rvk

  • Hero Member
  • *****
  • Posts: 7120
Re: RichMemo ► no arrow visible in text
« Reply #17 on: October 29, 2026, 04:29:02 pm »
Yet another bug in TRichMemo: when the Insert key is pressed it shall switch to INSERT mode and change the cursor from | to █. It changes the mode, but does not change the cursor.
By default, Windows' standard Rich Edit implementation (riched20.dll) does not automatically change the cursor (caret) shape when switching between Insert and Overwrite (Overtype) modes. You can of course do this through code.

It should work in every single text entering app in Windows, including WordPad (which is not included in windows 11).
The rich-edit documentation says nothing about ALT+#. It does mention ALT+0# in which case unicode characters are inserted.
https://learn.microsoft.com/en-us/windows/win32/controls/about-rich-edit-controls

When using ALT+# the bare boned char(14) is send to the component. Riched20.dll does nothing with that because it's a control character (SO - shift out) same as TAB and BEL. You can also use Keybd_Event to send that character but it will still do nothing.

But ok... if you want to convert the control character to a unicode character, that can be done.

rvk

  • Hero Member
  • *****
  • Posts: 7120
Re: RichMemo ► no arrow visible in text
« Reply #18 on: October 29, 2026, 05:10:31 pm »
BTW Different editors show the overwrite as different cursors. Notepad++ shows a ▁ (probably like a unicode 0x2581) for overwrite mode. LibreOffice shows a block over the character to be overwritten (but it stays at | if at the end of the line). Not sure how MS Word does.

CM630

  • Hero Member
  • *****
  • Posts: 1842
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: RichMemo ► no arrow visible in text
« Reply #19 on: October 30, 2026, 08:47:52 pm »
...The rich-edit documentation says nothing about ALT+#. It does mention ALT+0# in which case unicode characters are inserted...
You have gone in the wrong ruts, so I will try to explan it with more details, sorry if I am too verbose;

Between the keyboard and the apps there is a layer, let us call it KLM (keyboard layot manager).
So when I press keys, KLM processes them and passes to the apps, controls, components, etc.
For example, when you press the key labelled with Y, RichMemo might add an Y, but in Germany you would rather get an Z, and I will get an Ъ.
Some keyboard layouts use dead keys - you press a dead key and nothing is sent to the controls, until you press another key, which will send to the controls something depending on the dead key + next key.
So it is the same with alt + numpad : alt + 16 sends ►; alt + 12 sends ♀; alt + 253 send ¤ .... I typed them in the browser, it shows the, because it gets the from KLM.

That is why documentatin says nothing about alt + numpad. All it has to say is "when you get a printable character - print it."

At least I believe that it works this way.


BTW Different editors show the overwrite as different cursors. Notepad++ shows a ▁ (probably like a unicode 0x2581) for overwrite mode. LibreOffice shows a block over the character to be overwritten (but it stays at | if at the end of the line). Not sure how MS Word does.
So sadly, it occurs there is no standard replace character, but the standard behaviour is to change the cursor in Insert mode  :-X
« Last Edit: October 30, 2026, 08:51:37 pm by CM630 »
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

rvk

  • Hero Member
  • *****
  • Posts: 7120
Re: RichMemo ► no arrow visible in text
« Reply #20 on: October 30, 2026, 09:08:14 pm »
That is why documentatin says nothing about alt + numpad. All it has to say is "when you get a printable character - print it."

At least I believe that it works this way.
My point is that a keyboard doesn't send characters. It sends bytes.
And byte 14 and 16 are control characters from origin.
And that's not printable in richedit.

Unless you can show me rtf source/font where a 14 or 16 character is used like:
\'0e

In the original IBM PC (OEM font/Code Page 437), character 14 was visually mapped to the Beamed Eighth Notes symbol (♫). When you press Alt + 14 on a Windows numeric keypad, Windows outputs that exact music note.

However, RTF reads raw hexadecimal values strictly through modern character maps. If you feed an RTF reader the literal control character code \'0e (which is hex for 14), it interprets it as the invisible Shift Out control command rather than the music symbol.

On TEdit you get the music symbol because Windows does an automatic font-fallback to Segoe UI for that character. But riched20.dll does not. Maybe newer versions of richedit (Msftedit.dll) do too, but that's not guaranteed.

BTW. You can check that TEdit used font-fallback because if you save the field to a non Unicode database, the music symbol is ready back as ?, not as the original music symbol. Believe me, I know because I'm running a non unicode database here  ;)

BTW #2. The Wordpad on Windows 10 does the font-fallback because it accepts Alt+14 (and you can see it switches to Segoe UI Symbol.

And:
Quote
If you are strictly using riched20.dll (Rich Edit 2.0/3.0), it treats Alt code entries via the older OemToChar translation rules. This often causes Alt+14 to inject a legacy ASCII control character (0x0E, Shift Out) rather than translating it cleanly into the Unicode U+266B string.

• Upgrade the DLL: Switch to msftedit.dll (Rich Edit 4.1+), which parses Alt codes natively into modern Unicode characters.
• Intercept the Input: Intercept the WM_CHAR or WM_KEYDOWN message in your window procedure, check if WPARAM is 14, and manually insert the string L"\u266B" using EM_REPLACESEL.
« Last Edit: October 30, 2026, 09:26:36 pm by rvk »

jamie

  • Hero Member
  • *****
  • Posts: 8072
Re: RichMemo ► no arrow visible in text
« Reply #21 on: October 30, 2026, 10:16:36 pm »
In my Win10 system, using a Tedit and ALT+#16 simply spits out a unicode (UTF8) string which is 3 bytes, so no lower characters are actually being inserted.

 
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Edit1Change(Sender: TObject);
  2. begin
  3.   Caption := Length(Edit1.Caption).Tostring;
  4. end;        
  5.  

 Just type it out and you get the number of chars that is added to the EDIT.Caption and it shows the system is just spitting out UTF8 chars.

Jamie

The only true wisdom is knowing you know nothing

rvk

  • Hero Member
  • *****
  • Posts: 7120
Re: RichMemo ► no arrow visible in text
« Reply #22 on: October 30, 2026, 10:59:23 pm »
In my Win10 system, using a Tedit and ALT+#16 simply spits out a unicode (UTF8) string which is 3 bytes, so no lower characters are actually being inserted.
Yes, And that's because the TEdit component does the font-fallback conversion.
It also does this correctly on Windows 7 in TEdit.

But... the older msftedit.dll (4.1) from Windows 7 (and much older riched20.dll with RichEdit20W) don't do this.

My guess is that the newer msftedit.dll in Windows 10 does do the fallback.
I can confirm this because when I forced the system riched20.dll to load (with RichEdit20W) on Windows 10 (I changed the loading code in richmemo), it stopped working there too.

I then took a newer 64 bit RICHED20.DLL (plus MSPTLS.DLL) from Office16, forced my program to load it and created a RichEdit60W... and YES, the Alt+14 started working.

So it's the older richedits (msftedit.dll < 8.5 and the older riched20.dll with RichEdit20W) which don't do the automatic fond binding with fallback for certain keys.

Edit... you can use the class RichEdit20W but you do need the newer riched20.dll version 8.0 (or msftedit.dll 8.5+).
Yeah, I've got them all  %) Up to about 14 versions now.
(BTW Those newer versions also need the VC++ Redistributable if not already installed, which on a clean win7 system is not)
« Last Edit: October 30, 2026, 11:51:05 pm by rvk »

CM630

  • Hero Member
  • *****
  • Posts: 1842
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
« Last Edit: November 04, 2026, 09:42:20 am by CM630 »
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

rvk

  • Hero Member
  • *****
  • Posts: 7120
Re: RichMemo ► no arrow visible in text
« Reply #24 on: November 04, 2026, 11:57:59 am »
https://gitlab.com/freepascal.org/lazarus/lazarus/-/work_items/42698
Not sure if you want to fix all problems related with older riched20.dll. Then I also have a few more  :P

https://gitlab.com/freepascal.org/lazarus/lazarus/-/work_items/42697
The cursor could be easily implemented in your own code, at least on Windows.

Something like (where W is the width you want for the cursor and H is the height of the font/line):
Code: Pascal  [Select][+][-]
  1.   Windows.GetCaretPos(P);
  2.   Windows.DestroyCaret;
  3.   Windows.CreateCaret(RichMemo1.Handle, 0, W, 2);
  4.   Windows.SetCaretPos(P.X, P.Y + H - 2);
  5.   Windows.ShowCaret(RichMemo1.Handle);

But it needs to be executed after each OnMouseUp and OnKeyUp because riched20.dll/msftedit.dll recreates/positions the cursor each time. You could call a procedure which recreates the insert cursor with Application.QueueAsyncCall to make sure it's done after TRichMemo handles it.

As I understand WM_SETFOCUS creates the caret and WM_KILLFOCUS destroys it. But also during font changes (during positioning) the caret can also change size. I don't think riched20.dll was ever intended to handle an insert caret itself.

You can also do it by hooking the WndProc and setting the cursor. But that might be more difficult in cross-platform because I'm not sure what TRichMemo does on Linux when switching to insert. And fixing TRichMemo should naturally be done cross-platform.

BTW TEdit also doesn't change cursor, but is also doesn't have Insert-mode.

https://gitlab.com/freepascal.org/lazarus/lazarus/-/work_items/42696 (copied from https://github.com/skalogryz/richmemo/issues/13
Yeah, I remember that one  ;)
Still not fixed.

CM630

  • Hero Member
  • *****
  • Posts: 1842
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: RichMemo ► no arrow visible in text
« Reply #25 on: November 04, 2026, 01:09:04 pm »
Not sure if you want to fix all problems related with older riched20.dll. Then I also have a few more  :P
“Will not fix” is also a common issue resolution.
At least this info can be added in the wiki.

BTW TEdit also doesn't change cursor, but is also doesn't have Insert-mode.
Indeed, I have already checked that. If it is up to my preference, the best way to fix the issue is to remove the INSERT mode at all.
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

 

TinyPortal © 2005-2018