Whenever I post here I'm usually seeking answers to issues that elude me but Today I have had a small victory over that ways that Lazarus/FPC endeavours to thwart me without the need to interupt the very busy lives that contributors here have

The project involves entering a HEX number into a TEdit and since there is no Property 'HexOnly' (as there is a NumbersOnly
(with limited usefulness)) and I wish to trap 'Invalid Key Strokes' to display meaningful information, I set about writing a 'Key Validation' routine. Nothing really taxing once you get your head around the difference between 'KeyNumber' and 'ScanCode' but I had one 'silly' irritation.
When an invalid character was used, I could trap it, determine what it was, show the user what key was unacceptable and remove it from the 'string', All well and good BUT the editing position within the string was always set at the start - rather than the position that the invalid key was typed.
At this point I didn't even know what 'property' I needed to modify to set the 'Cursor' position. A little research and I discovered '
CaretPos' and sure enough I soon found that as a 'Property' of the TEdit. Now I could store this property at the start of the validation and retrieve it at the end - - - '
simples' - - -
wrong!
Yes, I could assign it to a var at the start - though initially I declared that as 'Byte' when in fact it's a 'TPoint' but that was a minor issue - and restore it at the end, but the result was that the position was always one character to the right of the original ???
Ah - I thought - take 1 off the TEdit.CaretPos 'X' - - - again wrong, compiler says 'not allowed' - Next attempt, modify the Var (which of course is also a TPoint but not a 'property' of the TEdit). That
is allowed, so, assign the Var, take one off the 'X' property then at the end of the proc. assign the TEdit.CaretPos to the Var - - - fully acceptable.
I said at the start that I wasn't interupting your busy lives but if you've read this far of course I have

sorry - I hope that it is minimal - but this tale may assist someone else who needs to know where the cursor actually is (for whatever reason!) - and it's always good to share a 'success'
🤣