Hi, I was learning this Context Menu example based on an e-book where I've been supplied with this code
Code:
1: void CMenusDlg:: OnContextMenu(CWnd* pWnd, CPoint point)
2: {
3: // TODO: Add your message handler code here
4:
5: ///////////////////////
6: // MY CODE STARTS HERE
7: ///////////////////////
8:
9: // Declare local variables
10: CMenu *m_lMenu; // A pointer to the menu
11: CPoint m_pPoint; // A copy of the mouse position
12:
13: // Copy the mouse position to a local variable
14: m_pPoint = point;
15: // Convert the position to a screen position
16: ClientToScreen(&m_pPoint);
17: // Get a pointer to the window menu
18: m_lMenu - GetMenu();
19: // Get a pointer to the first submenu
20: m_lMenu = m_lMenu->GetSubMenu(0);
21: // Show the Popup Menu
22: m_lMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON,
23: m_pPoint.x, m_pPoint.y, this, NULL);
24:
25: ///////////////////////
26: // MY CODE ENDS HERE
27: ///////////////////////
28: }
The compilation went smoothly except there are 2 warnings on line 18 and 20.
Nevertheless, the application runs, but when I do a right click on the form, it crashes.....
Any idea what's wrong with it?
Thanks for any help
Harddisk
PS:It's an MFC exe
Last edited by Harddisk; Oct 10th, 2005 at 09:53 PM.
Those pages are scanned with a text recognition algoritm, so code often gets mistyped, - on line 18 should be =
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.