Results 1 to 5 of 5

Thread: Context Menu

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485

    Resolved Context Menu [RESOLVED]

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width