void MyFrame::OnListCtrlRightClick(wxListEvent& event) { wxPoint position = event.GetPoint(); wxMenu menu; menu.Append(1001, "Copy"); menu.Append(1002, "Paste"); PopupMenu(&menu, position.x, position.y); }
void MyFrame::OnListItemActivated(wxListEvent& event) { wxPoint position = event.GetPoint(); wxString item = m_listCtrl->GetItemText(event.GetIndex()); wxMessageBox(item, "Selected Item"); if (position.x > 100 && position.y > 100) { MyDialog dialog(this, wxID_ANY, "Dialog Title"); dialog.ShowModal(); } }In this example, we use the GetPoint method to obtain the position of the mouse click event and check if it is within a certain range. If it is, we create and display a modal dialog box using the MyDialog class. We also display a message box showing the selected item from the list control. In both examples, we use the wxListEvent class and its GetPoint method, which are a part of the wxWidgets library.