- // Convert the screen point to a client point
- wxPoint MenuPoint = ScreenToClient(wxPoint(x, y));
-
- // can't use GetSelection() here as it would assert in multiselect mode
- wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_MENU, this,
- wxTreeItemId(TreeView_GetSelection(GetHwnd())));
-
- // Get the bounding rectangle for the item, including the non-text areas
- wxRect ItemRect;
- GetBoundingRect(event.m_item, ItemRect, false);
- // If the point is inside the bounding rectangle, use it as the click position.
- // This should be the case for WM_CONTEXTMENU as the result of a right-click
- if (ItemRect.Contains(MenuPoint))
+
+ // the item for which the menu should be shown
+ wxTreeItemId item;
+
+ // the position where the menu should be shown in client coordinates
+ // (so that it can be passed directly to PopupMenu())
+ wxPoint pt;
+
+ if ( x == -1 || y == -1 )