这样,我们就可以在VC中通过上述两种方法向指定控件中添加右键菜单了,具体使用哪种方法,则可根据情况而选择。
http://blog.sina.com.cn/s/blog_8e61c70c010175hj.html
void CEikonaView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu Menu;
Menu.CreatePopupMenu();
Menu.AppendMenu(MF_ENABLED, ID_EDIT_UNDO, _T("撤销"));
Menu.AppendMenu(MF_SEPARATOR);
Menu.AppendMenu(MF_GRAYED, NULL, _T("另存为"));
Menu.AppendMenu(MF_ENABLED, ID_FILE_SAVE_AS, _T("Bitmap"));
Menu.AppendMenu(MF_ENABLED, ID_FILE_SAVEAS_GIF, _T("GIF"));
Menu.AppendMenu(MF_ENABLED, ID_FILE_SAVEAS_TIFF, _T("TIFF"));
Menu.AppendMenu(MF_ENABLED, ID_FILE_SAVEAS_JPEG, _T("JPEG"));
Menu.AppendMenu(MF_ENABLED, ID_FILE_SAVEAS_PNG, _T("PNG"));
Menu.AppendMenu(MF_ENABLED, ID_FILE_SAVEAS_JPEG2000, _T("JPEG-2000"));
Menu.AppendMenu(MF_SEPARATOR);
Menu.AppendMenu(MF_ENABLED, ID_RGBCHANNELVIEW, _T("RGB View"));
Menu.AppendMenu(MF_SEPARATOR);
Menu.AppendMenu(MF_ENABLED, ID_IMAGEPROCESSING_IMAGEINFORMATION, _T("Image Information"));
Menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
}