Context Menu on CCheckBoxList Items only when an item is selected
Posted on 2010-11-18
I have a Main UI (MP_UI), which comprises of various controls. One of the controls is a ListBox Control.
The items inside are CCheckListBox based items.
What I am trying to do is add a context menu when the user selects a check box item and right clicks. Right Click function should only be part of the listbox control (IDC_HOST_LIST) and only when an item is selected.
I have a class CCheckListBoxMP, which is a derived class from CCheckListBox. The member functions in CCheckListBoxMP allows the user to do operations like add an item, delete an item, rename, update etc.
I added a WM_CONTEXTMENU to CCheckListBoxMP.cpp and implemented the function CCheckListBoxMP::OnContextMenu(CWnd, CPoint).
However I cannot seem to access the popup menu (which is partt of the MainUI.rc) in my CCheckListBoxMP. How will I do it.
Also how do I invoke right click on MainUI such that the OnContextMenu is correctly called and displayed.