Hi. I apologize in advance for the lengthy post, but I didn't want to leave anything out.
I'm having a problem with executing context menu commands. In my list view, I've managed to display the context menu when a list item is right-clicked on, however, when I try to execute any of the menu commands, nothing happens.
I started up the debugger and had a look at the stack trace. It seems that the message handler that I specified using the ON_COMMAND macro (which I named `OnPopupCommand'), is being passed an incorrect menu item ID value, but the functions that were called before that had been the correct menu item ID value. My knowledge of the debugger and its capabilities is limited, so I am now at a dead end. Here are the last few lines of the the stack trace:
32775 is the value of the menu item ID `ID_BDMITM2', but somehow, OnPopupCommand is being passed some other value. Here's how I defined the message handler in my CVIW_List class (CListView):
In the same class, I also have a handler for double click events, where I call OnPopupCommand explicitly ...
I'm having a problem with executing context menu commands. In my list view, I've managed to display the context menu when a list item is right-clicked on, however, when I try to execute any of the menu commands, nothing happens.
I started up the debugger and had a look at the stack trace. It seems that the message handler that I specified using the ON_COMMAND macro (which I named `OnPopupCommand'), is being passed an incorrect menu item ID value, but the functions that were called before that had been the correct menu item ID value. My knowledge of the debugger and its capabilities is limited, so I am now at a dead end. Here are the last few lines of the the stack trace:
Code:
CVIW_List::OnPopupCommand(unsigned int 1244532) line 317
_AfxDispatchCmdMsg(CCmdTarget * 0x00302220 {CVIW_List hWnd=0x00050460}, unsigned int 32775, int 0, void (void)* 0x00401212 CVIW_List::OnPopupCommand(unsigned int), void * 0x00000000, unsigned int 12, AFX_CMDHANDLERINFO * 0x00000000) line 88
CCmdTarget::OnCmdMsg(unsigned int 32775, int 0, void * 0x00000000, AFX_CMDHANDLERINFO * 0x00000000) line 302 + 39 bytes
CView::OnCmdMsg(unsigned int 32775, int 0, void * 0x00000000, AFX_CMDHANDLERINFO * 0x00000000) line 159 + 24 bytes
32775 is the value of the menu item ID `ID_BDMITM2', but somehow, OnPopupCommand is being passed some other value. Here's how I defined the message handler in my CVIW_List class (CListView):
Code:
ON_COMMAND(ID_BDMITM2, OnPopupCommand)
In the same class, I also have a handler for double click events, where I call OnPopupCommand explicitly ...
Code:
void CVIW_List::OnItemDoubleClick(NMHDR* pNMHDR, LRESULT* pResult)
{
... // Get POSITION of affected list item.
if(pos)
{
int nIndex = myListCtrl.GetNextSelectedItem(pos);
switch(m_nSelection)
{
case IID_BENEDB_1:
CVIW_List::OnPopupCommand(ID_BDMITM2);
break;
}
}
... // Done.
}[code]
... and everything works fine.
This problem has become increasingly frustrating, so any suggestions or comments would be greatly appreciated. Thanks in advance.