Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
While I am trying to create a context menu with the code I am getting exception(code:c000005) and my application is crashing:

C++
void CMenusDlg::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	// TODO: Add your message handler code here
	CMenu *m_lMenu;
	CPoint m_pPoint;
	m_pPoint=point;
	ClientToScreen(&m_pPoint);
	m_lMenu =  GetMenu();
	m_lMenu = m_lMenu ->GetSubMenu(0);
	m_lMenu->TrackPopupMenu(TPM_CENTERALIGN+TPM_LEFTBUTTON,m_pPoint.x,m_pPoint.y,this,NULL);

}


How to resolve this issue?
Posted
Updated 28-Apr-15 4:00am
v4
Comments
Leo Chapiro 28-Apr-15 6:50am    
Do you have any question, dude?
Member 11648410 28-Apr-15 8:19am    
yeah...while i am trying to create a context menu with the code i am getting exception(code:c000005) and my application is crashing..how to resolve this issue
Richard MacCutchan 28-Apr-15 9:37am    
Use your debugger to see if GetMenu() actually returns a valid menu pointer. Is that really a minus sign rather than equals?
Leo Chapiro 28-Apr-15 10:01am    
It makes no sense with minus sign: I have changed to equal sign.
Richard MacCutchan 28-Apr-15 11:04am    
But if that was OP's actual code then I'm not surprised it gave an access error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900