[求助]如何在datagrid中增加右键菜单
我想在datagrid中增加一个右键菜单,然后通过点击右键菜单可以选择对数据库表行的删除和插入.我现在是不知道怎样做这个右键菜单..高手指点一下.在当前的window中加上WMCONTEXTMENU的message handler,然后在生成的function中加入如下程序:
void CYourView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// pop up menu
CMenu menu;
// see if the current window is the parameter list
YourControlType *pControl = (YourControlType *)GetDlgItem(resource id);
YourControlType *pWndList = (YourControlType *)pWnd;
if (pList != pWndList)
return; // it's not, get out
VERIFY(menu.LoadMenu(menu resource id));
// get first (only) tree of popup menu
if ((menu.GetSubMenu(0)) == NULL)
return;
menu.GetSubMenu(0).TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
}