I try your code but sadly not compile.
Why not? What is the actual error? On which line of code? I don't have FreePascal installed, so I can't compile it myself, but I don't see anything in the code I posted that shouldn't compile in either mode.
both lines same error:
Error: Illegal qualifierNevermind because with the {$Mode Delphi} compiles fine with 3 warnings:
Hint: Conversion between ordinals and pointers is not portableI checked again and after change the mode, the code produce the desired result in the memo.
My mistake (possible a bad copy/paste).
Thanks for this new code!