C++ Programming
11-03-2009, 01:40 AM
HI all
DWORD pos = GetMessagePos();
CPoint point;
GetCursorPos(&point);
int nIndex = m_List.GetNextItem(-1, LVNI_SELECTED);
CString strItem = m_List.GetItemText(nIndex, 0);
select_no = m_List.GetSelectionMark();
HMENU hMenu = ::CreatePopupMenu();
if (NULL != hMenu)
{
// add a few test items
::AppendMenu(hMenu, MF_STRING, 1, "Update");
::AppendMenu(hMenu, MF_SEPARATOR,2, "");
::AppendMenu(hMenu, MF_STRING, 3, "Delete");
if(strItem.Trim().IsEmpty())
{
::EnableMenuItem(hMenu,1,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
::EnableMenuItem(hMenu,3,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
int sel = ::TrackPopupMenuEx(hMenu,TPM_LEFTALIGN|TPM_RETURNCMD,point.x,point.y,m_hWnd,NULL);
switch(sel)
{
case 1:
{
//for Update
}
break;
case 3:
{
//for delete
}
break;
}
}
thanks
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
DWORD pos = GetMessagePos();
CPoint point;
GetCursorPos(&point);
int nIndex = m_List.GetNextItem(-1, LVNI_SELECTED);
CString strItem = m_List.GetItemText(nIndex, 0);
select_no = m_List.GetSelectionMark();
HMENU hMenu = ::CreatePopupMenu();
if (NULL != hMenu)
{
// add a few test items
::AppendMenu(hMenu, MF_STRING, 1, "Update");
::AppendMenu(hMenu, MF_SEPARATOR,2, "");
::AppendMenu(hMenu, MF_STRING, 3, "Delete");
if(strItem.Trim().IsEmpty())
{
::EnableMenuItem(hMenu,1,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
::EnableMenuItem(hMenu,3,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
int sel = ::TrackPopupMenuEx(hMenu,TPM_LEFTALIGN|TPM_RETURNCMD,point.x,point.y,m_hWnd,NULL);
switch(sel)
{
case 1:
{
//for Update
}
break;
case 3:
{
//for delete
}
break;
}
}
thanks
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.