Theo,
I just posted the solution on my forums.
The problem is twofold.
First, displaying popup menus during a mouse DOWN event, appears to give Windows trouble.
It is best to display popup menus on the mouse UP event. This prevents any lockups of dialogs
displayed right after the popup disappears. If you right click in most apps, you will notice a popup
menu does not appear until after the mouse up action.
Next, trapping the right mouse up event can't be done trhough simple subclassing with some of
the common controls (ie. listview, treeview). The reason is that when the mouse button goes down
the control does something strange which prevents the occurance of the WM_RBUTTONUP message
being sent to the controls window procedure. You only get WM_RBUTTONUP after a double click.
Fortunately, the common controls generate the NM_RCLICK notification event through WM_NOTIFY.
This gives you the mouse button up event for the right button, but some controls don't pass the
mouse position via NM_RCLICK. This means you need to trap the mouse position some other way.
In the code I posted on the forum, I subclass the control and trap the WM_RBUTTONDOWN event
and store the lparam value (mouse position) in a global variable and then in the NM_RCLICK event, I
use that value for displaying the popup menu. The coordinates though will have to be converted from
the control client arrea to the forms client area for displaying the popup menu.
The moral of the store is, display right click popup menus in the UP mouse action and not down.