The final menu is so simple by comparison with the rest it is hardly necessary to explain how to implement it! What is more difficult is to say when it should be used. It certainly shoudn't be used as ...
I have a button that calls TrackPopupMenuEx and I want to use SetCursorPos to put the cursor on the top item of the popup. But Windows relocates the popup when it doesn't fit entirely on the desktop ...