But ... where is the code? I am only a simple code monkey but when I write code it does something. This is just a maze. Where is the thing that does the thing?
...
Why can't I find it like the compiler does?
it's not a maze, but an amazing back bone of LCL, known as VMT-hack. It's a very old solution (back from the days when FPC didn't support interfaces), that still works.
And in fact, the compiler doesn't find the proper implementation as well.
What's happening is a
run-time construction of an additional virtual class, with a mix of methods from different classes. The mix is driven by the hierarchy you're trying to search through (TWSCustomRichMemoClass -> TWSCustomMemo -> TWSCustomEdit)
However, the actual implementation is being copied over from a selected widgetset.
For Win32, you might want to search TWin32WSCustomRichMemoClass (from richmemo package), TWin32WSCustomMemo (from LCL), TWin32CustomEdit (from LCL).
(one of those should have PasteFromClipboard method)
The VMT for the virtual classes is reconstructed based on the inheritance of TWin32WSxxx classes. (the same thing is explained
here)
However, once you find Win32 PasteFromClipboard you might find it pretty boring and uninteresting:
imptype procedure TWin32WSCustomEdit.Paste(const ACustomEdit: TCustomEdit);
begin
SendMessage(ACustomEdit.Handle, WM_PASTE, 0, 0)
end;
In other words, all the "fun part" of actually pasting an image into a rich edit is implemented within the system code, and is not available for the review.