建立工程
插入资源
菜单
对话框
编辑菜单
编辑主菜单
编辑子菜单
编辑对话框
对话框类
创建类
添加消息
1.添加对话框消息
2.添加菜单消息
编辑
编辑菜单消息
void CTest1View::OnShow()
{
// TODO: Add your command handler code here
MyDlg dlg;
dlg.DoModal();
}
void CTest1View::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu menu;
menu.LoadMenu(IDR_MENU1);
CMenu* pPopup=menu.GetSubMenu(0);
pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
}
编辑对话框消息
添加变量
取值求平方
运行结果