• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

Displaying Popupmenu over a List Contol

Hi,
    How to display a Pop up meny when i right-
    click on a CListControl widget,

    I tried by adding onRightClick function, but this
    does not return me the current clicked mouse position.

void CTestDlg::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here


     *pResult = 0;
}

Regards
Prashanth
0
prashanthgn
Asked:
prashanthgn
1 Solution
 
AlexFMCommented:
You can use GetCursorPos to get screen cursor coordinates. Don't forget to convert them to client dialog/list coordinates.
0
 
Roshan DavisCommented:
void CTestDlg::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
{
     if( m_wndListCtrl.GetSelectedCount() )
     {
          CMenu     oMenu;
         
          // IDR_POPUPMENU - menu added in the resource
          if( !oMenu.LoadMenu(IDR_POPUPMENU) )
          {
               *pResult = 0;
               return;
          }

          // Getting first submenu of the resource added menu
          CMenu     *pSubMenu = oMenu.GetSubMenu(0)     ;
          POINT     oPoint;

          GetCursorPos(&oPoint);

          pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
                                         oPoint.x,
                                         oPoint.y,
                                         this);

          pSubMenu->DestroyMenu();
          oMenu.DestroyMenu();
     }
     
     *pResult = 0;
}

Good Luck
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now