Excellent sample code, thanks for posting. Might refer back to this if I need to write DLL code.
I can confirm that your issue exists, or at least on Windows 8 64 bit, using the win32 widgetset. I presume you're also using the win32 widgetset? And my confirming your issue doesn't help you much :-(
I added a button to each form, then added manual popup code. Confirmed that the popup menu doesn't appear even if triggered manually.
Went looking on the bug tracker, found the following:
http://mantis.freepascal.org/view.php?id=18624Seems it's a known issue, and has been fixed for several other widgetsets, but not for Win32. On a whim, I tried applying the patch in the bug issue, and sure enough, it appears to have resolved the issue.