#define ID_MENUITEM_OPEN 1001
#define ID_MENUITEM_DISPLAY 1002
#define ID_MENUITEM_DELETE 1003
#define ID_MENUITEM_EXIT 1004
CPoint point;
GetCursorPos(&point);
CMenu menuPopup;
menuPopup.CreatePopupMenu();
menuPopup.AppendMenu( MF_STRING, ID_MENUITEM_OPEN, "打开" );
menuPopup.AppendMenu( MF_SEPARATOR );
menuPopup.AppendMenu( MF_STRING, ID_MENUITEM_DISPLAY, "显示" );
menuPopup.AppendMenu( MF_SEPARATOR );
menuPopup.AppendMenu( MF_STRING, ID_MENUITEM_DELETE, "删除");
menuPopup.AppendMenu( MF_SEPARATOR );
menuPopup.AppendMenu( MF_STRING, ID_MENUITEM_EXIT, "退出");
int nCmd = ( int ) menuPopup.TrackPopupMenu(
TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD,
point.x,
point.y,
AfxGetMainWnd() );
switch( nCmd )
{
case ID_MENUITEM_OPEN:
OnOpenButton() ;
break;
case ID_MENUITEM_DISPLAY:
OnChartButton();
break;
case ID_MENUITEM_DELETE:
OnDeleteButton();
break;
case ID_MENUITEM_EXIT:
exit(0);
}