D5: Popup menu doesn't close when item clicked

I seem to remember this was asked before, but I didn't archive the answer
and searching brings up nothing now. I'm trying to move my apps from Delphi
3 to Delphi 5, which of course triggers some "interesting" problems. One is
that a popup menu attached to a TRichEdit (the usual Cut, Copy, Paste etc.
commands) stays open after an item is clicked.

Specifically, what happens is:

* right-click the richedit; context menu pops up
* click "Paste"
* menu stays open, the Paste command is executed (you can see text added to
the editor even as the menu stays open)
* click "Paste" again, the Paste command is executed again, this time the
menu closes.

This happens to all commands in the menu; the menu is always closed after
TWO clicks (not necessarily the same menu item) - unless the command opens
a dialog box, which predictably does cause the menu to go away immediately.

A similar problem occurs with a popup menu attached to a TTreeView, except
the treeview lies on a tabsheet which has its own context menu; in this
case, after clicking a treeview context menu item, that menu is closed but
the menu of the underlying tabsheet pops up. Of course, none of these
problems happens when the application is compiled in Delphi 3.

Thanks in advance for any hints,
.marek jedlinski

Homepage, PGP Public Key: http://www.lodz.pdi.net/~eristic/
No ads, no nags freeware: http://www.lodz.pdi.net/~eristic/free/